private void Txt_PassWords_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { if (string.IsNullOrEmpty(this.Txt_PassWords.Text)) { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "密码不能为空!"; mb.ShowDialog(); } else { if (!string.IsNullOrEmpty(this.Txt_PassWords.Text) && this.Txt_PassWords.Text == PassValue.Code) { this.Close(); } else { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "密码错误!"; mb.ShowDialog(); } } } }
/// <summary> /// 单独开台操作 /// </summary> private void BtnOpenTables_Click(object sender, EventArgs e) { PassValue.count_select_idle = 0; PassValue.selectedtableid.Clear(); if (CurrentChooseDesk.Count > 0) { foreach (Control ct in this.panelDesk.Controls) { if (ct is DeskControl.DeskControl) { DeskControl.DeskControl dc = (DeskControl.DeskControl)ct; if (CurrentChooseDesk.Keys.Contains(dc.lbTableID.Text) && dc.lbStatus.Text == "idle") { PassValue.count_select_idle = CurrentChooseDesk.Count; PassValue.selectedtableid.Add(dc.lbTableID.Text); } } } } if (PassValue.count_select_idle > 0) { if (string.IsNullOrEmpty(PassValue.consumptionid)) { PassValue.desk = PassValue.selectedtableid.ToArray();//将集合转换为string数组 OpenTables ot = new OpenTables(); ot.Owner = this; ot.ShowDialog(); } else { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请选择空桌!"; mb.Show(); } } else { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请选择空桌!"; mb.Show(); } //选中默认 ChooseCurrent(); }
//确认提交反结算 private void Btn_Enter_Click(object sender, EventArgs e) { HttpWebResponse response = null; if (this.TxtNote.Text != "") { Consumption cp = new Consumption(); List <Log> log = new List <Log>(); Log logs = new Log(); logs.note = this.TxtNote.Text; logs.operation = "RECHECKOUTING";//RECHECKOUTING log.Add(logs); cp.logs = log.ToArray(); cp.people = p_peopleCount; List <Payment> lps = new List <Payment>(); cp.payments = lps.ToArray(); try { System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection(); headers.Add("Authorization", PassValue.token); response = Patch.PatchHttp(headers, "consumptions/" + p_ConsumptionsId, cp); PassValue.consumptionid = ""; Messagebox mb = new Messagebox(); PassValue.MessageInfor = "反结算成功!"; mb.ShowDialog(); this.Close(); } finally { if (response != null) { response.Close(); } } } else { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "不能为空!"; mb.ShowDialog(); } }
/// <summary> /// 组合开台操作 /// </summary> private void toolStripMenuItem1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(PassValue.consumptionid)) { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请选择空桌!"; mb.Show(); return; } LastIsidle = false; PassValue.selectedtableid.Clear(); PassValue.count_select_idle = 0; foreach (KeyValuePair <string, string> item in CurrentChooseDesk) { PassValue.selectedtableid.Add(item.Key); } PassValue.count_select_idle = CurrentChooseDesk.Count; if (PassValue.count_select_idle > 0) { PassValue.desk = PassValue.selectedtableid.ToArray();//将集合转换为string数组 OpenTables ot = new OpenTables(); ot.Owner = this; if (ot.ShowDialog() == DialogResult.Cancel) { LastIsidle = true; } } else { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请先选择桌子!"; mb.Show(); } //选中默认 ChooseCurrent(); }
//确认提交反结算 private void Btn_Enter_Click(object sender, EventArgs e) { HttpWebResponse response = null; if (this.TxtNote.Text != "") { Consumption cp = new Consumption(); List<Log> log = new List<Log>(); Log logs = new Log(); logs.note = this.TxtNote.Text; logs.operation = "RECHECKOUTING";//RECHECKOUTING log.Add(logs); cp.logs = log.ToArray(); cp.people = p_peopleCount; List<Payment> lps= new List<Payment>(); cp.payments = lps.ToArray(); try { System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection(); headers.Add("Authorization", PassValue.token); response = Patch.PatchHttp(headers, "consumptions/" + p_ConsumptionsId, cp); PassValue.consumptionid = ""; Messagebox mb = new Messagebox(); PassValue.MessageInfor = "反结算成功!"; mb.ShowDialog(); this.Close(); } finally { if (response != null) { response.Close(); } } } else { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "不能为空!"; mb.ShowDialog(); } }
/// <summary> /// 选择原因 /// </summary> private void panelChoose_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.TxtDiscount.Text)) { Member mb = new Member(); mb = (Member)this.Owner; this.Visible = false; PaymentReasons pr = new PaymentReasons(); pr.Owner = this; this.Visible = false; pr.TopLevel = false; mb.panelChildren.Controls.Add(pr); pr.Show(); } else { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "其他支付金额不能为空!"; mb.ShowDialog(); } }
public void btnorders() { if (TitleId == 1)//当前为开桌界面 { if (!string.IsNullOrEmpty(PassValue.consumptionid)) { TitleId = 2; SetUp(); this.BtnOrders.Image = Properties.Resources.点菜2;//选中点菜 frmOrder frmorder = new frmOrder(PassValue.consumptionid); frmorder.Owner = this; frmorder.TopLevel = false; frmorder.FormBorderStyle = FormBorderStyle.None; frmorder.Dock = DockStyle.Fill; this.panelMain.Controls.Clear(); this.panelMain.Controls.Add(frmorder); frmorder.Show(); PassValue.consumptionid = ""; } else { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请先选择已开台的桌子!"; mb.Show(); } } else { if (TitleId != 2) { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "您还未选桌,不能点菜!"; mb.Show(); } } }
//消台操作 private void Btn_Enter_Click(object sender, EventArgs e) { Desk d; d = (Desk)this.Owner; bool choose = false; ArrayList al = new ArrayList(); foreach (Control ctl in this.panelTables.Controls) { if (ctl is DeskControl.DeskControl) { DeskControl.DeskControl dcdc = (DeskControl.DeskControl)ctl; if (dcdc.picCheck.Visible) { choose = true; al.Add(dcdc.lbTableID.Text); } } } if (!choose) { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "还未勾选桌子!"; mb.ShowDialog(); return; } foreach (string item in al) { d.CurrentChooseDesk.Remove(item); } Consumption cp = new Consumption(); cp.id = this.Txt_Master.Text; int count = RestTableIDList.Count(); cp.tables = new Table[count]; for (int i = 0; i < count; i++) { cp.tables[i] = new Table(); cp.tables[i].id = RestTableIDList[i]; } cp.people = PeopleList[0]; HttpResult httpResult; if (cp.tables.Count() == 0) { httpResult = httpReq.HttpDelete(string.Format("consumptions/{0}", PassValue.consumptionid)); } else { httpResult = httpReq.HttpPatch(string.Format("consumptions/{0}", this.Txt_Master.Text), cp); } if ((int)httpResult.StatusCode == 409) { MessageBox.Show("选择的桌子已被操作,将为您刷新!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); AddTable(); return; } else if ((int)httpResult.StatusCode == 401) { LoginBusiness lg = new LoginBusiness(); lg.LoginAgain(); return; } else if ((int)httpResult.StatusCode == 0) { MessageBox.Show(string.Format("{0}{1}", httpResult.StatusDescription, httpResult.OtherDescription), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } d.Refresh_Method(); this.Close(); PassValue.count_select_idle = 0;//被选中的桌子数量 PassValue.count_select_ordering = cp.tables.Count(); PassValue.selectedtableid.Clear(); d.lbInfor.Text = d.lbInfor.Text.Split('[')[0] + "[空桌]";//餐台名称 //人数 d.lbPeople.Text = "0人"; }
/// <summary> /// 打折菜单的展开 /// </summary> private void panelChoose_Click(object sender, EventArgs e) { if (this.TxtDiscount.Text != "") { Member mb = new Member(); mb = (Member)this.Owner; PartOrderChoose poc = new PartOrderChoose(partConsumptionid); Consumption personsConsumption = httpReq.HttpGet <Consumption>(string.Format("consumptions/{0}", partConsumptionid)); //获取折扣的菜 //if (personsConsumption != null) //{ // Discount d = personsConsumption.discounts.Where(r => r.type == "partial").FirstOrDefault(); // if (d != null) // { // foreach (DiscountItem item in d.items) // { // } // } //} ArrayList haveAdd = new ArrayList(); for (int i = 0; i < personsConsumption.details.Count(); i++) { if (personsConsumption.details[i].discountable == true) { if (!haveAdd.Contains(personsConsumption.details[i].item.id)) { ListViewItem item = new ListViewItem(); item.Text = ""; item.SubItems.Add(personsConsumption.details[i].item.name); item.Tag = personsConsumption.details[i].item.id; if (PassValue.listItemID.Count == 0) { item.Checked = true; } else { if (PassValue.listItemID.Contains(personsConsumption.details[i].item.id)) { item.Checked = true; } else { item.Checked = false; } } haveAdd.Add(personsConsumption.details[i].item.id); poc.lv.Items.Add(item); } } } poc.Owner = this; this.Visible = false; poc.TopLevel = false; mb.panelChildren.Controls.Add(poc); poc.Show(); } else if (this.TxtDiscount.Text == "") { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请先输入折扣率!"; mb.ShowDialog(); } }
/// <summary> /// 确认按钮 /// </summary> private void Btn_Enter_Click(object sender, EventArgs e) { if (MessageBox.Show("确认结账吗?", "订单操作", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var personsConsumption = httpReq.HttpGet <Consumption>(string.Format("consumptions/{0}", PassValue.consumptionid)); //实收金额 string price_fixed = this.lbReceiveActual.Text; //应收金额 string total = this.lbTotal.Text; PassValue.Infor_payment.paid = PassValue.Infor_payment.closed = true; PassValue.Infor_payment.payments = PassValue.payments.ToArray(); PassValue.Infor_payment.discounts = personsConsumption.discounts; if (double.Parse(total) - double.Parse(price_fixed) <= 0.00) { //判断有没有支付信息 if (PassValue.payments.Count() == 0) { MessageBox.Show("请输入支付信息,您不能结账,如支付金额为0,请选择其他?", "订单操作", MessageBoxButtons.OK, MessageBoxIcon.Question); return; } else { //判断支付信息有没有会员卡信息 Payment payment = PassValue.payments.Where(payments => payments.method.Equals("member")).FirstOrDefault(); if (payment != null) { //弹出密码输入框 InputPassWord ip = new InputPassWord(); if (ip.ShowDialog() == DialogResult.Cancel) { return; } } } HttpResult httpResult = httpReq.HttpPatch(string.Format("consumptions/{0}", PassValue.consumptionid), PassValue.Infor_payment); if ((int)httpResult.StatusCode == 410) { MessageBox.Show("请检查打印机是否连接!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if ((int)httpResult.StatusCode == 401) { LoginBusiness lg = new LoginBusiness(); lg.LoginAgain(); return; } else if ((int)httpResult.StatusCode == 0) { MessageBox.Show(string.Format("{0}{1}", httpResult.StatusDescription, httpResult.OtherDescription), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if ((int)httpResult.StatusCode == 403) { MessageBox.Show("操作被禁止!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if ((int)httpResult.StatusCode == 500) { MessageBox.Show("操作错误(500)!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if ((int)httpResult.StatusCode == 400) { MessageBox.Show("请求错误(400)!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } PassValue.Infor_payment = new PatchOrders(); PassValue.discounts.Clear(); PassValue.payments.Clear();//清空 Messagebox mb = new Messagebox(); PassValue.MessageInfor = "结账完成"; mb.ShowDialog(); PassValue.consumptionid = ""; PassValue.MemberCardPwd = ""; PassValue.listItemID.Clear(); PassValue.listItemIDBefore.Clear(); PassValue.Percent = 0; Desk d = this.Owner as Desk; if (d == null) { if (m_ILoadData != null) { m_ILoadData.LoadData(); } } else { d.CurrentChooseDesk.Clear(); d.Refresh_Method(); d.CurrentChooseDesk = new Dictionary <string, string>(); } this.Close(); } else { PassValue.MessageInfor = "应收金额:" + this.lbTotal.Text + "实际结账的金额是:" + this.lbReceiveActual.Text + ",您不能结账!"; MessageBox.Show(PassValue.MessageInfor); } } }
/// <summary> /// 登录事件 /// </summary> private void picLogin_Click(object sender, EventArgs e) { if (this.TxtUser.Text == "请输入用户名" || this.TxtKey.Text == "请输入密码" || this.TxtUser.Text == "" || this.TxtKey.Text == "")//判断是否为空 { PassValue.MessageInfor = "用户名和密码不能为空"; Messagebox mb = new Messagebox(); mb.ShowDialog(); this.TxtKey.Text = "请输入密码"; this.TxtUser.Text = ""; this.TxtUser.Focus(); } else { PassValue.username = this.TxtUser.Text;//用户名 PassValue.password = this.TxtKey.Text;//密码 string passvalue = PassValue.username + ":" + PassValue.password; WebHeaderCollection headers = new WebHeaderCollection(); headers.Add("Authorization", "Basic " + System.Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(passvalue))); headers.Add("Authed", "true"); LoginID li = null; HttpResult httpResult = httpReq.HttpPost("auth/tokens", null, headers); if ((int)httpResult.StatusCode == 0) { MessageBox.Show(string.Format("{0}{1}", httpResult.StatusDescription, httpResult.OtherDescription), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } //else if ((int)httpResult.StatusCode == 403) //{ // if (MessageBox.Show("用户已在其他地方登陆 是否强制登陆?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) // { // headers.Add("Authed", "true"); // httpResult = httpReq.HttpPost("auth/tokens", null, headers); // } // else // { // return; // } //} if ((int)httpResult.StatusCode >= 200 && (int)httpResult.StatusCode < 300) { li = httpReq.ScriptDeserialize<LoginID>(httpResult.Html); PassValue.token = "Token " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(li.id));//ID加密 PassValue.tokenid = li.id; PassValue.Code = li.principal.code; if (needRemPassword) { Global.GetConfig().SetConfigString("system", "LoginUserName", this.TxtUser.Text.Trim()); Global.GetConfig().SetConfigString("system", "LoginUserPSW", this.TxtKey.Text.Trim()); } //获取楼层信息 Layout floorLayout = httpReq.HttpGet<Layout>("layout"); if (floorLayout != null) { foreach (Floor floor in floorLayout.floors) { PassValue.tablesstatuslist.Add(floor.number); } PassValue.tablesstatuslist.Sort(); } //获取桌子信息 PassValue.Tables = httpReq.HttpGet<List<Table>>("tables"); //获取交接班需要的信息 Shift shift = new Shift(); shift.cashier = new Employee(); if (li != null) { shift.cashier.id = li.principal.id; } httpResult = httpReq.HttpPost("shifts", shift); if ((int)httpResult.StatusCode >= 200 && (int)httpResult.StatusCode < 300) { shift = httpReq.ScriptDeserialize<Shift>(httpResult.Html); PassValue.shiftId = shift.id; needHandOver = shift.isWarn; } else if ((int)httpResult.StatusCode == 0) { MessageBox.Show(string.Format("{0}{1}", httpResult.StatusDescription, httpResult.OtherDescription), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } Main frmMain = new Main(this); frmMain.Show(); } else { MessageBox.Show("请输入正确的工号和密码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.TxtKey.Text = ""; this.TxtUser.Text = ""; this.TxtUser.Focus(); } } }
public void ShowView(string p_Name) { if (m_CurrentView !=null && (m_CurrentView.GetName() == p_Name)) //点击的是当前的,不做处理 { return; } if (m_RegisteredView != null) { frmMessageBox frmMessageBox = new frmMessageBox(System.Windows.MessageBoxButton.OK, "请先点击右下方的确定或者取消按钮,才能进行其他操作。"); frmMessageBox.ShowDialog(); return; } bool isneedactive = false; IView view= FindView(p_Name); switch (p_Name) { case "开桌": { if (view == null) { view = new Desk(); m_ViewList.Add(view); } else { isneedactive = true; } } break; case "点菜": { if (m_CurrentView.GetName() == "开桌") { if (string.IsNullOrEmpty(PassValue.consumptionid)) { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请先选择已开台的桌子!"; mb.Show(); } else { view = new frmOrder(PassValue.consumptionid); isneedactive = true; } } } break; case "收银": { view = new frmCashier(PassValue.consumptionid); isneedactive = true; } break; case "预定": { view = new frmReserveDishes(); } break; case "会员": { if (view == null) { view = new MemberSystem(); } } break; case "交接班": { view = new Transfer(); } break; case "历史查询": { view = new frmQuery(PassValue.consumptionid); isneedactive = true; } break; case "菜品": { if (view == null) { view = new frmWebDishes(); m_ViewList.Add(view); } } break; case "库管": { if (view == null) { view = new frmWebWarehouse(); m_ViewList.Add(view); } } break; case "设置": { History hs = new History(); hs.ShowDialog(); } break; case "报表": { if (view == null) { view = new frmWebReport(); m_ViewList.Add(view); } } break; case "TT100": { if (view == null) { view = new frmWebTT100(); m_ViewList.Add(view); } } break; case "锁屏": { LockWindows lw = new LockWindows(); lw.ShowDialog(); } break; } if (view == null) //前面没有生成view { } else { //先关闭之前的view if (m_CurrentView != null && FindView(m_CurrentView.GetName()) == null) { Form frm = m_CurrentView as Form; frm.Close(); } //显示现在的view Form form = view as Form; form.Owner = this; form.TopLevel = false; form.Dock = DockStyle.Fill; this.panelMain.Controls.Clear(); this.panelMain.Controls.Add(form); form.Show(); if (isneedactive) { view.Active(); } m_CurrentView = view; //设置按钮状态 SetButtonActived(p_Name); } }
/// <summary> /// 组合开台操作 /// </summary> private void toolStripMenuItem1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(PassValue.consumptionid)) { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请选择空桌!"; mb.Show(); return; } LastIsidle = false; PassValue.selectedtableid.Clear(); PassValue.count_select_idle = 0; foreach (KeyValuePair<string, string> item in CurrentChooseDesk) { PassValue.selectedtableid.Add(item.Key); } PassValue.count_select_idle = CurrentChooseDesk.Count; if (PassValue.count_select_idle > 0) { PassValue.desk = PassValue.selectedtableid.ToArray();//将集合转换为string数组 OpenTables ot = new OpenTables(); ot.Owner = this; if (ot.ShowDialog() == DialogResult.Cancel) { LastIsidle = true; } } else { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请先选择桌子!"; mb.Show(); } //选中默认 ChooseCurrent(); }
public void ShowView(string p_Name) { if (m_CurrentView != null && (m_CurrentView.GetName() == p_Name)) //点击的是当前的,不做处理 { return; } if (m_RegisteredView != null) { frmMessageBox frmMessageBox = new frmMessageBox(System.Windows.MessageBoxButton.OK, "请先点击右下方的确定或者取消按钮,才能进行其他操作。"); frmMessageBox.ShowDialog(); return; } bool isneedactive = false; IView view = FindView(p_Name); switch (p_Name) { case "开桌": { if (view == null) { view = new Desk(); m_ViewList.Add(view); } else { isneedactive = true; } } break; case "点菜": { if (m_CurrentView.GetName() == "开桌") { if (string.IsNullOrEmpty(PassValue.consumptionid)) { Messagebox mb = new Messagebox(); PassValue.MessageInfor = "请先选择已开台的桌子!"; mb.Show(); } else { view = new frmOrder(PassValue.consumptionid); isneedactive = true; } } } break; case "收银": { view = new frmCashier(PassValue.consumptionid); isneedactive = true; } break; case "预定": { view = new frmReserveDishes(); } break; case "会员": { if (view == null) { view = new MemberSystem(); } } break; case "交接班": { view = new Transfer(); } break; case "历史查询": { view = new frmQuery(PassValue.consumptionid); isneedactive = true; } break; case "菜品": { if (view == null) { view = new frmWebDishes(); m_ViewList.Add(view); } } break; case "库管": { if (view == null) { view = new frmWebWarehouse(); m_ViewList.Add(view); } } break; case "设置": { History hs = new History(); hs.ShowDialog(); } break; case "报表": { if (view == null) { view = new frmWebReport(); m_ViewList.Add(view); } } break; case "TT100": { if (view == null) { view = new frmWebTT100(); m_ViewList.Add(view); } } break; case "锁屏": { LockWindows lw = new LockWindows(); lw.ShowDialog(); } break; } if (view == null) //前面没有生成view { } else { //先关闭之前的view if (m_CurrentView != null && FindView(m_CurrentView.GetName()) == null) { Form frm = m_CurrentView as Form; frm.Close(); } //显示现在的view Form form = view as Form; form.Owner = this; form.TopLevel = false; form.Dock = DockStyle.Fill; this.panelMain.Controls.Clear(); this.panelMain.Controls.Add(form); form.Show(); if (isneedactive) { view.Active(); } m_CurrentView = view; //设置按钮状态 SetButtonActived(p_Name); } }
/// <summary> /// 确认按钮 /// </summary> private void Btn_Enter_Click(object sender, EventArgs e) { if (MessageBox.Show("确认结账吗?", "订单操作", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var personsConsumption = httpReq.HttpGet<Consumption>(string.Format("consumptions/{0}", PassValue.consumptionid)); //实收金额 string price_fixed = this.lbReceiveActual.Text; //应收金额 string total = this.lbTotal.Text; PassValue.Infor_payment.paid = PassValue.Infor_payment.closed = true; PassValue.Infor_payment.payments = PassValue.payments.ToArray(); PassValue.Infor_payment.discounts = personsConsumption.discounts; if (double.Parse(total) - double.Parse(price_fixed) <= 0.00) { //判断有没有支付信息 if (PassValue.payments.Count() == 0) { MessageBox.Show("请输入支付信息,您不能结账,如支付金额为0,请选择其他?", "订单操作", MessageBoxButtons.OK, MessageBoxIcon.Question); return; } else { //判断支付信息有没有会员卡信息 Payment payment = PassValue.payments.Where(payments => payments.method.Equals("member")).FirstOrDefault(); if (payment != null) { //弹出密码输入框 InputPassWord ip = new InputPassWord(); if (ip.ShowDialog() == DialogResult.Cancel) { return; } } } HttpResult httpResult = httpReq.HttpPatch(string.Format("consumptions/{0}", PassValue.consumptionid), PassValue.Infor_payment); if ((int)httpResult.StatusCode == 410) { MessageBox.Show("请检查打印机是否连接!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if ((int)httpResult.StatusCode == 401) { LoginBusiness lg = new LoginBusiness(); lg.LoginAgain(); return; } else if ((int)httpResult.StatusCode == 0) { MessageBox.Show(string.Format("{0}{1}", httpResult.StatusDescription, httpResult.OtherDescription), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if ((int)httpResult.StatusCode == 403) { MessageBox.Show("操作被禁止!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if ((int)httpResult.StatusCode == 500) { MessageBox.Show("操作错误(500)!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if ((int)httpResult.StatusCode == 400) { MessageBox.Show("请求错误(400)!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } PassValue.Infor_payment = new PatchOrders(); PassValue.discounts.Clear(); PassValue.payments.Clear();//清空 Messagebox mb = new Messagebox(); PassValue.MessageInfor = "结账完成"; mb.ShowDialog(); PassValue.consumptionid = ""; PassValue.MemberCardPwd = ""; PassValue.listItemID.Clear(); PassValue.listItemIDBefore.Clear(); PassValue.Percent = 0; Desk d = this.Owner as Desk; if (d == null) { if (m_ILoadData != null) { m_ILoadData.LoadData(); } } else { d.CurrentChooseDesk.Clear(); d.Refresh_Method(); d.CurrentChooseDesk = new Dictionary<string, string>(); } this.Close(); } else { PassValue.MessageInfor = "应收金额:" + this.lbTotal.Text + "实际结账的金额是:" + this.lbReceiveActual.Text + ",您不能结账!"; MessageBox.Show(PassValue.MessageInfor); } } }
/// <summary> /// 登录事件 /// </summary> private void picLogin_Click(object sender, EventArgs e) { if (this.TxtUser.Text == "请输入用户名" || this.TxtKey.Text == "请输入密码" || this.TxtUser.Text == "" || this.TxtKey.Text == "")//判断是否为空 { PassValue.MessageInfor = "用户名和密码不能为空"; Messagebox mb = new Messagebox(); mb.ShowDialog(); this.TxtKey.Text = "请输入密码"; this.TxtUser.Text = ""; this.TxtUser.Focus(); } else { PassValue.username = this.TxtUser.Text; //用户名 PassValue.password = this.TxtKey.Text; //密码 string passvalue = PassValue.username + ":" + PassValue.password; WebHeaderCollection headers = new WebHeaderCollection(); headers.Add("Authorization", "Basic " + System.Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(passvalue))); headers.Add("Authed", "true"); LoginID li = null; HttpResult httpResult = httpReq.HttpPost("auth/tokens", null, headers); if ((int)httpResult.StatusCode == 0) { MessageBox.Show(string.Format("{0}{1}", httpResult.StatusDescription, httpResult.OtherDescription), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } //else if ((int)httpResult.StatusCode == 403) //{ // if (MessageBox.Show("用户已在其他地方登陆 是否强制登陆?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) // { // headers.Add("Authed", "true"); // httpResult = httpReq.HttpPost("auth/tokens", null, headers); // } // else // { // return; // } //} if ((int)httpResult.StatusCode >= 200 && (int)httpResult.StatusCode < 300) { li = httpReq.ScriptDeserialize <LoginID>(httpResult.Html); PassValue.token = "Token " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(li.id));//ID加密 PassValue.tokenid = li.id; PassValue.Code = li.principal.code; if (needRemPassword) { Global.GetConfig().SetConfigString("system", "LoginUserName", this.TxtUser.Text.Trim()); Global.GetConfig().SetConfigString("system", "LoginUserPSW", this.TxtKey.Text.Trim()); } //获取楼层信息 Layout floorLayout = httpReq.HttpGet <Layout>("layout"); if (floorLayout != null) { foreach (Floor floor in floorLayout.floors) { PassValue.tablesstatuslist.Add(floor.number); } PassValue.tablesstatuslist.Sort(); } //获取桌子信息 PassValue.Tables = httpReq.HttpGet <List <Table> >("tables"); //获取交接班需要的信息 Shift shift = new Shift(); shift.cashier = new Employee(); if (li != null) { shift.cashier.id = li.principal.id; } httpResult = httpReq.HttpPost("shifts", shift); if ((int)httpResult.StatusCode >= 200 && (int)httpResult.StatusCode < 300) { shift = httpReq.ScriptDeserialize <Shift>(httpResult.Html); PassValue.shiftId = shift.id; needHandOver = shift.isWarn; } else if ((int)httpResult.StatusCode == 0) { MessageBox.Show(string.Format("{0}{1}", httpResult.StatusDescription, httpResult.OtherDescription), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } Main frmMain = new Main(this); frmMain.Show(); } else { MessageBox.Show("请输入正确的工号和密码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.TxtKey.Text = ""; this.TxtUser.Text = ""; this.TxtUser.Focus(); } } }