Ejemplo n.º 1
0
        void CreateLabel(TabPage tabPage, int x, int y, MyOrderRow Row, int WidthX, int HeightY)
        {
            if (Row == null)
            {
                return;
            }
            string mark = "St" + tabPage.Name + DateTime.Now.Ticks.ToString();  //避免多次進入,label重名了
            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" + PurePosNoStr(Row.ID) + "-" + PureIDStr(Row.ID);
            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("N0") + "元";

            if (!Row.IsDeletedNull() && Row.Deleted)
            {
                b.BackColor = Color.Green;
            }
            else if (income < 0)
            {
                b.BackColor = Color.Pink;
            }
            else if (!Row.IsDeductNull() && Row.Deduct != 0)
            {
                b.BackColor = Color.Azure;
            }
            b.Tag         = Row;
            b.TextAlign   = HorizontalAlignment.Center;
            b.BorderStyle = BorderStyle.Fixed3D;
            tabPage.Controls.Add(b);
        }