Exemplo n.º 1
0
        string CurrentPhotoPath()
        {
            DataRowView rowView = productBindingSource.Current as DataRowView;

            BasicDataSet.ProductRow row = rowView.Row as BasicDataSet.ProductRow;
            return(m_PhotoPath + row.ProductID.ToString() + ".jpg");
        }
Exemplo n.º 2
0
        private void photoPictureBox_DoubleClick(object sender, EventArgs e)
        {
            DataRowView rowView = productBindingSource.Current as DataRowView;

            BasicDataSet.ProductRow row = rowView.Row as BasicDataSet.ProductRow;
            if (row.ProductID <= 0)
            {
                MessageBox.Show("抱歉! 新增時內碼小於 0 無法存照片!\r\n請存檔後關閉產品表,再重新進入設定照片!");
                return;
            }
            DialogResult result = openFileDialog1.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }
            string ext = Path.GetExtension(openFileDialog1.FileName).ToLower();

            if (ext != ".jpg")
            {
                MessageBox.Show("對不起!只接受jpg檔");
                return;
            }
            string path = CurrentPhotoPath();

            File.Copy(openFileDialog1.FileName, path, true);
            photoPictureBox.ImageLocation = path;
        }
Exemplo n.º 3
0
        void Item2Buffer(ByteBuilder Buf, CSaleItem item)
        {
            int    index = productBindingSource.Find("ProductID", item.ProductID);
            string s     = "產品" + item.ProductID.ToString();

            if (index >= 0)
            {
                object       o  = productBindingSource.DataSource;
                BasicDataSet ds = (BasicDataSet)o;
                BasicDataSet.ProductDataTable t   = ds.Product;
                BasicDataSet.ProductRow       row = t[index];
                s = row.Name;
            }

            int m;

            do
            {
                m = GB2312.GetByteCount(s);
                if (m <= 16)
                {
                    break;
                }
                s = s.Substring(0, s.Length - 1);
            } while (true);
            int n = 16 - m + s.Length;

            Buf.AppendPadRight(s, n, GB2312);
            Buf.Append(d2str(item.Volume, 6), GB2312);
//            Buf.Append(d2str(item.Price  , 5), GB2312);
            Buf.Append(d2str(item.Total, 10), GB2312);
            Buf.Append("\r\n", GB2312);
        }
Exemplo n.º 4
0
        private void InitFoodMenu(GroupBox grBox, int menuId, out Label [,] FoodName)
        {
            SuspendLayout();
            string mark    = "F" + menuId.ToString() + DateTime.Now.Ticks.ToString(); //避免多次進入,label重名了
            int    WidthX  = (grBox.Width - MyLayout.OffsetX) / MyLayout.NoX;
            int    HeightY = (grBox.Height - MyLayout.OffsetY) / MyLayout.NoY;

            FoodName = new 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 Name Label
                    l = new Label();
                    FoodName[x, y] = l;
                    l.AutoSize     = false;
                    l.Location     = new System.Drawing.Point(xx, yy);
                    l.Name         = mark + "X" + x.ToString() + "Y" + y.ToString();
                    l.Size         = new System.Drawing.Size(WidthX - MyLayout.NoWidth - 2, HeightY - 2);
                    l.TabIndex     = 0;
                    BasicDataSet.ProductRow Row = GetFoodMenuItem(menuId, x, y);
                    if (Row != null)
                    {
                        l.Tag = Row;
                        if (Row.IsNameNull())
                        {
                            l.Text = "";
                        }
                        else
                        {
                            l.Text = Row.Name.ToString();
                        }
                    }
                    else
                    {
                        l.Tag  = null;
                        l.Text = "";
                    }
                    l.DragEnter  += new DragEventHandler(this.LabelDragEnter);
                    l.DragLeave  += new EventHandler(this.LabelDragLeave);
                    l.DragDrop   += new DragEventHandler(LabelDragDrop);
                    l.MouseDown  += new MouseEventHandler(LabelMouseDown);
                    l.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
                    l.BorderStyle = BorderStyle.None;
                    l.AllowDrop   = true;
                    grBox.Controls.Add(l);
                }
            }

            ResumeLayout();
            PerformLayout();
        }
Exemplo n.º 5
0
        private void LabelDragDrop(object sender, DragEventArgs e)
        {
            Label label = sender as Label;

            label.BorderStyle = BorderStyle.None;
            DragItem item = e.Data.GetData(typeof(DragItem)) as DragItem;

            BasicDataSet.ProductRow row = item.row;
            if (label.Tag == row)
            {
                return;
            }
            label.Text      = item.ToString();
            label.BackColor = Color.SeaShell;
            label.Tag       = row;
            m_Modified      = true;
            if (item.label != null)
            {
                item.label.Text      = "";
                item.label.BackColor = Color.SeaShell;
                item.label.Tag       = null;
            }
            if (row == null)
            {
                return;
            }
            // Check duplicate
            int code = row.Code;

            foreach (Label l in m_FoodName)
            {
                BasicDataSet.ProductRow ro = l.Tag as BasicDataSet.ProductRow;
                if (ro == null)
                {
                    continue;
                }
                if (l == label)
                {
                    continue;
                }
                if (ro.Code == code)
                {
                    l.Text      = "";
                    l.BackColor = Color.SeaShell;
                    l.Tag       = null;
                }
            }
        }
Exemplo n.º 6
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("由酒水單点");
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
                }
            }
        }
Exemplo n.º 9
0
 public DragItem(Label l, BasicDataSet.ProductRow r)
 {
     label = l;
     row   = r;
     X     = Y = -1;
 }