public DTONhaPhanPhoi getNhaPhanPhoiDetail(string mahanghoa) { DALDoiTac um = new DALDoiTac(); DataTable dt = um.getNhaPhanPhoiDetail(mahanghoa); DTONhaPhanPhoi a = new DTONhaPhanPhoi(); a.MaNPP = dt.Rows[0]["MaNPP"].ToString(); a.MaKhuVuc = dt.Rows[0]["MaKhuVuc"].ToString(); a.TenNPP = dt.Rows[0]["TenNPP"].ToString(); a.DiaChi = dt.Rows[0]["DiaChi"].ToString(); a.MaSoThue = dt.Rows[0]["MaSoThue"].ToString(); a.Fax = dt.Rows[0]["Fax"].ToString(); a.SODT = dt.Rows[0]["SODT"].ToString(); a.Mobile = dt.Rows[0]["Mobile"].ToString(); a.Email = dt.Rows[0]["Email"].ToString(); a.Website = dt.Rows[0]["Website"].ToString(); a.TaiKhoan = dt.Rows[0]["TaiKhoan"].ToString(); a.NganHang = dt.Rows[0]["NganHang"].ToString(); a.GioiHanNo = dt.Rows[0]["GioiHanNo"].ToString(); a.NoHienTai = dt.Rows[0]["NoHienTai"].ToString(); a.ChietKhau = dt.Rows[0]["ChietKhau"].ToString(); a.NguoiLienHe = dt.Rows[0]["NguoiLienHe"].ToString(); a.ChucVu = dt.Rows[0]["ChucVu"].ToString(); a.ConQuanLy = Convert.ToBoolean(dt.Rows[0]["ConQuanLy"].ToString()); return(a); }
public int updateNhaPhanPhoi(DTONhaPhanPhoi hanghoa) { var _cmd = new SqlCommand(); _cmd.CommandText = "update NHAPHANPHOI set MaNPP=@MaNPP,MaKhuVuc=@MaKhuVuc,TenNPP=@TenNPP,DiaChi=@DiaChi,MaSoThue=@MaSoThue,Fax=@Fax,SODT=@SODT,Mobile=@Mobile,Email=@Email,Website=@Website,TaiKhoan=@TaiKhoan,NganHang=@NganHang,GioiHanNo=@GioiHanNo,NoHienTai=@NoHienTai,ChietKhau=@ChietKhau,NguoiLienHe=@NguoiLienHe,ConQuanLy=@ConQuanLy where MaNPP=@MaNPP "; _cmd.CommandType = CommandType.Text; _cmd.Connection = connection; _cmd.Parameters.Add("@MaNPP", SqlDbType.NVarChar).Value = hanghoa.MaNPP; _cmd.Parameters.Add("@MaKhuVuc", SqlDbType.NVarChar).Value = hanghoa.MaKhuVuc; _cmd.Parameters.Add("@TenNPP", SqlDbType.NVarChar).Value = hanghoa.TenNPP; _cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar).Value = hanghoa.DiaChi; _cmd.Parameters.Add("@MaSoThue", SqlDbType.NVarChar).Value = hanghoa.MaSoThue; _cmd.Parameters.Add("@Fax", SqlDbType.NVarChar).Value = hanghoa.Fax; _cmd.Parameters.Add("@SODT", SqlDbType.NVarChar).Value = hanghoa.SODT; _cmd.Parameters.Add("@Mobile", SqlDbType.NVarChar).Value = hanghoa.Mobile; _cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = hanghoa.Email; _cmd.Parameters.Add("@TaiKhoan", SqlDbType.NVarChar).Value = hanghoa.TaiKhoan; _cmd.Parameters.Add("@NganHang", SqlDbType.NVarChar).Value = hanghoa.NganHang; _cmd.Parameters.Add("@GioiHanNo", SqlDbType.Money).Value = Convert.ToDecimal(hanghoa.GioiHanNo); _cmd.Parameters.Add("@NoHienTai", SqlDbType.Money).Value = Convert.ToDecimal(hanghoa.NoHienTai); _cmd.Parameters.Add("@ChietKhau", SqlDbType.Float).Value = Convert.ToDouble(hanghoa.ChietKhau); _cmd.Parameters.Add("@NguoiLienHe", SqlDbType.NVarChar).Value = hanghoa.NguoiLienHe; _cmd.Parameters.Add("@Website", SqlDbType.NVarChar).Value = hanghoa.Website; _cmd.Parameters.Add("@ConQuanLy", SqlDbType.Bit).Value = hanghoa.ConQuanLy; _cmd.Parameters.Add("@ChucVu", SqlDbType.NVarChar).Value = hanghoa.ChucVu; OpenConn(); var i = _cmd.ExecuteNonQuery(); CloseConn(); return(i); }
public int updateNhaPhanPhoi(DTONhaPhanPhoi KhachHang) { DALDoiTac um = new DALDoiTac(); int dt = um.updateNhaPhanPhoi(KhachHang); return(dt); }
public bool insertNhaPhanPhoi(DTONhaPhanPhoi KhachHang) { DALDoiTac um = new DALDoiTac(); bool dt = um.insertNhaPhanPhoi(KhachHang); return(dt); }
private void frmNhaPhanPhoi_Add_Load(object sender, EventArgs e) { DataTable dt2 = new DataTable(); BUSDoiTac bus = new BUSDoiTac(); dt2 = bus.getKhuVuc(); if (dt2.Rows.Count > 0) { foreach (DataRow row in dt2.Rows) { comboBoxEdit1.Properties.Items.Add(row["MaKhuVuc"]); } } if (!isAddForm) { BUSDoiTac b = new BUSDoiTac(); DTONhaPhanPhoi dtoHangHoa = b.getNhaPhanPhoiDetail(gotID); textEdit1.Text = dtoHangHoa.MaNPP; textEdit2.Text = dtoHangHoa.TenNPP; textEdit3.Text = dtoHangHoa.DiaChi; textEdit4.Text = dtoHangHoa.MaSoThue; textEdit5.Text = dtoHangHoa.Fax; textEdit6.Text = dtoHangHoa.SODT; textEdit7.Text = dtoHangHoa.Mobile; textEdit8.Text = dtoHangHoa.Email; textEdit9.Text = dtoHangHoa.Website; textEdit10.Text = dtoHangHoa.TaiKhoan; textEdit11.Text = dtoHangHoa.NganHang; textEdit12.Text = dtoHangHoa.NguoiLienHe; textEdit13.Text = dtoHangHoa.ChucVu; comboBoxEdit1.Text = dtoHangHoa.MaKhuVuc; comboBoxEdit2.Text = dtoHangHoa.GioiHanNo; comboBoxEdit3.Text = dtoHangHoa.NoHienTai; comboBoxEdit4.Text = dtoHangHoa.ChietKhau; checkEdit1.Checked = dtoHangHoa.ConQuanLy; } else { textEdit1.ReadOnly = false; } }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { BUSDoiTac b = new BUSDoiTac(); DTONhaPhanPhoi d = new DTONhaPhanPhoi(); d.MaNPP = textEdit1.Text; d.TenNPP = textEdit2.Text; d.DiaChi = textEdit3.Text; d.MaSoThue = textEdit4.Text; d.Fax = textEdit5.Text; d.SODT = textEdit6.Text; d.Mobile = textEdit7.Text; d.Email = textEdit8.Text; d.Website = textEdit9.Text; d.TaiKhoan = textEdit10.Text; d.NganHang = textEdit11.Text; d.NguoiLienHe = textEdit12.Text; d.ChucVu = textEdit13.Text; d.MaKhuVuc = comboBoxEdit1.Text; d.GioiHanNo = comboBoxEdit2.Text; d.NoHienTai = comboBoxEdit3.Text; d.ChietKhau = comboBoxEdit4.Text; d.ConQuanLy = checkEdit1.Checked; if (isAddForm) { if (b.insertNhaPhanPhoi(d)) { MessageBox.Show("Thao tác thành công"); } else { MessageBox.Show("Thao tác không thành công"); } } else { b.updateNhaPhanPhoi(d); MessageBox.Show("Thao tác hóa thành công"); } }
public bool insertNhaPhanPhoi(DTONhaPhanPhoi hanghoa) { string query = string.Format($"select * from NHAPHANPHOI where MaNPP='{hanghoa.MaNPP}'"); if (ExecSelectedCount(query) == 0) { var _cmd = new SqlCommand(); _cmd.CommandText = "insert into NHAPHANPHOI values (@MaNPP,@MaKhuVuc,@TenNPP,@DiaChi,@MaSoThue,@Fax,@SODT,@Mobile,@Email,@Website,@TaiKhoan,@NganHang,@GioiHanNo,@NoHienTai,@ChietKhau,@NguoiLienHe,@ChucVu,@ConQuanLy)"; _cmd.CommandType = CommandType.Text; _cmd.Connection = connection; _cmd.Parameters.Add("@MaNPP", SqlDbType.Text).Value = hanghoa.MaNPP; _cmd.Parameters.Add("@MaKhuVuc", SqlDbType.Text).Value = hanghoa.MaKhuVuc; _cmd.Parameters.Add("@TenNPP", SqlDbType.Text).Value = hanghoa.TenNPP; _cmd.Parameters.Add("@DiaChi", SqlDbType.Text).Value = hanghoa.DiaChi; _cmd.Parameters.Add("@MaSoThue", SqlDbType.Text).Value = hanghoa.MaSoThue; _cmd.Parameters.Add("@Fax", SqlDbType.Text).Value = hanghoa.Fax; _cmd.Parameters.Add("@SODT", SqlDbType.Text).Value = hanghoa.SODT; _cmd.Parameters.Add("@Mobile", SqlDbType.Text).Value = hanghoa.Mobile; _cmd.Parameters.Add("@Email", SqlDbType.Text).Value = hanghoa.Email; _cmd.Parameters.Add("@TaiKhoan", SqlDbType.Text).Value = hanghoa.TaiKhoan; _cmd.Parameters.Add("@NganHang", SqlDbType.Text).Value = hanghoa.NganHang; _cmd.Parameters.Add("@GioiHanNo", SqlDbType.Money).Value = Convert.ToDecimal(hanghoa.GioiHanNo); _cmd.Parameters.Add("@NoHienTai", SqlDbType.Money).Value = Convert.ToDecimal(hanghoa.NoHienTai); _cmd.Parameters.Add("@ChietKhau", SqlDbType.Float).Value = Convert.ToDouble(hanghoa.ChietKhau); _cmd.Parameters.Add("@NguoiLienHe", SqlDbType.Text).Value = hanghoa.NguoiLienHe; _cmd.Parameters.Add("@Website", SqlDbType.Text).Value = hanghoa.Website; _cmd.Parameters.Add("@ConQuanLy", SqlDbType.Bit).Value = hanghoa.ConQuanLy; _cmd.Parameters.Add("@ChucVu", SqlDbType.Text).Value = hanghoa.ChucVu; OpenConn(); var i = _cmd.ExecuteNonQuery(); CloseConn(); return(true); } else { return(false); } }