if (txtpnum.Text == \) {
MessageBox.Show(\数量不能为空\); return; } else {
txtallprice.Text =
Convert.ToString(Convert.ToInt32(txtprice.Text) * Convert.ToInt32(txtpnum.Text)); } } }
private void txtpnum_TextChanged(object sender, EventArgs e) {
if (txtpnum.Text == \) {
MessageBox.Show(\数量不能为空\); return; } else {
if (Convert.ToInt32(txtpnum.Text) < 1) {
MessageBox.Show(\不能为小于的数字\); return; } else {
txtallprice.Text =
Convert.ToString(Convert.ToInt32(txtprice.Text) * Convert.ToInt32(txtpnum.Text)); } } }
private void GetData()
26
{
SqlConnection conn = BaseClass.DBConn.CyCon(); SqlDataAdapter sda = new SqlDataAdapter(\
foodname,foodsum,foodallprice,waitername,beizhu,zhuotai,datatime ,ID from tb_GuestFood where zhuotai='\ + RName + \, conn); DataSet ds = new DataSet(); sda.Fill(ds);
dgvFoods.DataSource = ds.Tables[0]; }
private void txtpnum_KeyPress(object sender, KeyPressEventArgs e) {
if ((e.KeyChar != 8 && !char.IsDigit(e.KeyChar)) && e.KeyChar != 13)
{
MessageBox.Show(\请输入数字\); e.Handled = true; } }
private void btnDelete_Click(object sender, EventArgs e) {
if (dgvFoods.SelectedRows.Count > 0) {
//string names = dgvFoods.SelectedCells[0].Value.ToString(); int intID =
Convert.ToInt32(dgvFoods.CurrentRow.Cells[7].Value);
SqlConnection conn = BaseClass.DBConn.CyCon(); conn.Open();
//SqlCommand cmd = new SqlCommand(\tb_GuestFood where foodname='\conn);
SqlCommand cmd = new SqlCommand(\tb_GuestFood where ID = '\ + intID + \, conn); cmd.ExecuteNonQuery();
27
conn.Close(); GetData(); } }
private void btnSave_Click(object sender, EventArgs e) {
if (txtName.Text == \ || txtNum.Text == \|| txtprice.Text == \) {
MessageBox.Show(\请将选择菜系\); return; } else {
if (txtpnum.Text == \) {
MessageBox.Show(\数量不能为空\); return; } else {
if (Convert.ToInt32(txtpnum.Text) <= 0) {
MessageBox.Show(\请输入消费数量\); return; } else {
SqlConnection conn = BaseClass.DBConn.CyCon(); conn.Open();
SqlCommand cmd = new SqlCommand(\tb_GuestFood(foodnum,foodname,foodsum,foodallprice,waitername,beizhu,zhuotai,datatime) values('\ + txtNum.Text.Trim() + \ + txtName.Text.Trim() + \ + txtpnum.Text.Trim() + \ + Convert.ToDecimal(txtallprice.Text.Trim()) + \ + cbWaiter.SelectedItem.ToString() + \ + txtbz.Text.Trim() + \ + RName + \ +
28
DateTime.Now.ToString() + \, conn);
cmd.ExecuteNonQuery(); conn.Close(); GetData(); } } } }
private void btnExit_Click(object sender, EventArgs e) {
this.Close(); }
private void groupBox2_Enter(object sender, EventArgs e) {
}
} }
运行结果
29
第五部分 结束语
经过这次开发基C#的餐饮管理系统系统的设计与实现的设计,使我对C#有较深的认识及体会。在本开发系统时,由于是本人初次接触有关C#领域;在知识、经验方面都存在着太多的不足。另外,在开发的整个过程中,时间也较仓促。因此,该系统必然会存在很多不足。因为对整个学校的管理模式不够了解及对整个系统的流程不够熟悉,在需求分析阶段用户的需求未能做到完全满足,如系统还没做到请假信息的管理,不能从考核信息中得出考核工资等等。在系统功能上,还有部分问题是我还没有考虑到的,所以本系统还有继续开发一定空
30