public bool TaoHoaDonXuat(HoaDonXuat hdx, ArrayList arrThuoc) { int i = hdxQ.InsertHDX(hdx); if (i > 0) { HoaDonXuat hdxTemp = hdxQ.SelectLastHoaDonXuat(); int MaHDX = hdxTemp.MaHDX; int j = 0; foreach (Thuoc thuoc in arrThuoc) { ChiTietHoaDonXuat chiTietHDX = new ChiTietHoaDonXuat(MaHDX, thuoc.IDThuoc, thuoc.SoLuong, thuoc.GiaBan, thuoc.Thue, thuoc.TenDVT); j += hdxQ.InsertChiTietHDX(chiTietHDX); } if (j == arrThuoc.Count) { foreach (Thuoc thuoc in arrThuoc) { hdxQ.UpdateSoLuongThuoc(thuoc.IDThuoc, thuoc.SoLuong); } return true; } else { hdxQ.DelChiTietHDXByMaHDX(MaHDX); hdxQ.DelHoaDonXuatByMaHDX(MaHDX); return false; } } else { return false; } }
public ArrayList SelectAllChiTietHDX(int _MaHDX) { SqlDataReader rd = dbHelper.ExecuteQuery(" GetChiTietHD_MaHDX " + _MaHDX + " "); ArrayList arrLChiTietHDX = new ArrayList(); while (rd.Read()) { ChiTietHoaDonXuat chiTietHDX = new ChiTietHoaDonXuat(rd.GetInt32(0), rd.GetInt32(1),rd.GetInt32(2), rd.GetString(3), rd.GetInt32(4), rd.GetDecimal(5), rd.GetDouble(6), rd.GetString(7), rd.GetString(8)); arrLChiTietHDX.Add(chiTietHDX); } rd.Close(); return arrLChiTietHDX; }
public int InsertChiTietHDX(ChiTietHoaDonXuat chiTietHDX) { List<SqlParameter> paramList = new List<SqlParameter>(); SqlParameter param = new SqlParameter(); param = new SqlParameter("@MaHDX", SqlDbType.Int); param.Value = chiTietHDX.MaHDX; paramList.Add(param); param = new SqlParameter("@IDThuoc", SqlDbType.Int); param.Value = chiTietHDX.IDThuoc; paramList.Add(param); param = new SqlParameter("@SoLuong", SqlDbType.Int); param.Value = chiTietHDX.SoLuong; paramList.Add(param); param = new SqlParameter("@GiaBan", SqlDbType.Decimal); param.Value = chiTietHDX.GiaBan; paramList.Add(param); param = new SqlParameter("@Thue", SqlDbType.Float); param.Value = chiTietHDX.Thue; paramList.Add(param); param = new SqlParameter("@DonVi", SqlDbType.NVarChar); param.Value = chiTietHDX.DonVi; paramList.Add(param); int i = dbHelper.ExecuteNonQuery("ChiTietHoaDonXuat_Insert", paramList); return i; }