public void DataLoad() { dbCTHopDong = new DBCTHopDong(); dgvDanhMucCTHopDong.DataSource = dbCTHopDong.GetAllCTHopDong(); dgvDanhMucCTHopDong.Columns["HopDong"].Visible = false; dgvDanhMucCTHopDong.Columns["SanPham"].Visible = false; foreach (DataGridViewRow row in dgvDanhMucCTHopDong.Rows) { row.HeaderCell.Value = (row.Index + 1).ToString(); } dgvDanhMucCTHopDong.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders); if (dgvDanhMucCTHopDong.Rows.Count == 0) { btnXoa.Enabled = false; } cmSoHopDong.DataSource = new DBHopDong().GetAllHopDong(); cmSoHopDong.DisplayMember = "SoHopDong"; cmSoHopDong.ValueMember = "SoHopDong"; cmMaSP.DataSource = new DBSanPham().GetAllProduct(); cmMaSP.DisplayMember = "MaSP"; cmMaSP.ValueMember = "MaSP"; cmCotTimKiem.DataSource = new string[] { "SoHopDong", "MaSP" }; DataBind(); }
private void frmXemDanhMucCTHopDong_Load(object sender, EventArgs e) { dbCTHopDong = new DBCTHopDong(); dgvDanhMucCTHopDong.DataSource = dbCTHopDong.GetAllCTHopDong(); dgvDanhMucCTHopDong.Columns["HopDong"].Visible = false; dgvDanhMucCTHopDong.Columns["SanPham"].Visible = false; foreach (DataGridViewRow row in dgvDanhMucCTHopDong.Rows) { row.HeaderCell.Value = (row.Index + 1).ToString(); } dgvDanhMucCTHopDong.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders); cmCotTimKiem.DataSource = new string[] { "SoHopDong", "MaSP" }; }
private void LuuThongTinCTHopDong() { DBCTHopDong dbCTHopDong = new DBCTHopDong(); string soHopDong = txtSoPhieu.Text.Trim(); string err = ""; foreach (DataRow row in dtCurrCTHopDong.Rows) { string maSP = row["MaSP"].ToString(); int soLuong = int.Parse(row["SoLuong"].ToString()); decimal donGia = decimal.Parse(row["ThanhTien"].ToString()); // Lưu thông tin ct hợp đồng dbCTHopDong.InsertCTHopDong(ref err, soHopDong, maSP, soLuong, donGia); // tăng số lượng sản phẩm với masp ở trên dbSanPham.UpdateProductAmount(maSP, soLuong); } }