private void txtLuu_Click(object sender, EventArgs e) { if (txtTen.Text.Length == 0) { errorProvider1.SetError(txtTen, "Không được để trống"); } else { errorProvider1.SetError(txtTen, ""); } if (errorProvider1.GetError(txtTen).Length == 0) { var cc = new NhaCungCap(); cc.TenNCC = txtTen.Text ?? ""; cc.DiaChi = txtdiachi.Text ?? ""; cc.DienThoai = txtSodienthoai.Text ?? ""; cc.Fax = txtFax.Text ?? ""; cc.MaSoThue = txtMathue.Text ?? ""; if (NhaCungCapBus.CreateNhaCC(cc)) { MessageBox.Show("Thêm mới thánh công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); _frmCC.data = NhaCungCapBus.GetListNhaCC(); _frmCC.dgvNhaCC.DataSource = _frmCC.data; this.Close(); } else { MessageBox.Show("Thêm mới thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public FrmNhaCC() { InitializeComponent(); data = NhaCungCapBus.GetListNhaCC(); dataFilter = data; }
private void btnDelete_Click(object sender, EventArgs e) { var cc = dgvNhaCC.CurrentRow.DataBoundItem as NhaCungCap; DialogResult result = MessageBox.Show("Bạn có chắc chắn xóa", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { if (NhaCungCapBus.DeleteNhaCC(cc.MaNCC)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); data = NhaCungCapBus.GetListNhaCC(); dgvNhaCC.DataSource = data; } else { MessageBox.Show("Xóa thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void txtLuu_Click(object sender, EventArgs e) { cc.TenNCC = txtTen.Text ?? ""; cc.DienThoai = txtSodienthoai.Text ?? ""; cc.MaSoThue = txtMathue.Text ?? ""; cc.Fax = txtFax.Text ?? ""; cc.DiaChi = txtdiachi.Text ?? ""; if (NhaCungCapBus.UpdateNhaCC(cc)) { MessageBox.Show("Cập nhật thánh công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); _frmCC.data = NhaCungCapBus.GetListNhaCC(); _frmCC.dgvNhaCC.DataSource = _frmCC.data; this.Close(); } else { MessageBox.Show("Cập nhật thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void FrmCreateNhaCC_Load(object sender, EventArgs e) { txtMa.Text = NhaCungCapBus.GetMaNhaCCNext().ToString(); }