餐饮管理系统大作业SQL/C#
来源:互联网 发布:如何破解mac迅雷限速 编辑:程序博客网 时间:2024/04/30 18:48
using System.Data.SqlClient;
//数据绑定
private void BindData()
{SqlConnection con=new SqlConnection(s);
SqlDataAdapter sda = new SqlDataAdapter("select * from cpb",con);
DataSet ds = new DataSet();
sda.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.Columns[0].HeaderText = "菜名";
dataGridView1.Columns[1].HeaderText = "菜品种类";
dataGridView1.Columns[2].HeaderText = "菜品容量";
dataGridView1.Columns[3].HeaderText = "菜品价格";
}
//修改按钮
private void buttonxg_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count > 0)//有选中的行
{
string names = dataGridView1.SelectedCells[0].Value.ToString();
SqlConnection con = new SqlConnection(s);
con.Open();
string s3 = "update cpb set cpname='"+textBoxcpm.Text+"',cptype='"+textBoxcpzl.Text+"',cpstore="+textBoxcpyl.Text+",cpprice="+textBoxcpjg.Text+"where cpname='" + names.Trim() + "'";
SqlCommand cmd = new SqlCommand(s3, con);
cmd.ExecuteNonQuery();
con.Close();
BindData();
}
}
//program.cs 登陆主界面切换
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Formdl fl = new Formdl();
fl.ShowDialog();
if (fl.DialogResult == DialogResult.OK)
{
MainForm mf = new MainForm();
mf.name = fl.textBox1.Text;
mf.password = fl.textBox2.Text;
mf.time = DateTime.Now.ToShortDateString();
Application.Run(mf);
}
else
{
return;
}
}
private void button1_Click(object sender, EventArgs e)
{
string s = "server=localhost;Database=cygl;uid="
+ textBox1.Text.ToString() + ";pwd=" + textBox2.Text.ToString();
con = new SqlConnection(s);
try
{
con.Open();
if (con.State == ConnectionState.Open)//判断数据库是否连接成功
{
con.Close();
this.DialogResult = DialogResult.OK;
this.Close();
}
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
}
//主界面 listview控件 激活 记得设置LISTVIEW的视图和LARGEIMAGELIST
private void MainForm_Activated(object sender, EventArgs e)
{
lv.Items.Clear();
s = "server=localhost;Database=cygl;uid=" + name + ";pwd=" + password;
SqlConnection con = new SqlConnection(s);
con.Open();
SqlCommand cmd = new SqlCommand("select * from ztb",con);
sdr = cmd.ExecuteReader();
while(sdr.Read())
{
string zt=sdr["state"].ToString().Trim();
AddItems(zt);
}
con.Close();
}
private void AddItems(string zt)
{
if(zt=="0")
{
lv.Items.Add(" "+sdr["tableid"].ToString(), 0);//imagelist中的图片索引
}
else
{
lv.Items.Add(" " + sdr["tableid"].ToString(), 1);
}
}
private void lv_Click(object sender, EventArgs e)
{
string names = lv.SelectedItems[0].SubItems[0].Text;//点击选中的LV中的项目
s = "server=localhost;Database=cygl;uid=" + name + ";pwd=" + password;
SqlConnection con = new SqlConnection(s);
con.Open();
SqlCommand cmd = new SqlCommand("select * from ztb where tableid="+names, con);
sdr = cmd.ExecuteReader();
sdr.Read();
string zt = sdr["state"].ToString().Trim();
sdr.Close();
if(zt=="0")
{
this.contextMenuStrip1.Items[0].Enabled = false;
this.contextMenuStrip1.Items[1].Enabled = true;
this.contextMenuStrip1.Items[3].Enabled = true;
this.contextMenuStrip1.Items[5].Enabled = true;
}
if(zt=="1")
{
this.contextMenuStrip1.Items[0].Enabled = true;
this.contextMenuStrip1.Items[1].Enabled = false;
this.contextMenuStrip1.Items[3].Enabled = false;
this.contextMenuStrip1.Items[5].Enabled = false;
}
con.Close();
}
private void menu1_Click(object sender, EventArgs e)
{
if (lv.SelectedItems.Count != 0)
{
SqlConnection con = new SqlConnection(s);
con.Open();
SqlCommand cmd = new SqlCommand("update ztb set state=0 where tableid=" + lv.SelectedItems[0].SubItems[0].Text, con);
cmd.ExecuteNonQuery();
con.Close();
this.MainForm_Activated(sender, e);
}
else
{
MessageBox.Show("请选择桌台");
}
}
设置ANCHOR属性四个全选 让控件随着界面变化而变化
cmd3.ExecuteScalar() 返回查询的结果集的第一行第一列
设置界面的KEYPRIVIEW属性为TRUE 使界面接受到按键事件
private void Formdl_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13) //如果按下回车键
button1_Click(sender, e);
if (e.KeyChar == 27) //按下ESC键
button2_Click(sender, e);
}
- 餐饮管理系统大作业SQL/C#
- C#开发的餐饮管理系统总结
- vb.net+sql 餐饮管理系统
- 金石餐饮管理系统 官网
- 美食管家餐饮管理系统
- java版餐饮管理系统
- 餐饮管理系统思想总结
- 餐饮管理系统 VC MFC
- c++大作业--学籍管理系统--
- 学生图书管理系统大作业
- C#大作业——简易银行管理系统 过程积累
- 餐饮大数据-系统架构模块设计
- 星火餐饮管理系统 v1.0 官网
- 一帆风顺餐饮管理系统 v3.01 官网
- 宏图酒店餐饮管理系统 怎么用
- 教之初餐饮管理系统 绿色
- 小金宇酒店客房餐饮管理系统 下载
- 天韵餐饮管理系统/软件
- java 数据类型所占字节数,int char
- DASH Adaptive Streaming for HTML 5 Video
- 上传图片到图片服务器,base64转图片
- SQL SERVER 数据库-增-删-改-查
- hive 元数据 mysql-1
- 餐饮管理系统大作业SQL/C#
- 有用的Matlab、C、C++、Python和LaTeX代码以及数据集
- Swift如何取得View所属的ViewController
- Linux 命令小结
- Python 读取GIST Data Set(二)
- CodeForces 366A Dima and Guards (暑期小练习)
- 选数[CQOI2015][bzoj3930]
- hive 元数据 mysql-2
- 第十六周实践项目之阅读程序————2