/// <summary> /// 加载信息 /// </summary> public void AddInformation() { var personsConsumption = httpReq.HttpGet <Consumption>(string.Format("consumptions/{0}", PassValue.consumptionid)); int lccount = 0; if (personsConsumption != null) { this.lbSubtotal.Text = personsConsumption.subtotal; this.lbSaving.Text = personsConsumption.savings; this.lbTotal.Text = personsConsumption.total; PassValue.Price_All = this.lbSubtotal.Text; //总金额传递给全局变量 PassValue.Price_Now = (double.Parse(this.lbTotal.Text) - double.Parse(this.lbReceiveActual.Text)).ToString("0.00");; //应付价格传递给全局变量 for (int j = 0; j < personsConsumption.details.Count(); j++) { if (personsConsumption.details[j].discountable == true) { if (!PassValue.listItemIDBefore.Contains(personsConsumption.details[j].item.id)) { PassValue.listItemIDBefore.Add(personsConsumption.details[j].item.id); } } } if (personsConsumption.discounts != null) { for (int i = 0; i < personsConsumption.discounts.Count(); i++) { LineControl.LineControl lc = new LineControl.LineControl(); switch (personsConsumption.discounts[i].type) { case "whole": lc.lbInformation.Text = "整单打折:" + " " + personsConsumption.discounts[i].percent.ToString() + "%"; break; case "partial": //获取目前的打折菜品 PassValue.listItemID.Clear(); string percent = ""; if (personsConsumption.discounts[i].items != null) { foreach (DiscountItem di in personsConsumption.discounts[i].items) { percent = di.percent.ToString(); PassValue.Percent = int.Parse(percent); PassValue.listItemID.Add(di.id); } } lc.lbInformation.Text = "部分打折:" + " " + PassValue.listItemID.Count.ToString() + "份菜 折扣:" + percent + "%"; break; case "scheme": int intpercent = personsConsumption.discounts[i].scheme.percent; lc.lbInformation.Text = "方案打折:" + " " + intpercent.ToString() + "折"; break; case "quota": lc.lbInformation.Text = "定额打折:" + " " + personsConsumption.discounts[i].amount.ToString(); break; case "round": lc.lbInformation.Text = "抹零:" + " " + personsConsumption.discounts[i].amount.ToString(); break; case "free": lc.lbInformation.Text = "免单:" + " " + personsConsumption.discounts[i].amount.ToString(); break; } lc.picClose.Click += new EventHandler(addorderclose_Click);//去除事件 this.panelChildren.Controls.Add(lc); lc.Location = new System.Drawing.Point(0, lc.Height * lccount + this.panelInfor.Height + 20); lccount++; } } } if (PassValue.payments.Count != 0) { Price_Recive = 0;//初始化应收的价格 for (int c = 0; c < PassValue.payments.Count(); c++) { LineControl.LineControl lc = new LineControl.LineControl(); switch (PassValue.payments[c].method) { case "bankcard": lc.lbInformation.Text = "银联卡:" + " " + PassValue.payments[c].amount; break; case "sign": lc.lbInformation.Text = "签单:" + " " + PassValue.payments[c].amount; break; case "other": lc.lbInformation.Text = "其他:" + " " + PassValue.payments[c].amount; break; case "cash": lc.lbInformation.Text = "现金支付:" + " " + PassValue.payments[c].amount; break; case "member": lc.lbInformation.Text = "会员卡:" + " " + PassValue.payments[c].amount; break; } Price_Recive += double.Parse(PassValue.payments[c].amount); lc.Location = new System.Drawing.Point(0, lc.Height * lccount + this.panelInfor.Height + 20); lc.picClose.Click += new EventHandler(addorderclose_Click);//去除事件 this.panelChildren.Controls.Add(lc); lccount++; } } //加载完毕之后判断是否要屏蔽现金支付方式 if (double.Parse(lbTotal.Text) <= double.Parse(lbReceiveActual.Text)) { this.Btn_All.Enabled = false; this.Btn_Part.Enabled = false; this.Btn_Plan.Enabled = false; this.Btn_Fixed.Enabled = false; this.Btn_Maling.Enabled = false; this.Btn_Free.Enabled = false; this.Btn_MemberCard.Enabled = false; this.Btn_BankCard.Enabled = false; this.Btn_Sign.Enabled = false; this.Btn_Other.Enabled = false; this.Btn_Cash.Enabled = false; this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Maling.Image = Properties.Resources.抹零2; this.Btn_Free.Image = Properties.Resources.免单2; this.Btn_MemberCard.Image = Properties.Resources.会员卡2; this.Btn_BankCard.Image = Properties.Resources.银联卡2; this.Btn_Sign.Image = Properties.Resources.签单2; this.Btn_Other.Image = Properties.Resources.其他2; this.Btn_Cash.Image = Properties.Resources.现金支付2; if (PassValue.payments == null) //如果没有支付信息,开放其他按钮 { this.Btn_Other.Enabled = true; this.Btn_Other.Image = Properties.Resources.其他; } else if (PassValue.payments.Count() == 0) { this.Btn_Other.Enabled = true; this.Btn_Other.Image = Properties.Resources.其他; } } else { //初始化 this.Btn_All.Enabled = true; this.Btn_Part.Enabled = true; this.Btn_Plan.Enabled = true; this.Btn_Fixed.Enabled = true; this.Btn_Maling.Enabled = true; this.Btn_Free.Enabled = true; this.Btn_MemberCard.Enabled = true; this.Btn_BankCard.Enabled = true; this.Btn_Sign.Enabled = true; this.Btn_Other.Enabled = true; this.Btn_Cash.Enabled = true; this.Btn_All.Image = Properties.Resources.整单打折; this.Btn_Part.Image = Properties.Resources.部分打折; this.Btn_Plan.Image = Properties.Resources.方案打折; this.Btn_Fixed.Image = Properties.Resources.定额打折; this.Btn_Maling.Image = Properties.Resources.摸零; this.Btn_Free.Image = Properties.Resources.免单; this.Btn_MemberCard.Image = Properties.Resources.会员卡; this.Btn_BankCard.Image = Properties.Resources.银联卡; this.Btn_Sign.Image = Properties.Resources.签单; this.Btn_Other.Image = Properties.Resources.其他; this.Btn_Cash.Image = Properties.Resources.现金支付; this.Btn_Print.Image = Properties.Resources.打印对账单; this.Btn_Enter.Image = Properties.Resources.确定2; //要根据现有的打折和折扣信息进行按钮的控制 //①只要有现金的支付的话,打折信息就不能使用了 if (PassValue.payments.Count > 0) { this.Btn_All.Enabled = false; this.Btn_Part.Enabled = false; this.Btn_Plan.Enabled = false; this.Btn_Fixed.Enabled = false; this.Btn_Maling.Enabled = false; this.Btn_Free.Enabled = false; this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Maling.Image = Properties.Resources.抹零2; this.Btn_Free.Image = Properties.Resources.免单2; } //②根据折扣信息来处理 if (personsConsumption.discounts == null) { return; } if (personsConsumption.discounts.Count() > 0) { foreach (Discount item in personsConsumption.discounts) { switch (item.type) { case "whole": this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = this.Btn_Plan.Enabled = false; break; case "partial": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_All.Enabled = this.Btn_Fixed.Enabled = this.Btn_Plan.Enabled = false; break; case "scheme": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = this.Btn_All.Enabled = false; break; case "quota": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_All.Enabled = this.Btn_Part.Enabled = this.Btn_Plan.Enabled = false; break; case "round": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_All.Enabled = this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Fixed.Enabled = false; break; case "free": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_All.Enabled = this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Fixed.Enabled = false; break; } } } } }
public void addorderclose_Click(object sender, EventArgs e) { SetUp(); var personsConsumption = httpReq.HttpGet <Consumption>(string.Format("consumptions/{0}", PassValue.consumptionid)); PassValue.discounts.Clear(); PassValue.Infor_payment = new PatchOrders(); if (personsConsumption.discounts != null) { PassValue.discounts = personsConsumption.discounts.ToList(); } Discount discount = new Discount(); Payment payment = new Payment(); LineControl.LineControl lclc = ((PictureBox)sender).Parent as LineControl.LineControl; switch (lclc.lbInformation.Text.Split(':')[0].Trim()) { case "整单打折": discount = personsConsumption.discounts.Where(persons => persons.type.Equals("whole")).FirstOrDefault(); PassValue.discounts.Remove(discount); this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = true; break; case "部分打折": discount = personsConsumption.discounts.Where(persons => persons.type.Equals("partial")).FirstOrDefault(); PassValue.discounts.Remove(discount); this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = true; PassValue.listItemID.Clear(); PassValue.listItemIDBefore.Clear(); PassValue.Percent = 0; break; case "方案打折": discount = personsConsumption.discounts.Where(persons => persons.type.Equals("scheme")).FirstOrDefault(); PassValue.discounts.Remove(discount); this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = true; break; case "定额打折": discount = personsConsumption.discounts.Where(persons => persons.type.Equals("quota")).FirstOrDefault(); PassValue.discounts.Remove(discount); this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = true; break; case "抹零": discount = personsConsumption.discounts.Where(persons => persons.type.Equals("round")).FirstOrDefault(); PassValue.discounts.Remove(discount); this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = true; break; case "免单": discount = personsConsumption.discounts.Where(persons => persons.type.Equals("free")).FirstOrDefault(); PassValue.discounts.Remove(discount); this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = true; break; case "银联卡": payment = PassValue.payments.Where(payments => payments.method.Equals("bankcard")).FirstOrDefault(); PassValue.payments.Remove(payment); PassValue.Price_Now = (double.Parse(this.lbTotal.Text) + double.Parse(payment.amount)).ToString("0.00"); //应付价格传递给全局变量 Price_Recive = Price_Recive - double.Parse(payment.amount); this.lbReceiveActual.Text = Price_Recive.ToString(); break; case "现金支付": payment = PassValue.payments.Where(payments => payments.method.Equals("cash")).FirstOrDefault(); PassValue.payments.Remove(payment); PassValue.Price_Now = (double.Parse(this.lbTotal.Text) + double.Parse(payment.amount)).ToString("0.00"); //应付价格传递给全局变量 Price_Recive = Price_Recive - double.Parse(payment.amount); this.lbReceiveActual.Text = Price_Recive.ToString(); break; case "会员卡": payment = PassValue.payments.Where(payments => payments.method.Equals("member")).FirstOrDefault(); PassValue.payments.Remove(payment); PassValue.Price_Now = (double.Parse(this.lbTotal.Text) + double.Parse(payment.amount)).ToString("0.00"); //应付价格传递给全局变量 Price_Recive = Price_Recive - double.Parse(payment.amount); this.lbReceiveActual.Text = Price_Recive.ToString(); break; case "签单": payment = PassValue.payments.Where(payments => payments.method.Equals("sign")).FirstOrDefault(); PassValue.payments.Remove(payment); PassValue.Price_Now = (double.Parse(this.lbTotal.Text) + double.Parse(payment.amount)).ToString("0.00"); //应付价格传递给全局变量 Price_Recive = Price_Recive - double.Parse(payment.amount); this.lbReceiveActual.Text = Price_Recive.ToString(); break; case "其他": payment = PassValue.payments.Where(payments => payments.method.Equals("other")).FirstOrDefault(); PassValue.payments.Remove(payment); PassValue.Price_Now = (double.Parse(this.lbTotal.Text) + double.Parse(payment.amount)).ToString("0.00"); //应付价格传递给全局变量 Price_Recive = Price_Recive - double.Parse(payment.amount); this.lbReceiveActual.Text = Price_Recive.ToString(); break; } if (PassValue.discounts != null) { PassValue.Infor_payment.discounts = PassValue.discounts.ToArray(); HttpResult httpResult = httpReq.HttpPatch(string.Format("consumptions/{0}", PassValue.consumptionid), PassValue.Infor_payment); 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; } } this.panelChildren.Controls.Clear(); AddInformation(); }
/// <summary> /// 加载信息 /// </summary> public void AddInformation() { var personsConsumption = httpReq.HttpGet<Consumption>(string.Format("consumptions/{0}", PassValue.consumptionid)); int lccount = 0; if (personsConsumption != null) { this.lbSubtotal.Text = personsConsumption.subtotal; this.lbSaving.Text = personsConsumption.savings; this.lbTotal.Text = personsConsumption.total; PassValue.Price_All = this.lbSubtotal.Text;//总金额传递给全局变量 PassValue.Price_Now = (double.Parse(this.lbTotal.Text) - double.Parse(this.lbReceiveActual.Text)).ToString("0.00"); ;//应付价格传递给全局变量 for (int j = 0; j < personsConsumption.details.Count(); j++) { if (personsConsumption.details[j].discountable == true) { if (!PassValue.listItemIDBefore.Contains(personsConsumption.details[j].item.id)) { PassValue.listItemIDBefore.Add(personsConsumption.details[j].item.id); } } } if (personsConsumption.discounts != null) { for (int i = 0; i < personsConsumption.discounts.Count(); i++) { LineControl.LineControl lc = new LineControl.LineControl(); switch (personsConsumption.discounts[i].type) { case "whole": lc.lbInformation.Text = "整单打折:" + " " + personsConsumption.discounts[i].percent.ToString() + "%"; break; case "partial": //获取目前的打折菜品 PassValue.listItemID.Clear(); string percent=""; if (personsConsumption.discounts[i].items != null) { foreach (DiscountItem di in personsConsumption.discounts[i].items) { percent = di.percent.ToString(); PassValue.Percent = int.Parse(percent); PassValue.listItemID.Add(di.id); } } lc.lbInformation.Text = "部分打折:" + " " + PassValue.listItemID.Count.ToString() + "份菜 折扣:" + percent + "%"; break; case "scheme": int intpercent = personsConsumption.discounts[i].scheme.percent; lc.lbInformation.Text = "方案打折:" + " " + intpercent.ToString() + "折"; break; case "quota": lc.lbInformation.Text = "定额打折:" + " " + personsConsumption.discounts[i].amount.ToString(); break; case "round": lc.lbInformation.Text = "抹零:" + " " + personsConsumption.discounts[i].amount.ToString(); break; case "free": lc.lbInformation.Text = "免单:" + " " + personsConsumption.discounts[i].amount.ToString(); break; } lc.picClose.Click += new EventHandler(addorderclose_Click);//去除事件 this.panelChildren.Controls.Add(lc); lc.Location = new System.Drawing.Point(0, lc.Height * lccount + this.panelInfor.Height + 20); lccount++; } } } if (PassValue.payments.Count != 0) { Price_Recive = 0;//初始化应收的价格 for (int c = 0; c < PassValue.payments.Count(); c++) { LineControl.LineControl lc = new LineControl.LineControl(); switch (PassValue.payments[c].method) { case "bankcard": lc.lbInformation.Text = "银联卡:" + " " + PassValue.payments[c].amount; break; case "sign": lc.lbInformation.Text = "签单:" + " " + PassValue.payments[c].amount; break; case "other": lc.lbInformation.Text = "其他:" + " " + PassValue.payments[c].amount; break; case "cash": lc.lbInformation.Text = "现金支付:" + " " + PassValue.payments[c].amount; break; case "member": lc.lbInformation.Text = "会员卡:" + " " + PassValue.payments[c].amount; break; } Price_Recive += double.Parse(PassValue.payments[c].amount); lc.Location = new System.Drawing.Point(0, lc.Height * lccount + this.panelInfor.Height + 20); lc.picClose.Click += new EventHandler(addorderclose_Click);//去除事件 this.panelChildren.Controls.Add(lc); lccount++; } } //加载完毕之后判断是否要屏蔽现金支付方式 if (double.Parse(lbTotal.Text) <= double.Parse(lbReceiveActual.Text)) { this.Btn_All.Enabled = false; this.Btn_Part.Enabled = false; this.Btn_Plan.Enabled = false; this.Btn_Fixed.Enabled = false; this.Btn_Maling.Enabled = false; this.Btn_Free.Enabled = false; this.Btn_MemberCard.Enabled = false; this.Btn_BankCard.Enabled = false; this.Btn_Sign.Enabled = false; this.Btn_Other.Enabled = false; this.Btn_Cash.Enabled = false; this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Maling.Image = Properties.Resources.抹零2; this.Btn_Free.Image = Properties.Resources.免单2; this.Btn_MemberCard.Image = Properties.Resources.会员卡2; this.Btn_BankCard.Image = Properties.Resources.银联卡2; this.Btn_Sign.Image = Properties.Resources.签单2; this.Btn_Other.Image = Properties.Resources.其他2; this.Btn_Cash.Image = Properties.Resources.现金支付2; if (PassValue.payments == null) //如果没有支付信息,开放其他按钮 { this.Btn_Other.Enabled = true; this.Btn_Other.Image = Properties.Resources.其他; } else if (PassValue.payments.Count() == 0) { this.Btn_Other.Enabled = true; this.Btn_Other.Image = Properties.Resources.其他; } } else { //初始化 this.Btn_All.Enabled = true; this.Btn_Part.Enabled = true; this.Btn_Plan.Enabled = true; this.Btn_Fixed.Enabled = true; this.Btn_Maling.Enabled = true; this.Btn_Free.Enabled = true; this.Btn_MemberCard.Enabled = true; this.Btn_BankCard.Enabled = true; this.Btn_Sign.Enabled = true; this.Btn_Other.Enabled = true; this.Btn_Cash.Enabled = true; this.Btn_All.Image = Properties.Resources.整单打折; this.Btn_Part.Image = Properties.Resources.部分打折; this.Btn_Plan.Image = Properties.Resources.方案打折; this.Btn_Fixed.Image = Properties.Resources.定额打折; this.Btn_Maling.Image = Properties.Resources.摸零; this.Btn_Free.Image = Properties.Resources.免单; this.Btn_MemberCard.Image = Properties.Resources.会员卡; this.Btn_BankCard.Image = Properties.Resources.银联卡; this.Btn_Sign.Image = Properties.Resources.签单; this.Btn_Other.Image = Properties.Resources.其他; this.Btn_Cash.Image = Properties.Resources.现金支付; this.Btn_Print.Image = Properties.Resources.打印对账单; this.Btn_Enter.Image = Properties.Resources.确定2; //要根据现有的打折和折扣信息进行按钮的控制 //①只要有现金的支付的话,打折信息就不能使用了 if (PassValue.payments.Count > 0) { this.Btn_All.Enabled = false; this.Btn_Part.Enabled = false; this.Btn_Plan.Enabled = false; this.Btn_Fixed.Enabled = false; this.Btn_Maling.Enabled = false; this.Btn_Free.Enabled = false; this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Maling.Image = Properties.Resources.抹零2; this.Btn_Free.Image = Properties.Resources.免单2; } //②根据折扣信息来处理 if (personsConsumption.discounts == null) { return; } if (personsConsumption.discounts.Count() > 0) { foreach (Discount item in personsConsumption.discounts) { switch (item.type) { case "whole": this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = this.Btn_Plan.Enabled = false; break; case "partial": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_All.Enabled = this.Btn_Fixed.Enabled = this.Btn_Plan.Enabled = false; break; case "scheme": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_Part.Enabled = this.Btn_Fixed.Enabled = this.Btn_All.Enabled = false; break; case "quota": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_All.Enabled = this.Btn_Part.Enabled = this.Btn_Plan.Enabled = false; break; case "round": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_All.Enabled = this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Fixed.Enabled = false; break; case "free": this.Btn_All.Image = Properties.Resources.整单打折2; this.Btn_Part.Image = Properties.Resources.部分打折2; this.Btn_Plan.Image = Properties.Resources.方案打折2; this.Btn_Fixed.Image = Properties.Resources.定额打折2; this.Btn_All.Enabled = this.Btn_Part.Enabled = this.Btn_Plan.Enabled = this.Btn_Fixed.Enabled = false; break; } } } } }