private void btthem_Click(object sender, EventArgs e) { if (txttenncc.Text == "" || txtsdt.Text == "" || txtdiachi.Text == "" || IsNumber(txtsdt.Text) == false) { MessageBox.Show("Thông tin chưa đầy đủ hoặc sai định dạng, vui lòng kiểm tra lại!"); } else { Nhacungcap_DTO nccDTO = new Nhacungcap_DTO(); nccDTO.SMancc = txtmancc.Text; nccDTO.STencc = txttenncc.Text; nccDTO.SSodienthoaincc = txtsdt.Text; nccDTO.SDiachincc = txtdiachi.Text; if (Nhacungcap_BUS.Themncc(nccDTO) == true) { MessageBox.Show("Lưu thành công"); LoadDgvNhacungcap(); } else { MessageBox.Show("Thất bại!"); } } }
private void LoadDgvNhacungcap() { List <Nhacungcap_DTO> lstncc = Nhacungcap_BUS.LoadNhacungcap(); dgvncc.DataSource = lstncc; dgvncc.Columns["SMancc"].HeaderText = "Mã NCC"; dgvncc.Columns["STencc"].HeaderText = "Tên NCC"; dgvncc.Columns["SSodienthoaincc"].HeaderText = "SĐT"; dgvncc.Columns["SDiachincc"].HeaderText = "Địa chỉ"; dgvncc.Columns["SMancc"].Width = 50; dgvncc.Columns["SDiachincc"].Width = 300; }
private void btxoa_Click(object sender, EventArgs e) { Nhacungcap_DTO nccDTO = new Nhacungcap_DTO(); nccDTO.SMancc = txtmancc.Text; if (Nhacungcap_BUS.Xoancc(nccDTO) == true) { MessageBox.Show("Đã xóa"); LoadDgvNhacungcap(); } else { MessageBox.Show("Thất bại!"); } }
private void QLNCC_Load(object sender, EventArgs e) { txttenncc.Enabled = false; txtdiachi.Enabled = false; txtsdt.Enabled = false; txtmancc.Enabled = false; LoadDgvNhacungcap(); try { Nhacungcap_BUS x = new Nhacungcap_BUS(); txtmancc.Text = x.XuLyMaNCC(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//private void dgvncc_CellContentClick(object sender, DataGridViewCellEventArgs e) //{ // DataGridViewRow dr1 = dgvncc.SelectedRows[0]; // txtmancc.Text = dr1.Cells["SMancc"].Value.ToString(); // txttenncc.Text = dr1.Cells["STencc"].Value.ToString(); // txtsdt.Text = dr1.Cells["SSodienthoaincc"].Value.ToString(); // txtdiachi.Text = dr1.Cells["SDiachincc"].Value.ToString(); //} private void dtsua_Click(object sender, EventArgs e) { Nhacungcap_DTO nccDTO = new Nhacungcap_DTO(); nccDTO.SMancc = txtmancc.Text; nccDTO.STencc = txttenncc.Text; nccDTO.SSodienthoaincc = txtsdt.Text; nccDTO.SDiachincc = txtdiachi.Text; if (Nhacungcap_BUS.Suancc(nccDTO) == true) { MessageBox.Show("Cập nhật thành công"); LoadDgvNhacungcap(); } else { MessageBox.Show("Thất bại!"); } }