Beispiel #1
0
 private void LoadCT(HoaDon hd)
 {
     blCT  = new BLChiTiet_HD();
     dsCT  = new List <ChiTiet_HD>();
     dsLay = blCT.LoadData(hd);
     for (int i = 0; i < dsLay.Tables[0].Rows.Count; i++)
     {
         DataRow    row = dsLay.Tables[0].Rows[i];
         var        x   = row.ItemArray.ToList();
         ChiTiet_HD ct  = new ChiTiet_HD()
         {
             MaHD    = int.Parse(row[0].ToString()),
             MaSP    = int.Parse(row[1].ToString()),
             TenSP   = row[2].ToString(),
             SoLuong = int.Parse(row[3].ToString())
         };
         dsCT.Add(ct);
     }
     dgvSanPham.Rows.Clear();
     lblMa.Visible   = true;
     labelMa.Visible = true;
     lblMa.Text      = hd.MaHD.ToString();
     for (int i = 0; i < dsCT.Count; i++)
     {
         dgvSanPham.Rows.Add(dsCT[i].MaHD, dsCT[i].MaSP, dsCT[i].TenSP, dsCT[i].SoLuong);
     }
 }
Beispiel #2
0
        public bool Delete(ChiTiet_HD ct, out string message)
        {
            bool   result;
            string str = String.Format("delete from ChiTiet_HD where MaHD = {0} and MaSP={1}", ct.MaHD, ct.MaSP);

            result = main.ExecuteNonQuery(str, out message);
            return(result);
        }
Beispiel #3
0
        public bool Insert(ChiTiet_HD ct, out string message)
        {
            bool   result = false;
            string str    = String.Format("insert into ChiTiet_HD values({0},{1},{2})", ct.MaHD, ct.MaSP, ct.SoLuong);

            result = main.ExecuteNonQuery(str, out message);
            return(result);
        }
Beispiel #4
0
        public bool Update(ChiTiet_HD ct, out string message)
        {
            bool   result = false;
            string str    = String.Format("update ChiTiet_HD set SoLuong={2} where MaHD={0} and MaSP={1}",
                                          ct.MaHD, ct.MaSP, ct.SoLuong);

            result = main.ExecuteNonQuery(str, out message);
            return(result);
        }
Beispiel #5
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            bool   kq = false;
            string message;

            kq = blHD.Reader(out message);
            if (kq == false)
            {
                MessageBox.Show(message);
            }
            else
            {
                HoaDon hd = new HoaDon();
                hd.MaHD      = blHD.Max + 1;
                hd.TongTien  = ThanhTien;
                hd.TongGiaSP = TongGiaSP;
                hd.Ngay      = DateTime.Now.Day;
                hd.Thang     = DateTime.Now.Month;
                hd.Nam       = DateTime.Now.Year;
                hd.TT_HD     = true;
                blHD.Insert(hd, out message);

                for (int i = 0; i < listItem.Count; i++)
                {
                    int        value = (int)(listItem[i].Tag);
                    ChiTiet_HD ct    = new ChiTiet_HD();
                    ct.MaHD    = hd.MaHD;
                    ct.MaSP    = value;
                    ct.SoLuong = listItem[i].SoLuong;
                    blCT.Insert(ct, out message);
                }
                MessageBox.Show(message);
                listItem.Clear();
                flpSanPham.Controls.Clear();
                for (int i = 0; i < dsSP.Count; i++)
                {
                    if (listPi[i] == null)
                    {
                        break;
                    }
                    listPi[i].Count = 0;
                }
                pnThanhToan.Visible = false;
            }
        }
Beispiel #6
0
 private void DetailBill_Load(object sender, EventArgs e)
 {
     blCT  = new BLChiTiet_HD();
     dsCT  = new List <ChiTiet_HD>();
     dsLay = blCT.LoadData(hd);
     for (int i = 0; i < dsLay.Tables[0].Rows.Count; i++)
     {
         DataRow    row = dsLay.Tables[0].Rows[i];
         var        x   = row.ItemArray.ToList();
         ChiTiet_HD ct  = new ChiTiet_HD()
         {
             MaHD    = int.Parse(row[0].ToString()),
             MaSP    = int.Parse(row[1].ToString()),
             TenSP   = row[2].ToString(),
             SoLuong = int.Parse(row[3].ToString())
         };
         dsCT.Add(ct);
     }
     dgvSanPham.Rows.Clear();
     for (int i = 0; i < dsCT.Count; i++)
     {
         dgvSanPham.Rows.Add(dsCT[i].MaHD, dsCT[i].MaSP, dsCT[i].TenSP, dsCT[i].SoLuong);
     }
 }