string PrintLine(BakeryOrderSet.OrderRow order) { int id = order.ID % 100000; decimal income = 0; if (!order.IsIncomeNull()) { income = order.Income; } DateTime printTime = new DateTime(2013, 10, 31); if (!order.IsPrintTimeNull()) { printTime = order.PrintTime; } string str = id.ToString("d3") + " " + printTime.ToString("HH:mm:ss") + " " + income.ToString("f0").PadLeft(3); string addNote = ""; if (!order.IsDeletedNull() && order.Deleted) { addNote += "删"; } else if (!order.IsPayByNull()) { if (order.PayBy == "B") { addNote += "卡"; } else if (order.PayBy == "C") { addNote += "支"; } else if (order.PayBy == "E") { addNote += "微"; } else if (order.PayBy == "D") { addNote += "A "; } else if (order.PayBy == "F") { addNote += "B "; } } if (income < 0) { addNote += "退"; } if (addNote.Length == 0) { addNote = " "; } return(str + addNote); }
private bool ShowOrder(BakeryOrderSet.OrderRow order) { BakeryOrderSet.OrderItemRow[] items = order.GetOrderItemRows(); lvItems.Items.Clear(); decimal total = 0, count = 0;; foreach (BakeryOrderSet.OrderItemRow item in items) { if (item.IsNoNull()) { continue; } if (item.IsProductIDNull()) { continue; } if (item.IsPriceNull()) { item.Price = 0m; } decimal no = item.No; decimal money = item.Price * no; int productID = item.ProductID; ListViewItem lvItem = lvItems.Items.Add(productID.ToString()); lvItem.SubItems.Add(FindNameFromProduct(productID)); lvItem.SubItems.Add(no.ToString()); lvItem.SubItems.Add(money.ToString()); total += money; count++; } // 計算折扣 if (!order.IsDiscountRateNull()) { decimal discountRate = order.DiscountRate; if (discountRate != 0m && discountRate != 1m) { total = Math.Floor(total * discountRate); } } lvItems.Columns[1].Text = "ID " + (order.ID % 10000).ToString() + (order.Deleted ? " deleted" : "") + (order.RCashierID > 0 ? " 退货" : ""); lvItems.Columns[2].Text = count.ToString(); lvItems.Columns[3].Text = total.ToString(); if (!order.IsPayByNull() && order.PayBy.Length > 0) { char c = order.PayBy[0]; if (DicPayBy.Keys.Contains(c)) { btnClass.Text = DicPayBy[c]; } else { btnClass.Text = DicPayBy.First().Value; } } if (!order.IsDeductNull() && order.Deduct != 0) { if (order.OldID > 0) { total += order.Deduct; } else { total -= order.Deduct; } labelDeduct.Text = "己优惠 " + Math.Abs(order.Deduct).ToString(); } else { labelDeduct.Text = ""; } decimal income = 0; if (!order.IsIncomeNull()) { income = Math.Round(order.Income, 2); } if (!order.IsDiscountRateNull() && order.DiscountRate != 1m) { labelIncome.Text = (order.DiscountRate * 100).ToString("F0") + "折 " + income.ToString("N0"); } else { labelIncome.Text = income.ToString("N0"); } //labelIncome.Text = income.ToString(); if (!order.IsMemberIDNull()) { labelMemberID.Text = "会员" + order.MemberID; } labelAlipayNo.Text = ""; if (order.PayBy[0] == 'D' || order.PayBy[0] == 'F') { if (!order.IsCouponIncomeNull()) { labelAlipayNo.Text += "收券 " + order.CouponIncome.ToString(); } if (!order.IsCashIncomeNull() && order.CashIncome != 0m) { labelAlipayNo.Text += " 收现 " + order.CashIncome.ToString(); } } if (order.IsTradeNoNull() || order.TradeNo == "") { labelAlipayNo.Text += ""; } else { int len = order.TradeNo.Length; if (len > 18) { labelAlipayNo.Text += "支付号 " + order.TradeNo.Substring(0, 8) + "\r" + order.TradeNo.Substring(8, len - 8); } else { labelAlipayNo.Text += "支付号 " + order.TradeNo; } } if (total != income) { if (total == -income) { if (order.OldID > 0) { return(true); } else { MessageBoxShow("計算金額<" + total.ToString() + ">不符 " + order.Income.ToString()); return(false); } } else { MessageBoxShow("計算金額<" + total.ToString() + ">不符 " + order.Income.ToString()); return(false); } } return(true); }
void CreateLabel(TabPage tabPage, int x, int y, BakeryOrderSet.OrderRow Row) { if (Row == null) { return; } string mark = "St" + tabPage.Name + DateTime.Now.Ticks.ToString(); //避免多次進入,label重名了 int WidthX = (tabPage.Width - MyLayout.OffsetX) / MyLayout.NoX; int HeightY = (tabPage.Height - MyLayout.OffsetY) / MyLayout.NoY; int xx, yy; xx = MyLayout.OffsetX + x * WidthX; yy = MyLayout.OffsetY + y * HeightY; TextBox b = new TextBox(); b.MouseClick += new MouseEventHandler(b_MouseClick); b.MouseDoubleClick += new MouseEventHandler(b_MouseDoubleClick); b.Multiline = true; b.Font = SystemFonts.MenuFont; b.AutoSize = false; b.Location = new System.Drawing.Point(xx, yy); b.Name = mark + "X" + x.ToString() + "Y" + y.ToString(); b.Size = new System.Drawing.Size(WidthX - MyLayout.NoWidth - 2, HeightY - 2); b.TabIndex = 0; b.BackColor = tabPage.BackColor; if (!Row.IsPrintTimeNull()) { b.Text = Row.PrintTime.ToString("mm:ss"); } b.Text += "\r\n" + (Row.ID % 100000).ToString(); if (!Row.IsPayByNull()) { if (Row.PayBy == "B") { b.Text += "卡"; } else if (Row.PayBy == "C") { b.Text += "支"; } else if (Row.PayBy == "D") { b.Text += 'A'; } else if (Row.PayBy == "E") { b.Text += '微'; } else if (Row.PayBy == "F") { b.Text += 'B'; } } decimal income = 0; if (!Row.IsIncomeNull()) { income = Math.Round(Row.Income, 2); } b.Text += "\r\n" + income.ToString() + "元"; if (!Row.IsOldIDNull() && Row.OldID > 0) { b.BackColor = Color.Red; } if (!Row.IsDeletedNull() && Row.Deleted) { b.BackColor = Color.Green; } b.Tag = Row; b.TextAlign = HorizontalAlignment.Center; b.BorderStyle = BorderStyle.Fixed3D; tabPage.Controls.Add(b); }