private void buttonThem_Click(object sender, EventArgs e) { //co hieu bool cohieu = true; string ma = textBoxMaDonViTinh.Text; string ten = textBoxTenDonViTinh.Text; //xu ly if (ma != "") { for (int i = 0; i < dvt.Count; i++) { if (ma == dvt[i].MaDonViTinh) { cohieu = false; break; } } } if (ma != "" && ten != "" && cohieu == true) { bool Them = XL_DonViTinh.ThemDonViTinh(ma, ten); if (Them) { MessageBox.Show("Thêm thành công!"); this.Close(); } else { MessageBox.Show("Thêm thất bại!"); this.Close(); } } }
private void simpleButtonThem_Click(object sender, EventArgs e) { load(XL_DonViTinh.LayDuLieuDonViTinh()); // FormDonViTinhThem them = new FormDonViTinhThem(dvt); them.ShowDialog(); //cap nhat csdl var bangdonvitinh = XL_DonViTinh.LayDuLieuDonViTinh(); gridControl1.DataSource = bangdonvitinh; }
void load(DataTable bang) { if (dvt.Count != 0) { for (int i = 0; i < dvt.Count; i++) { dvt.RemoveAt(i); } var bangdonvitinh = bang; dvt = XL_DonViTinh.ChuyenDoiDTODonViTinh(bangdonvitinh); } }
private void ToolStripMenuItemSua_Click(object sender, EventArgs e) { load(XL_DonViTinh.LayDuLieuDonViTinh()); // FormDonViTinhSua sua = new FormDonViTinhSua(dvt); sua.ShowDialog(); //cap nhat csdl var bangdonvitinh = XL_DonViTinh.LayDuLieuDonViTinh(); gridControl1.DataSource = bangdonvitinh; }
private void FormDonViTinh_Load(object sender, EventArgs e) { var bangdonvitinh = XL_DonViTinh.LayDuLieuDonViTinh(); gridControl1.DataSource = bangdonvitinh; dvt = XL_DonViTinh.ChuyenDoiDTODonViTinh(bangdonvitinh); //phan quyen button for (int i = 0; i < vtcn.Count; i++) { if (vtcn[i].TenTrongHeThong == this.Tag.ToString()) { if (vtcn[i].Them == true) { simpleButtonThem.Enabled = true; } if (vtcn[i].Xoa == true) { simpleButtonXoa.Enabled = true; } if (vtcn[i].Sua == true) { simpleButtonSua.Enabled = true; } break; } } //phan quyen contextMenuStrip for (int i = 0; i < vtcn.Count; i++) { if (vtcn[i].TenTrongHeThong == this.Tag.ToString()) { for (int j = 0; j < contextMenuStrip1.Items.Count; j++) { if (contextMenuStrip1.Items[j].Text == "Thêm" && vtcn[i].Them == true) { contextMenuStrip1.Items[j].Enabled = true; } if (contextMenuStrip1.Items[j].Text == "Xóa" && vtcn[i].Xoa == true) { contextMenuStrip1.Items[j].Enabled = true; } if (contextMenuStrip1.Items[j].Text == "Sửa" && vtcn[i].Sua == true) { contextMenuStrip1.Items[j].Enabled = true; } } break; } } }
private void buttonXoa_Click(object sender, EventArgs e) { string ma = comboBoxMaDonViTinh.Text; if (ma != "") { bool Xoa = XL_DonViTinh.XoaDonViTinh(ma); if (Xoa) { MessageBox.Show("Xóa thành công !"); this.Close(); } else { MessageBox.Show("Xóa không thành công !"); this.Close(); } } }
private void buttonSua_Click(object sender, EventArgs e) { string ma = comboBoxMaDonViTinh.Text; string ten = textBoxTenDonViTinh.Text; if (ma != "" && ten != "") { bool Sua = XL_DonViTinh.SuaDonViTinh(ma, ten); if (Sua) { MessageBox.Show("Cập nhật thành công !"); this.Close(); } else { MessageBox.Show("Cập nhật thất bại !"); this.Close(); } } }