Ejemplo n.º 1
0
 public FormReturnCheckout(int x, int y, BakeryOrderSet.OrderRow order, decimal total)
 {
     m_X      = x;
     m_Y      = y;
     m_Order  = order;
     m_Total  = total;
     m_Income = total;
     InitializeComponent();
 }
Ejemplo n.º 2
0
 public FormCheckout(int x, int y, BakeryOrderSet.OrderRow order, decimal total, FormCashier form)
 {
     m_Form   = form;
     m_X      = x;
     m_Y      = y;
     m_Order  = order;
     m_Total  = total;
     m_Income = total;
     InitializeComponent();
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        private void b_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (m_DataSealed)
            {
                MessageBoxShow("今日資料己封印,無法更改刪除狀態!");
                return;
            }
            TextBox t = sender as TextBox;

            BakeryOrderSet.OrderRow order = t.Tag as BakeryOrderSet.OrderRow;
            if (order.CashierID != m_CashierID)
            {
                MessageBoxShow("不是自己的單! 不能改");
                return;
            }
            if (MessageBoxShow("要更改刪除狀態?", true) != DialogResult.Yes)
            {
                return;
            }
            order.BeginEdit();
            if (!order.IsDeletedNull() && order.Deleted)
            {
                order.Deleted = false;
                if (order.OldID > 0)
                {
                    t.BackColor = Color.Red;
                }
                else
                {
                    t.BackColor = tabControl1.TabPages[0].BackColor;
                }
            }
            else
            {
                order.Deleted = true;
                t.BackColor   = Color.Green;
            }
            order.EndEdit();
            try
            {
                if (order.RowState != DataRowState.Unchanged)   // 不用管Deleted,Detached不會發生
                {
                    m_OrderTableAdapter.Update(order);
                    order.AcceptChanges();     // Update應該隱含AcceptChanges
                }
            }
            catch (Exception E)
            {
                if (E.GetType() != typeof(System.Data.DBConcurrencyException))
                {
                    MessageBoxShow(E.Message + "Update(CurrentOrder) 出錯");
                }
                else
                {
                    MessageBoxShow("Update(Order)發生並行違例,可能是別台己經改過這張單子,或新Order有初值未設定!");
                    MessageBoxShow("請重啟程式,你必需重新修改!");
                    this.DialogResult = DialogResult.Abort;  // 傳送.Abort給上層Form,代表ExitProgram
                    Close();
                }
            }
        }
Ejemplo n.º 6
0
        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);
        }