public bool insertKho(DTOKho hanghoa) { string query = string.Format($"select * from KHO where MaKho='{hanghoa.MaKho}'"); if (ExecSelectedCount(query) == 0) { var _cmd = new SqlCommand(); _cmd.CommandText = "insert into KHO values (@MaKho,@TenKho,@DiaChi,@Fax,@SODT,@Mobile,@Email,@NguoiQuanLy,@NguoiLienHe,@DienGiai,@ConQuanLy)"; _cmd.CommandType = CommandType.Text; _cmd.Connection = connection; _cmd.Parameters.Add("@MaKho", SqlDbType.Text).Value = hanghoa.MaKho; _cmd.Parameters.Add("@TenKho", SqlDbType.Text).Value = hanghoa.TenKho; _cmd.Parameters.Add("@DiaChi", SqlDbType.Text).Value = hanghoa.DiaChi; _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("@NguoiQuanLy", SqlDbType.Text).Value = hanghoa.NguoiQuanLy; _cmd.Parameters.Add("@NguoiLienHe", SqlDbType.Text).Value = hanghoa.NguoiLienHe; _cmd.Parameters.Add("@DienGiai", SqlDbType.Text).Value = hanghoa.DienGiai; _cmd.Parameters.Add("@ConQuanLy", SqlDbType.Bit).Value = hanghoa.ConQuanLy; OpenConn(); var i = _cmd.ExecuteNonQuery(); CloseConn(); return(true); } else { return(false); } }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { BUSKhoHang b = new BUSKhoHang(); DTOKho d = new DTOKho(); d.MaKho = textEdit1.Text; d.TenKho = textEdit2.Text; d.NguoiLienHe = textEdit3.Text; d.DiaChi = textEdit4.Text; d.SODT = textEdit5.Text; d.Mobile = textEdit6.Text; d.Fax = textEdit7.Text; d.Email = textEdit8.Text; d.NguoiQuanLy = textEdit9.Text; d.DienGiai = textEdit10.Text; d.ConQuanLy = checkEdit1.Checked; if (isAddForm) { if (b.insertKho(d)) { MessageBox.Show("Thao tác thành công"); } else { MessageBox.Show("Thao tác không thành công"); } } else { b.updateKho(d); MessageBox.Show("Thao tác hóa thành công"); } }
public int updateKho(DTOKho hanghoa) { DALKhoHang um = new DALKhoHang(); int dt = um.updateKho(hanghoa); return(dt); }
public bool insertKho(DTOKho hanghoa) { DALKhoHang um = new DALKhoHang(); bool dt = um.insertKho(hanghoa); return(dt); }
public DTOKho getKhoDetail(string mahanghoa) { DALKhoHang um = new DALKhoHang(); DataTable dt = um.getKhoDetail(mahanghoa); DTOKho a = new DTOKho(); a.MaKho = dt.Rows[0]["MaKho"].ToString(); a.TenKho = dt.Rows[0]["TenKho"].ToString(); a.DiaChi = dt.Rows[0]["DiaChi"].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.NguoiQuanLy = dt.Rows[0]["NguoiQuanLy"].ToString(); a.NguoiLienHe = dt.Rows[0]["NguoiLienHe"].ToString(); a.DienGiai = dt.Rows[0]["DienGiai"].ToString(); a.ConQuanLy = Convert.ToBoolean(dt.Rows[0]["ConQuanLy"].ToString()); return(a); }
private void frmKho_Add_Load(object sender, EventArgs e) { if (!isAddForm) { BUSKhoHang b = new BUSKhoHang(); DTOKho dtoHangHoa = b.getKhoDetail(gotID); textEdit1.Text = dtoHangHoa.MaKho; textEdit2.Text = dtoHangHoa.TenKho; textEdit3.Text = dtoHangHoa.NguoiLienHe; textEdit4.Text = dtoHangHoa.DiaChi; textEdit5.Text = dtoHangHoa.SODT; textEdit6.Text = dtoHangHoa.Mobile; textEdit7.Text = dtoHangHoa.Fax; textEdit8.Text = dtoHangHoa.Email; textEdit9.Text = dtoHangHoa.NguoiQuanLy; textEdit10.Text = dtoHangHoa.DienGiai; checkEdit1.Checked = dtoHangHoa.ConQuanLy; } else { textEdit1.ReadOnly = false; } }
public int updateKho(DTOKho hanghoa) { var _cmd = new SqlCommand(); _cmd.CommandText = "update KHO set MaKho=@MaKho,TenKho=@TenKho,DiaChi=@DiaChi,Fax=@Fax,SODT=@SODT,Mobile=@Mobile,NguoiQuanLy=@NguoiQuanLy,NguoiLienHe=@NguoiLienHe,DienGiai=@DienGiai,ConQuanLy=@ConQuanLy where MaKho=@MaKho "; _cmd.CommandType = CommandType.Text; _cmd.Connection = connection; _cmd.Parameters.Add("@MaKho", SqlDbType.NVarChar).Value = hanghoa.MaKho; _cmd.Parameters.Add("@TenKho", SqlDbType.NVarChar).Value = hanghoa.TenKho; _cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar).Value = hanghoa.DiaChi; _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("@NguoiQuanLy", SqlDbType.NVarChar).Value = hanghoa.NguoiQuanLy; _cmd.Parameters.Add("@NguoiLienHe", SqlDbType.NVarChar).Value = hanghoa.NguoiLienHe; _cmd.Parameters.Add("@DienGiai", SqlDbType.NVarChar).Value = hanghoa.DienGiai; _cmd.Parameters.Add("@ConQuanLy", SqlDbType.Bit).Value = hanghoa.ConQuanLy; OpenConn(); var i = _cmd.ExecuteNonQuery(); CloseConn(); return(i); }