/// <summary> /// Creates a new instance of the CT_PHIEU_NHAP_XE class and populates it with data from the specified SqlDataReader. /// </summary> private CTPHIEUNHAPXE_DTO MakeCTPHIEUNHAPXE_DTO(SqlDataReader dataReader) { CTPHIEUNHAPXE_DTO CtPhieuNhapXe = new CTPHIEUNHAPXE_DTO(); CtPhieuNhapXe.MaPhieuNhapXe = SqlClientUtility.GetInt32(dataReader, "MA_PHIEU_NHAP_XE", 0); CtPhieuNhapXe.MaXe = SqlClientUtility.GetInt32(dataReader, "MA_XE", 0); CtPhieuNhapXe.MaMau = SqlClientUtility.GetString(dataReader, "MA_MAU", String.Empty); CtPhieuNhapXe.SoLuong = SqlClientUtility.GetInt32(dataReader, "SO_LUONG", 0); return(CtPhieuNhapXe); }
/// <summary> /// Updates a record in the CT_PHIEU_NHAP_XE table. /// </summary> public void Update(CTPHIEUNHAPXE_DTO CtPhieuNhapXe) { ValidationUtility.ValidateArgument("CtPhieuNhapXe", CtPhieuNhapXe); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@MA_PHIEU_NHAP_XE", CtPhieuNhapXe.MaPhieuNhapXe), new SqlParameter("@MA_XE", CtPhieuNhapXe.MaXe), new SqlParameter("@MA_MAU", CtPhieuNhapXe.MaMau), new SqlParameter("@SO_LUONG", CtPhieuNhapXe.SoLuong) }; SqlClientUtility.ExecuteNonQuery(m_ConnectionString, CommandType.StoredProcedure, "PROC_CtPhieuNhapXe_Update", parameters); }
/// <summary> /// Selects all records from the CT_PHIEU_NHAP_XE table. /// </summary> public List <CTPHIEUNHAPXE_DTO> SelectAll() { using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_CtPhieuNhapXe_SelectAll")) { List <CTPHIEUNHAPXE_DTO> CtPhieuNhapXeList = new List <CTPHIEUNHAPXE_DTO>(); while (dataReader.Read()) { CTPHIEUNHAPXE_DTO CtPhieuNhapXe = MakeCTPHIEUNHAPXE_DTO(dataReader); CtPhieuNhapXeList.Add(CtPhieuNhapXe); } return(CtPhieuNhapXeList); } }
/// <summary> /// Selects all records from the CT_PHIEU_NHAP_XE table by a foreign key. /// </summary> public List <CTPHIEUNHAPXE_DTO> SelectAllByMaXe(int MaXe) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@MA_XE", MaXe) }; using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_CtPhieuNhapXeSelectAllByMaXe", parameters)) { List <CTPHIEUNHAPXE_DTO> CtPhieuNhapXeList = new List <CTPHIEUNHAPXE_DTO>(); while (dataReader.Read()) { CTPHIEUNHAPXE_DTO CtPhieuNhapXe = MakeCTPHIEUNHAPXE_DTO(dataReader); CtPhieuNhapXeList.Add(CtPhieuNhapXe); } return(CtPhieuNhapXeList); } }
private void btn_Nhap_Click(object sender, EventArgs e) { //Chon cac chi tiet don dat hang dua vao chi tiet phieu nhap xe CTPhieuNhapDto_List = new List <CTPHIEUNHAPXE_DTO>(); int SoLuongXeNhap = 0; if (chk_All.Checked) { for (int i = 0; i < grid_ChiTietDDH.Rows.Count; i++) { CTPHIEUNHAPXE_DTO CTPhieuNhapDto = new CTPHIEUNHAPXE_DTO(); CTPhieuNhapDto.MaXe = int.Parse(grid_ChiTietDDH.Rows[i].Cells["MaXe"].Value.ToString()); CTPhieuNhapDto.MaMau = grid_ChiTietDDH.Rows[i].Cells["MaMau"].Value.ToString(); //CTPhieuNhapDto.MaPhieuNhapXe = 'sau khi them phieu nhap xe moi bo sung vao' CTPhieuNhapDto.SoLuong = int.Parse(grid_ChiTietDDH.Rows[i].Cells["SoLuong"].Value.ToString()); CTPhieuNhapDto_List.Add(CTPhieuNhapDto); SoLuongXeNhap += CTPhieuNhapDto.SoLuong; } } else { for (int i = 0; i < grid_ChiTietDDH.Rows.Count; i++) { CheckBox chk_box = (CheckBox)grid_ChiTietDDH.Rows[i].Cells["Check"].Value; if (chk_box.Checked) { CTPHIEUNHAPXE_DTO CTPhieuNhapDto = new CTPHIEUNHAPXE_DTO(); CTPhieuNhapDto.MaXe = int.Parse(grid_ChiTietDDH.Rows[i].Cells["MaXe"].Value.ToString()); CTPhieuNhapDto.MaMau = grid_ChiTietDDH.Rows[i].Cells["MaMau"].Value.ToString(); //CTPhieuNhapDto.MaPhieuNhapXe = 'sau khi them phieu nhap xe moi bo sung vao' CTPhieuNhapDto.SoLuong = int.Parse(grid_ChiTietDDH.Rows[i].Cells["SoLuong"].Value.ToString()); CTPhieuNhapDto_List.Add(CTPhieuNhapDto); SoLuongXeNhap += CTPhieuNhapDto.SoLuong; } } } grid_ChiTietPhieuNhap.DataSource = CTPhieuNhapDto_List; txt_TongSoLuong.Text = SoLuongXeNhap.ToString(); }
/// <summary> /// Updates a record in the CT_PHIEU_NHAP_XE table. /// </summary> public void Update(CTPHIEUNHAPXE_DTO CtPhieuNhapXe) { ValidationUtility.ValidateArgument("CtPhieuNhapXe", CtPhieuNhapXe); new CTPHIEUNHAPXE_DAO().Update(CtPhieuNhapXe); }