private void btnImport_Click_1(object sender, EventArgs e) { if (Uc_WareHouse.GetData.idBill == "") { MessageBox.Show("You need to create a bill to import first"); } else { Uc_WareHouse.GetData.choose = 4; GetData.idSP = lbID.Text; Uc_WareHouse.GetData.id = lbID.Text; frmAmount amount = new frmAmount(); amount.ShowDialog(); if (frmAmount.GetData.sL != 0) { chiTietHDN cthdnn = db.chiTietHDNs.Where(s => s.maHDN.Equals(Uc_WareHouse.GetData.idBill) && s.maSP.Equals(lbID.Text)).FirstOrDefault(); if (cthdnn != null) { MessageBox.Show("Already have this product in present bill"); } else { db.CTHDN_Ins(Uc_WareHouse.GetData.idBill, lbID.Text, frmAmount.GetData.gia, frmAmount.GetData.sL, 0); lbSL.Text = (frmAmount.GetData.sL + Convert.ToInt32(lbSL.Text)).ToString(); } } } }
private void dgvProduct_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { if (dgvProduct.Columns[e.ColumnIndex].Name.Equals("ct")) { if (GetData.idBill == "") { MessageBox.Show("Must create a Import bill yet"); } else { chiTietHDN cthdn = db.chiTietHDNs. Where(s => s.maHDN.Equals(GetData.idBill) && s.maSP.Equals(GetData.masp)) .FirstOrDefault(); if (cthdn != null) { MessageBox.Show("Already have this product in this bill"); } else { frmAmount amount = new frmAmount(); amount.ShowDialog(); if (frmAmount.GetData.sL != 0 || frmAmount.GetData.gia != 0) { db.CTHDN_Ins(GetData.idBill, GetData.masp, frmAmount.GetData.gia, frmAmount.GetData.sL, 0); Uc_SP_Load(1); } } } } else if (dgvProduct.Columns[e.ColumnIndex].Name.Equals("Column6")) { frmProduct product = new frmProduct(); GetData.choose = 2; product.ShowDialog(); Uc_SP_Load(Convert.ToInt32(txtPage.Text)); } } }