Exemplo n.º 1
0
        //
        // Phương thức thêm hoá đơn
        //
        public void Add(ChiTietHDBan cthdb)
        {
            provider.Connect();
            string sql = string.Format("INSERT INTO CHITIETHDBAN(MAHDB, MASP, SOLUONG, TONG) VALUES " +
                                       "({0},{1},{2},{3})", cthdb.MaHDB, cthdb.MaSp, cthdb.SoLuong, cthdb.Tong);

            provider.ExecuteQuery(sql);
            provider.Disconnect();
        }
Exemplo n.º 2
0
        //
        // Phương thức event khi nhấn In hoá đơn ở tab hoá đơn
        //
        private void BtnIn4_Click(object sender, EventArgs e)
        {
            int   maNV = new TaiKhoanBUS().GetMaNV(_tenDN);
            Khach kh   = new Khach(-1, txtK4.Text, txtDC4.Text, txtSDT4.Text);

            new KhachBUS().Add(kh);

            int   maKH = new KhachBUS().GetMaKH(txtK4.Text);
            HDBan hdb  = new HDBan(-1, maKH, maNV, dtNgTT4.Value, Convert.ToInt32(txtThanhTien4.Text));

            new HDBanBUS().Add(hdb);
            int maHDB = new ChiTietHDBanBUS().GetMaHDB(maKH, maNV);

            try
            {
                for (int i = 0; i < gridData4.Rows.Count - 1; i++)
                {
                    int          maSP    = new SanPhamBUS().GetMaSP(gridData4.Rows[i].Cells[0].Value.ToString());
                    int          soLuong = Convert.ToInt32(gridData4.Rows[i].Cells[1].Value.ToString());
                    int          tong    = Convert.ToInt32(gridData4.Rows[i].Cells[3].Value.ToString());
                    ChiTietHDBan cthdb   = new ChiTietHDBan(maHDB, maSP, soLuong, tong);
                    new ChiTietHDBanBUS().Add(cthdb);
                }

                MessageBox.Show("Đã lưu hoá đơn vào ổ đĩa D");
                frmCryReport f = new frmCryReport
                {
                    _tenKH    = txtK4.Text,
                    _maHDB    = maHDB,
                    _tenNV    = new TaiKhoanBUS().GetTenNV(_tenDN),
                    _ngLap    = dtNgTT4.Value,
                    _tongTien = txtThanhTien4.Text
                };
                f.Show();
            }
            catch
            {
                MessageBox.Show("Kiểm tra lại thông tin");

                new HDBanBUS().Delete(maHDB.ToString());

                new KhachBUS().Delete(kh);
                int i = Convert.ToInt32(gridData2.Rows[gridData2.RowCount - 1].Cells[0].Value.ToString());
                new KhachBUS().Reset(i);

                gridData4.DataSource = new HDBanBUS().LoadHD();
                gridData4.Refresh();

                i = Convert.ToInt32(gridData3.Rows[gridData3.RowCount - 1].Cells[0].Value.ToString());

                new SanPhamBUS().Reset(i);
            }
        }
Exemplo n.º 3
0
        //
        // Phương thức truy xuất thông tin chi tiết hoá đơn dựa theo command được truyền vào
        //
        public List <ChiTietHDBan> LoadData(string sql)
        {
            provider.Connect();
            SqlDataReader reader = provider.ExecuteReader(sql);

            List <ChiTietHDBan> list = new List <ChiTietHDBan>();

            while (reader.Read())
            {
                int          maHDB   = reader.GetInt32(0);
                int          maSP    = reader.GetInt32(1);
                int          soLuong = reader.GetInt32(2);
                int          tong    = reader.GetInt32(3);
                ChiTietHDBan s       = new ChiTietHDBan(maHDB, maSP, soLuong, tong);

                list.Add(s);
            }
            provider.Disconnect();
            return(list);
        }
Exemplo n.º 4
0
 //
 // Phương thức truyền dẫn Add
 //
 public void Add(ChiTietHDBan cthdb)
 {
     new ChiTietHDBanDAO().Add(cthdb);
 }