//表单验证 public bool CheckInput() { string[] a = new string[3]; a = this.txtFoodPrice.Text.Split('.'); double price; if (this.txtFoodName.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入菜名"); } else if (this.txtFoodDanWei.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入单位"); } else if (this.txtFoodPrice.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入单价"); } else if (!double.TryParse(this.txtFoodPrice.Text.Trim(), out price) || (a.Length > 1 && a[1].Length > 1)) { FMHelper.OpenOk("请输入正确的价格"); } else { return(true); } return(false); }
//修改信息 public void ChangeInfo() { try { dbh.DBOpen(); string sql = "select id from food where danwei='" + this.txtFoodDanWei.Text.Trim() + "' and name='" + this.txtFoodName.Text.Trim() + "' and moeny='" + this.txtFoodPrice.Text.Trim() + "'"; SqlCommand comm = new SqlCommand(sql, dbh.Conn); if (comm.ExecuteScalar() == null) { sql = "insert food select '" + this.txtFoodDanWei.Text.Trim() + "','" + this.txtFoodName.Text.Trim() + "','" + this.txtFoodPrice.Text.Trim() + "',0 update food set zhuangtai=1 where id=" + foodId; comm = new SqlCommand(sql, dbh.Conn); comm.ExecuteNonQuery(); } else { string id = comm.ExecuteScalar().ToString(); sql = "update food set zhuangtai=1 where id=" + foodId + " update food set zhuangtai=0 where id=" + id; comm = new SqlCommand(sql, dbh.Conn); comm.ExecuteNonQuery(); } FMHelper.OpenOk("信息修改成功"); } catch (Exception ex) { text = ex.Message; ShowMessage(); } finally { dbh.DBClose(); } }
//管理员登陆 public void AdminLogin() { try { dbh.DBOpen(); string sql = "select count(*) from [user] where id='" + this.textId.Text.Trim() + "' and pwd='" + this.textPwd.Text.Trim() + "'"; SqlCommand comm = new SqlCommand(sql, dbh.Conn); if ((int)comm.ExecuteScalar() == 1) { FMHelper.OpenDeskMenu(); this.Hide(); } else { FMHelper.OpenOk("账号或密码错误"); } } catch (Exception ex) { text = ex.Message; ShowMessage(); } finally { dbh.DBClose(); } }
//检查手机号 public bool CheckPhone() { try { dbh.DBOpen(); string sql = "select count(*) from vipcard where phone='" + this.textPhone.Text.Trim() + "'"; SqlCommand comm = new SqlCommand(sql, dbh.Conn); if (Convert.ToInt32(comm.ExecuteScalar()) > 0) { FMHelper.OpenOk("该手机号已注册过会员"); return(false); } return(true); } catch (Exception ex) { text = ex.Message; ShowMessage(); return(false); } finally { dbh.DBClose(); } }
//营业验证 public bool CheckUse() { try { dbh.DBOpen(); string sql = "select count(*) from desk where zhuangtai=1"; SqlCommand comm = new SqlCommand(sql, dbh.Conn); if ((int)comm.ExecuteScalar() > 0) { FMHelper.OpenOk("有未处理账单,无法操作"); return(false); } else { return(true); } } catch (Exception ex) { text = ex.Message; ShowMessage(); return(false); } finally { dbh.DBClose(); } }
//一键清台 private void botAdd_Click(object sender, EventArgs e) { if (FMHelper.OpenYesNo("要清空所有桌台吗")) { EndInfo(); StartInfo(); FMHelper.OpenOk("已清理所有桌台"); } }
//取消订单按钮 private void button7_Click(object sender, EventArgs e) { if (FMHelper.OpenYesNo("要取消订单吗")) { DeZhnagDan(); FMHelper.OpenOk("取消订单成功"); FMHelper.OpenDeskMenu(); this.Close(); } }
//日期验证 public bool CheckDate() { if (this.time1.Value > this.time2.Value) { FMHelper.OpenOk("请选择正确的日期"); } else { return(true); } return(false); }
//结账验证 public bool JZCheck() { if (this.FoodList.Rows.Count == 0) { FMHelper.OpenOk("未点菜,无法进行结账操作"); } else { return(true); } return(false); }
//检查是否选择会员 public bool CheckVIPId() { if (this.textID.Text == string.Empty) { FMHelper.OpenOk("未选择任何会员"); } else { return(true); } return(false); }
//付款验证 public bool PayCheck() { if (zhaoLin < 0) { FMHelper.OpenOk("请输入正确的付款金额"); } else { return(true); } return(false); }
//表单验证 public bool CheckInput() { if (this.textName.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入姓名"); } else if (this.textSex.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入性别"); } else { return(true); } return(false); }
//表单验证 public bool CheckInput() { if (this.textId.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入用户名"); } else if (this.textPwd.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入密码"); } else { return(true); } return(false); }
//数量验证 public bool CheckNum() { int a; if (this.txtBuyNum.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入数量"); } else if (!int.TryParse(this.txtBuyNum.Text.Trim(), out a) || a < 1) { FMHelper.OpenOk("请输入正确的数量"); } else { return(true); } return(false); }
//添加菜品 public void AddFood() { try { dbh.DBOpen(); string sql = "select count(*) from food where name='" + this.txtFoodName.Text.Trim() + "' and zhuangtai=0"; SqlCommand comm = new SqlCommand(sql, dbh.Conn); if ((int)comm.ExecuteScalar() == 0) { sql = "select id from food where danwei='" + this.txtFoodDanWei.Text.Trim() + "' and name='" + this.txtFoodName.Text.Trim() + "' and moeny='" + this.txtFoodPrice.Text.Trim() + "'"; comm = new SqlCommand(sql, dbh.Conn); if (comm.ExecuteScalar() == null) { sql = "insert food select '" + this.txtFoodDanWei.Text.Trim() + "','" + this.txtFoodName.Text.Trim() + "','" + this.txtFoodPrice.Text.Trim() + "',0"; comm = new SqlCommand(sql, dbh.Conn); comm.ExecuteNonQuery(); } else { string id = comm.ExecuteScalar().ToString(); sql = "update food set zhuangtai=0 where id=" + id; comm = new SqlCommand(sql, dbh.Conn); comm.ExecuteNonQuery(); } FMHelper.OpenOk("菜品添加成功"); this.Close(); } else { FMHelper.OpenOk("该菜品已存在"); } } catch (Exception ex) { text = ex.Message; ShowMessage(); } finally { dbh.DBClose(); } }
//删除信息 public void DeInfo() { try { dbh.DBOpen(); string sql = "update food set zhuangtai=1 where id=" + this.foodId; SqlCommand comm = new SqlCommand(sql, dbh.Conn); comm.ExecuteNonQuery(); FMHelper.OpenOk("菜品删除成功"); } catch (Exception ex) { text = ex.Message; ShowMessage(); } finally { dbh.DBClose(); } }
//删除会员信息 public void DeVIPInfo() { try { dbh.DBOpen(); string sql = "update vipcard set zhuangtai=1 where phone='" + this.textID.Text + "'"; SqlCommand comm = new SqlCommand(sql, dbh.Conn); comm.ExecuteNonQuery(); FMHelper.OpenOk("注销成功"); } catch (Exception ex) { text = ex.Message; ShowMessage(); } finally { dbh.DBClose(); } }
//修改会员信息 public void ChangeVIPInfo() { try { dbh.DBOpen(); string sql = "update VIPCard set Name='" + this.textName.Text.Trim() + "',Sex='" + this.textSex.Text.Trim() + "',BeiZhu='" + this.textBeiZhu.Text.Trim() + "' where Phone='" + this.textID.Text + "'"; SqlCommand comm = new SqlCommand(sql, dbh.Conn); comm.ExecuteNonQuery(); FMHelper.OpenOk("修改成功"); } catch (Exception ex) { text = ex.Message; ShowMessage(); } finally { dbh.DBClose(); } }
//表单验证 public bool CheckInout() { long phone; if (this.textName.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入姓名"); } else if (this.textPhone.Text.Trim() == string.Empty) { FMHelper.OpenOk("请输入电话"); } else if (this.textPhone.Text.Trim().Length < 11 || !long.TryParse(this.textPhone.Text.Trim(), out phone)) { FMHelper.OpenOk("请输入正确的手机号"); } else { return(true); } return(false); }