Example #1
0
 private void item2List(MenuItemForTag item, MouseButtons btn)
 {
     if (item == null)
     {
         return;
     }
     if (btn == MouseButtons.Right)
     {
         if (item.No == 0)
         {
             return;
         }
         item.No -= 1;
         if (item.No <= 0)
         {
             item.No = 0;
         }
         Sub2List(item);
     }
     else if (btn == MouseButtons.Left)
     {
         item.No += 1;
         Add2List(item, false);
     }
     return;
 }
Example #2
0
        private void Row2ListAndMenu(int ProductID, double No)
        {
            Label l = FindMenuLabel(ProductID);

            if (l == null)
            {
                return;
            }
            MenuItemForTag item = (MenuItemForTag)l.Tag;

            if (item == null)
            {
                return;
            }
            item.No = No;
            if (item.No > 0)
            {
                l.BorderStyle = BorderStyle.FixedSingle;
            }
            else
            {
                l.BorderStyle = BorderStyle.None;
            }
            if (item.No > 1)
            {
                item.LabelNo.Text = item.NoToString();
            }
            else
            {
                item.LabelNo.Text = "";
            }
            Add2List(item, false);
        }
Example #3
0
        private void lvCanDiscount_KeyDown(object sender, KeyEventArgs e)
        {
            ListView listView = (ListView)sender;

            if (listView.SelectedItems.Count <= 0)
            {
                return;
            }
            if (Keys.Delete == e.KeyData)
            {
                MenuItemForTag item = (MenuItemForTag)(listView.SelectedItems[0].Tag);
                Row2ListAndMenu(item.productID, 0);
            }
        }
Example #4
0
        private void Add2List(MenuItemForTag item, bool AtFirst)
        {
            if (item.No == 0)
            {
                Sub2List(item);
                return;
            }

            ListViewItem lvItem = FindByProductID(item.productID);
            double       no     = item.No;

            double money = item.Money();

            if (lvItem != null)
            {
                lvItem.SubItems[2].Text = no.ToString();
                lvItem.SubItems[3].Text = money.ToString();;
            }
            else
            {
                if (item.classcode != MyConstant.CanDiscountClass)
                {
                    if (AtFirst)
                    {
                        lvItem = lvNoDiscount.Items.Insert(0, item.productID.ToString());
                    }
                    else
                    {
                        lvItem = lvNoDiscount.Items.Add(item.productID.ToString());
                    }
                }
                else
                {
                    if (AtFirst)
                    {
                        lvItem = lvCanDiscount.Items.Insert(0, item.productID.ToString());
                    }
                    else
                    {
                        lvItem = lvCanDiscount.Items.Add(item.productID.ToString());
                    }
                }
                lvItem.SubItems.Add(item.name);
                lvItem.SubItems.Add(no.ToString());
                lvItem.SubItems.Add(money.ToString());
            }
            lvItem.Tag = item;
            CalcTotal();
        }
