Пример #1
0
 private void fSanPham_ChinhSua_Them_Load(object sender, EventArgs e)
 {
     if (fSanPham.mProductID != -1)
     {
         txtbName.Text        = fSanPham.sp.TenMon;
         txtbPictureLink.Text = fSanPham.sp.LinkAnh;
         if (fSanPham.sp.KT_BanChay == 1)
         {
             rbBestSeller.Checked = true;
         }
         else if (fSanPham.sp.KT_DatBiet == 1)
         {
             rbSpecial.Checked = true;
         }
         else
         {
             rbNormal.Checked = true;
         }
         txtbSizeS.Text = fSanPham.sp.Gia.ToString();
         DTOTrangChu spM = DAOTrangChu.Instance.getProductByID(fSanPham.mProductID + 1);
         DTOTrangChu spL = DAOTrangChu.Instance.getProductByID(fSanPham.mProductID + 2);
         txtbSizeM.Text = spM.Gia.ToString();
         txtbSizeL.Text = spL.Gia.ToString();
     }
 }
Пример #2
0
        private void fDatHang_ChinhSua_Activated(object sender, EventArgs e)
        {
            int size   = cboBoxSize.SelectedIndex;
            int amount = (int)numericAmount.Value;

            if (size != 0)
            {
                product = DAOTrangChu.Instance.getProductByID(fDatHang.mProductID + size);
            }
            DAOChiTietHoaDon.Instance.InsertNewDetailBill(fDatHang.mBillID, fDatHang.mProductID, amount, txtbNote.Text);
            for (int i = 0; i < amount; i++)
            {
                DetailBill detailBill = new DetailBill();
                detailBill.IDBill           = fDatHang.mBillID;
                detailBill.IDProduct        = product.ID - size;
                detailBill.Name             = product.TenMon;
                detailBill.Price            = product.Gia.ToString() + "đ";
                detailBill.Amount           = amount;
                detailBill.BtnEdit.Click   += editDetailBill;
                detailBill.BtnEdit.Tag      = detailBill;
                detailBill.BtnDelete.Click += deleteDetailBill;
                detailBill.BtnDelete.Tag    = detailBill;
                fDatHang.flpHoaDon.Controls.Add(detailBill);
            }
            this.Close();
        }
Пример #3
0
        private void product_Click(object sender, EventArgs e)
        {
            mProductID = ((sender as PictureBox).Tag as DTOTrangChu).ID;
            sp         = DAOTrangChu.Instance.getProductByID(mProductID);
            fSanPham_ChinhSua_Them f = new fSanPham_ChinhSua_Them();

            f.ShowDialog();
        }
Пример #4
0
        DTOTrangChu ShowDetail(int id)
        {
            List <DTOTrangChu> table = DAOTrangChu.Instance.LoadData();
            DTOTrangChu        temp  = null;

            foreach (DTOTrangChu item in table)
            {
                if (item.ID == id)
                {
                    Console.WriteLine(item.ID + item.TenMon + item.Gia + ' ' + item.KT_BanChay + ' ' + item.KT_DatBiet + item.LinkAnh);
                    temp = item;
                }
            }
            return(temp);
        }// tra ve thong tin cu the cua mon thong qua id
Пример #5
0
        public List <DTOTrangChu> SearchData(string keyword)
        {
            List <DTOTrangChu> tableList = new List <DTOTrangChu>();
            DataTable          data      = DataProvider.Instance.ExcuteQuery("EXEC USP_SearchProductByName @keyword", new object[] { keyword }); //Procedure in sql, also can use select *...

            foreach (DataRow item in data.Rows)
            {
                DTOTrangChu table = new DTOTrangChu(item);
                if (table.ID % 3 == 1)
                {
                    tableList.Add(table);
                }
            }
            return(tableList);
        }
Пример #6
0
        //public int[] LoadData()
        //{
        //    string query = "SELECT * FROM MON";
        //    DataTable x = new DataTable();
        //    x = DataProvider.Instance.ExcuteQuery(query);
        //    DataRow[]x1= x.Select();
        //    int[] a = new int[100];
        //    int dem = 0;
        //    for(int i=0;i<x1.Length;i++)
        //    {
        //        //Console.WriteLine(x1[i]["ID"]);
        //        a[i] = Convert.ToInt32(x1[i]["ID"]);
        //        dem++;
        //    }

        //    return a;
        //}
        public List <DTOTrangChu> LoadData()
        {
            List <DTOTrangChu> tableList = new List <DTOTrangChu>();
            DataTable          data      = DataProvider.Instance.ExcuteQuery("USP_GetListDrink"); //Procedure in sql, also can use select *...

            foreach (DataRow item in data.Rows)
            {
                DTOTrangChu table = new DTOTrangChu(item);
                if (table.ID % 3 == 1)
                {
                    tableList.Add(table);
                }
            }
            return(tableList);
        }
