private void btnLuu_Click(object sender, EventArgs e) { string ten = this.txtTenNCC.Text; string diaChi = this.txtAddress.Text; string email = this.txtEmail.Text; string sdt = this.txtPhone.Text; if (ten == "" || diaChi == "" || email == "" || sdt == "") { MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Entity_NhaCungCap _ncc = new Entity_NhaCungCap(Int32.Parse(this.txtID.Text), ten, sdt, email, diaChi); if (ncc.insertNCC(_ncc) == true) { MessageBox.Show("Thêm thành công!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.gwNhacCungCap.DataSource = ncc.getData(); this.btnLuu.Enabled = false; } else { MessageBox.Show("Có lỗi xảy ra, không thể thêm mới nhà cung cấp!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.btnLuu.Enabled = false; } }
public bool insertNCC(Entity_NhaCungCap _ncc) { try { const string strSQL = "SP_INSERT_NCC"; string[] pNames = { "@id", "@ten", "@email", "@sdt", "@diaChi" }; object[] pValues = { _ncc.NccId, _ncc.Ten, _ncc.Email, _ncc.Sdt, _ncc.DiaChi }; int count = con.ExecuteStoredProcedure(strSQL, pNames, pValues); if (count >= 0) { return(true); } else { return(false); } } catch { return(false); } }
public bool insertNCC(Entity_NhaCungCap _ncc) { return(ncc.insertNCC(_ncc)); }