Example #5
0
 private bool WineLabelTagCodeIs(Label menu, int productID)
 {
     if (menu != null)
     {
         object obj = menu.Tag;
         if (obj != null)
         {
             MenuItemForTag item = (MenuItemForTag)obj;
             if (item.productID == productID)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #6
0
        void SetOrderItemFromListViewItem(BasicDataSet.OrderItemRow Row, ListViewItem lvItem, int i)
        {
            MenuItemForTag item = (MenuItemForTag)lvItem.Tag;

            Row.No        = (decimal)item.No;
            Row.ProductID = item.productID;
            Row.Price     = (decimal)item.Price;
            Row.Index     = (short)i;
            if (item.classcode == MyConstant.CanDiscountClass)
            {
                Row.Discount = true;
            }
            else
            {
                Row.Discount = false;
            }
        }
Example #7
0
        private void InitGuoDi()
        {
            int i;

            GuoDi          = new MenuItemForTag[MyConstant.MaxNo];
            OneDollorGuoDi = new MenuItemForTag[MyConstant.MaxNo];
            comboBoxGuoDi.Items.Clear();
            for (i = 0; i < MyConstant.MaxNo; i++)
            {
                MenuItemForTag          content = GuoDi[i] = new MenuItemForTag();
                int                     code    = MyConstant.Code[i];
                BasicDataSet.ProductRow Row     = GetMenuItemByCode(code);
                if (Row == null)
                {
                    MessageBox.Show("鍋底代碼 " + code.ToString() + ",資料庫內找不到");
                    continue;
                }
                content.No        = 0;
                content.Price     = Row.Price;
                content.productID = (int)Row.ProductID;
                content.classcode = Row.Class;
                content.LabelNo   = null;
                content.name      = Row.Name;
                comboBoxGuoDi.Items.Add(Row.Name);

                // 一元鍋底
                content = OneDollorGuoDi[i] = new MenuItemForTag();
                code    = MyConstant.OneDollorCode[i];
                Row     = GetMenuItemByCode(code);
                if (Row == null)
                {
                    MessageBox.Show("一元鍋底代碼 " + code.ToString() + ",資料庫內找不到");
                    checkOneDollor.Enabled = false;
                    continue;
                }
                content.No        = 0;
                content.Price     = Row.Price;
                content.productID = (int)Row.ProductID;
                content.classcode = Row.Class;
                content.LabelNo   = null;
                content.name      = Row.Name;
            }
            comboBoxGuoDi.Items.Add("由酒水單点");
        }
Example #8
0
        private void lvNoDiscount_KeyDown(object sender, KeyEventArgs e)
        {
            ListView listView = (ListView)sender;

            if (listView.SelectedItems.Count <= 0)
            {
                return;
            }
            if (Keys.Delete == e.KeyData)
            {
                MenuItemForTag item = (MenuItemForTag)(listView.SelectedItems[0].Tag);
                //if (item.code == MyConstant.NapkinCode)
                //{
                //    MessageBox.Show("毛巾請用別的方式刪!");
                //    return;
                //}
                //foreach (int code in MyConstant.AddPeopleCode)
                //{
                //    if (code == item.code)
                //    {
                //        MessageBox.Show("加人數請用別的方式刪!");
                //        return;
                //    }
                //}
                //foreach (int code in MyConstant.Code)
                //{
                //    if (code == item.code)
                //    {
                //        MessageBox.Show("鍋底請用別的方式刪!");
                //        return;
                //    }
                //}
                //foreach (int code in MyConstant.OneDollorCode)
                //{
                //    if (code == item.code)
                //    {
                //        MessageBox.Show("鍋底請用別的方式刪!");
                //        return;
                //    }
                //}
                Row2ListAndMenu(item.productID, 0);
            }
        }
Example #9
0
        // ListView的tag 指向MenuItem
        private bool Sub2List(MenuItemForTag item)
        {
            ListViewItem lvItem = FindByProductID(item.productID);

            if (lvItem == null)
            {
                return(false);                // 沒東西刪
            }
            if (item.No > 0)
            {
                lvItem.SubItems[2].Text = item.NoToString();
                lvItem.SubItems[3].Text = item.Money().ToString();
            }
            else
            {
                lvItem.Remove();
            }
            CalcTotal();
            return(true);            // 刪除成功
        }
Example #10
0
 private ListViewItem FindByProductID(int productID)
 {
     foreach (ListViewItem lvItem in lvNoDiscount.Items)
     {
         MenuItemForTag item = (MenuItemForTag)lvItem.Tag;
         if (productID == item.productID)
         {
             return(lvItem);
         }
     }
     foreach (ListViewItem lvItem in lvCanDiscount.Items)
     {
         MenuItemForTag item = (MenuItemForTag)lvItem.Tag;
         if (productID == item.productID)
         {
             return(lvItem);
         }
     }
     return(null);
 }
Example #11
0
        private double CalcTotal()
        {
            double total = 0;
            double no = 0, sum = 0;

            foreach (ListViewItem lvItem in lvNoDiscount.Items)
            {
                MenuItemForTag item = (MenuItemForTag)lvItem.Tag;
                sum += item.Money();
                no  += item.No;
            }
            sum = Math.Round(sum, 1);
            lvNoDiscount.Columns[2].Text = no.ToString();
            lvNoDiscount.Columns[3].Text = sum.ToString();
            total = sum;
            sum   = no = 0;
            foreach (ListViewItem lvItem in lvCanDiscount.Items)
            {
                MenuItemForTag item = (MenuItemForTag)lvItem.Tag;
                sum += item.Money();
                no  += item.No;
            }
            if (checkDiscount.Checked)
            {
                sum = sum * 0.88;
            }
            sum = Math.Round(sum, 0, MidpointRounding.AwayFromZero);
//            sum = Math.Round(sum, 1);  銀行家捨入
            lvCanDiscount.Columns[2].Text = no.ToString();
            lvCanDiscount.Columns[3].Text = sum.ToString();
            total += sum;
            if (mtbDeduct.Text != "")
            {
                int deduct = Int32.Parse(mtbDeduct.Text);
                total -= deduct;
            }
            total           = Math.Round(total, 0, MidpointRounding.AwayFromZero);
            labelTotal.Text = total.ToString();
            return(total);
        }
Example #12
0
        private void MenuClick(object sender, MouseEventArgs e)
        {
            Label          l    = (Label)sender;
            MenuItemForTag item = (MenuItemForTag)l.Tag;

            item2List(item, e.Button);
            if (item.No > 0)
            {
                l.BorderStyle = BorderStyle.FixedSingle;
            }
            else
            {
                l.BorderStyle = BorderStyle.None;
            }
            if (item.No == 1 || item.No == 0)
            {
                item.LabelNo.Text = "";
            }
            else
            {
                item.LabelNo.Text = item.NoToString();
            }
        }
Example #13
0
        private void SetWineMenuItem(BasicDataSet.ProductRow Row, int i, bool EnableOrNot, int WidthX, int HeightY, GroupBox grBox)
        {
            int x = i / MyLayout.NoY;
            int y = i % MyLayout.NoY;

            if (x >= MyLayout.NoX)
            {
                return;                    // 資料太多了
            }
            int xx, yy;

            xx = MyLayout.OffsetX + x * WidthX;
            yy = MyLayout.OffsetY + y * HeightY;
            Label l = new Label();

            // Create No Label
            WineItemNo[i] = l;
            l.Location    = new System.Drawing.Point(xx + WidthX - MyLayout.NoWidth, yy);
            l.Name        = "WinelabelX" + x.ToString() + "Y" + y.ToString();
            l.Size        = new System.Drawing.Size(MyLayout.NoWidth, HeightY - 2);
            l.TabIndex    = 0;
            l.Text        = "";
            l.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
            l.BorderStyle = BorderStyle.None;
            grBox.Controls.Add(l);
            // Create Name Label
            l           = new Label();
            WineMenu[i] = l;
            l.AutoSize  = false;
            l.Location  = new System.Drawing.Point(xx, yy);
            l.Name      = "WineNoLabelX" + x.ToString() + "Y" + y.ToString();
            l.Size      = new System.Drawing.Size(WidthX - MyLayout.NoWidth - 2, HeightY - 2);
            l.TabIndex  = 0;
            l.Enabled   = EnableOrNot;
            // 新細明體10pt
            //                l.Font = new System.Drawing.Font("新細明體", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));

            if (Row != null)
            {
                MenuItemForTag content = new MenuItemForTag();
                content.No        = 0;
                content.Price     = Row.Price;
                content.productID = (int)Row.ProductID;
                content.classcode = Row.Class;
                content.LabelNo   = WineItemNo[i];
                content.name      = Row.Name.ToString();
                l.Tag             = content;
                l.Text            = content.name;
                if (!FormOnlyForCheck)
                {
                    l.MouseClick += new MouseEventHandler(this.MenuClick);
                }
            }
            else
            {
                l.Tag  = null;
                l.Text = "";
            }
            l.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
            l.BorderStyle = BorderStyle.None;
            grBox.Controls.Add(l);
        }
Example #14
0
        private void btnCodeEntry_Click(object sender, EventArgs e)
        {
            int     code;
            decimal volume;
            double  d;

            try
            {
                code = Int32.Parse(textBoxCode.Text);
            }
            catch
            {
                MessageBox.Show("代碼只能打入數字");
                textBoxCode.Focus();
                return;
            }
            try
            {
                volume = decimal.Parse(textBoxVolume.Text);
                d      = (double)decimal.Round(volume, 1);
            }
            catch
            {
                MessageBox.Show("只能輸入數字和小數點");
                textBoxVolume.Focus();
                return;
            }
            Label l = FindMenuLabel(code);

            if (l == null)
            {
                MessageBox.Show("代碼錯誤,無此商品");
                textBoxCode.Focus();
                return;
            }
            MenuItemForTag item = (MenuItemForTag)l.Tag;

            if (item == null)
            {
                return;
            }
            item.No = d;
            if (item.No > 0)
            {
                l.BorderStyle = BorderStyle.FixedSingle;
            }
            else
            {
                l.BorderStyle = BorderStyle.None;
            }
            if (item.No > 1)
            {
                item.LabelNo.Text = item.No.ToString();
            }
            else
            {
                item.LabelNo.Text = "";
            }
            Add2List(item, false);
            textBoxCode.Text   = "";
            textBoxVolume.Text = "1";
        }
Example #15
0
        private void InitFoodMenu(GroupBox grBox)
        {
            int WidthX  = (grBox.Width - MyLayout.OffsetX) / MyLayout.NoX;
            int HeightY = (grBox.Height - MyLayout.OffsetY) / MyLayout.NoY;

            FoodMenu   = new System.Windows.Forms.Label[MyLayout.NoX, MyLayout.NoY];
            FoodItemNo = new System.Windows.Forms.Label[MyLayout.NoX, MyLayout.NoY];
            int x, y;

            for (x = 0; x < MyLayout.NoX; x++)
            {
                for (y = 0; y < MyLayout.NoY; y++)
                {
                    int xx, yy;
                    xx = MyLayout.OffsetX + x * WidthX;
                    yy = MyLayout.OffsetY + y * HeightY;
                    Label l = new Label();
                    // Create No Label
                    FoodItemNo[x, y] = l;
                    l.Location       = new System.Drawing.Point(xx + WidthX - MyLayout.NoWidth, yy);
                    l.Name           = "FoodlabelX" + x.ToString() + "Y" + y.ToString();
                    l.Size           = new System.Drawing.Size(MyLayout.NoWidth, HeightY - 2);
                    l.TabIndex       = 0;
                    l.Text           = "";
                    l.TextAlign      = System.Drawing.ContentAlignment.MiddleLeft;
                    l.BorderStyle    = BorderStyle.None;
                    grBox.Controls.Add(l);
                    // Create Name Label
                    l = new Label();
                    FoodMenu[x, y] = l;
                    l.AutoSize     = false;
                    l.Location     = new System.Drawing.Point(xx, yy);
                    l.Name         = "FoodNoLabelX" + x.ToString() + "Y" + y.ToString();
                    l.Size         = new System.Drawing.Size(WidthX - MyLayout.NoWidth - 2, HeightY - 2);
                    l.TabIndex     = 0;
                    // 新細明體10pt
                    //                   l.Font = new System.Drawing.Font("新細明體", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));


                    BasicDataSet.ProductRow Row = GetFoodMenuItem(x, y);
                    if (Row != null)
                    {
                        MenuItemForTag content = new MenuItemForTag();
                        content.No        = 0;
                        content.Price     = Row.Price;
                        content.productID = Row.ProductID;
                        content.classcode = Row.Class;
                        content.LabelNo   = FoodItemNo[x, y];
                        content.name      = Row.Name.ToString();
                        l.Tag             = content;
                        l.Text            = content.name;
                        if (!FormOnlyForCheck)
                        {
                            l.MouseClick += new MouseEventHandler(this.MenuClick);
                        }
                    }
                    else
                    {
                        l.Tag  = null;
                        l.Text = "";
                    }
                    l.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
                    l.BorderStyle = BorderStyle.None;
                    grBox.Controls.Add(l);
                }
            }
        }