Пример #7
0
 private void fDatHang_ChinhSua_Load(object sender, EventArgs e)
 {
     product = DAOTrangChu.Instance.getProductByID(fDatHang.mProductID);
     pictureBoxProduct.Image = Image.FromFile(fTrangChu.ImageFolder + product.LinkAnh);
     lbProductName.Text      = product.TenMon;
     if (update)
     {
         DTOChiTietHoaDon cthd =
             DAOChiTietHoaDon.Instance.GetDetailBillByID(detailBillUpdate.ID);
         numericAmount.ReadOnly  = true;
         cboBoxSize.Text         = detailBillUpdate.SizeValue;
         cboBoxSmell.Text        = cthd.Huong;
         cboBoxToppingIce.Text   = cthd.Da;
         cboBoxToppingSugar.Text = cthd.Duong;
         cboBoxTopping.Text      = cthd.Topping;
         txtbNote.Text           = cthd.Note;
     }
 }
Пример #8
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int size   = cboBoxSize.SelectedIndex;
            int amount = (int)numericAmount.Value;

            if (size != 0)
            {
                product = DAOTrangChu.Instance.getProductByID(fDatHang.mProductID + size);
            }
            if (!update)
            {
                for (int i = 0; i < amount; i++)
                {
                    DTOChiTietHoaDon cthd = DAOChiTietHoaDon.Instance.InsertNewDetailBill(fDatHang.mBillID, fDatHang.mProductID + size, cboBoxToppingSugar.Text, cboBoxToppingIce.Text,
                                                                                          cboBoxSmell.Text, cboBoxTopping.Text, txtbNote.Text);
                    DetailBill detailBill = new DetailBill();
                    detailBill.ID               = cthd.ID;
                    detailBill.IDBill           = cthd.IDHoaDon;
                    detailBill.IDProduct        = fDatHang.mProductID;
                    detailBill.Name             = product.TenMon;
                    detailBill.Price            = product.Gia;
                    detailBill.SizeValue        = cboBoxSize.Text;
                    detailBill.BtnEdit.Click   += editDetailBill;
                    detailBill.BtnEdit.Tag      = detailBill;
                    detailBill.BtnDelete.Click += deleteDetailBill;
                    detailBill.BtnDelete.Tag    = detailBill;
                    fDatHang.flpHoaDon.Controls.Add(detailBill);
                    fDatHang.mTongTien += product.Gia;
                }
            }
            else
            {
                fDatHang.mTongTien        -= detailBillUpdate.Price;
                detailBillUpdate.Price     = product.Gia;
                fDatHang.mTongTien        += detailBillUpdate.Price;
                detailBillUpdate.SizeValue = cboBoxSize.Text;
                int index = fDatHang.flpHoaDon.Controls.GetChildIndex(detailBillUpdate);
                fDatHang.flpHoaDon.Controls.Add(detailBillUpdate);
                fDatHang.flpHoaDon.Controls.SetChildIndex(detailBillUpdate, index);
                DAOChiTietHoaDon.Instance.UpdateDetailBillInfoByID(detailBillUpdate.ID, detailBillUpdate.IDProduct + size, cboBoxToppingSugar.Text, cboBoxToppingIce.Text, cboBoxSmell.Text, cboBoxTopping.Text, txtbNote.Text);
            }

            this.Close();
        }
Пример #9
0
 private void fDatHang_ChinhSua_Load(object sender, EventArgs e)
 {
     product = DAOTrangChu.Instance.getProductByID(fDatHang.mProductID);
     pictureBoxProduct.Image = Image.FromFile(@"E:\Hoc_Tap\Nam_3\CNPM\QLTS\QuanLyQuanTraSua\QuanLyQuanTraSua\img\" + product.LinkAnh);
     lbProductName.Text      = product.TenMon;
 }