//Cach 1 private void CapNhatSLVatTuKhoVer1(int ID_QuyetDinh, byte trangthai) { clsQD_NhapVatTu_ChiTiet clsChiTiet = new clsQD_NhapVatTu_ChiTiet(); clsKho_VatTu clsKVT = new clsKho_VatTu(); DataTable dt = clsChiTiet.SelectAllW_ID_QuyetDinh(ID_QuyetDinh); foreach (DataRow dr in dt.Rows) { clsKVT.ID_Kho = Convert.ToInt32(dr["ID_Kho"]); clsKVT.ID_VatTu = Convert.ToInt32(dr["ID_VatTu"]); bool bInsert = clsKVT.SelectOne().Rows.Count == 0; if (trangthai == 5) { if (bInsert) { clsKVT.SoLuong = Convert.ToInt32(dr["SoLuong"]); clsKVT.Insert(); } else { clsKVT.SoLuong = clsKVT.SoLuong + Convert.ToInt32(dr["SoLuong"]); clsKVT.Update(); } } else if (trangthai == 3) { clsKVT.SoLuong = clsKVT.SoLuong - Convert.ToInt32(dr["SoLuong"]); clsKVT.Update(); } } }
//Cach 3 private void CapNhatSLVatTuKhoVer3(int ID_QuyetDinh, byte trangthai) { clsQD_NhapVatTu_ChiTiet clsChiTiet = new clsQD_NhapVatTu_ChiTiet(); clsKho_VatTu clsKVT = new clsKho_VatTu(); DataTable dt = clsChiTiet.SelectAllW_ID_QuyetDinh(ID_QuyetDinh); foreach (DataRow dr in dt.Rows) { if (trangthai == 5) { clsKVT.Update_SoLuongVer3(Convert.ToInt32(dr["ID_Kho"]), Convert.ToInt32(dr["ID_VatTu"]), Convert.ToInt32(dr["SoLuong"])); } else if (trangthai == 3) { clsKVT.Update_SoLuongVer3(Convert.ToInt32(dr["ID_Kho"]), Convert.ToInt32(dr["ID_VatTu"]), (-1) * Convert.ToInt32(dr["SoLuong"])); } } }