예제 #1
0
        private void buttonThem_Click(object sender, EventArgs e)
        {
            //co hieu
            bool   cohieu = true;
            string ma     = textBoxMaBP.Text;
            string ten    = textBoxTenBP.Text;

            //xu ly
            if (ma != "")
            {
                for (int i = 0; i < bp.Count; i++)
                {
                    if (ma == bp[i].MaBP)
                    {
                        labelThongBao.Text = "Mã nhập không được trùng với mã khác! ";
                        cohieu             = false;
                        break;
                    }
                }
            }
            if (ma != "" && ten != "" && cohieu == true)
            {
                bool Them = XL_BoPhan.ThemBoPhan(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();
                }
            }
        }
예제 #2
0
        private void simpleButtonThem_Click(object sender, EventArgs e)
        {
            load(XL_BoPhan.LayDuLieuBoPhan());
            //
            FormBoPhanThem them = new FormBoPhanThem(bp);

            them.ShowDialog();
            //cap nhat csdl
            var bangbophan = XL_BoPhan.LayDuLieuBoPhan();

            gridControl1.DataSource = bangbophan;
        }
예제 #3
0
 void load(DataTable bang)
 {
     if (bp.Count != 0)
     {
         for (int i = 0; i < bp.Count; i++)
         {
             bp.RemoveAt(i);
         }
         var bangbophan = bang;
         bp = XL_BoPhan.ChuyenDoiDTOBoPhan(bangbophan);
     }
 }
예제 #4
0
        private void ToolStripMenuItemSua_Click(object sender, EventArgs e)
        {
            load(XL_BoPhan.LayDuLieuBoPhan());
            //
            FormBoPhanSua sua = new FormBoPhanSua(bp);

            sua.ShowDialog();
            //cap nhat csdl
            var bangbophan = XL_BoPhan.LayDuLieuBoPhan();

            gridControl1.DataSource = bangbophan;
        }
예제 #5
0
        private void FormBoPhan_Load(object sender, EventArgs e)
        {
            var bangbophan = XL_BoPhan.LayDuLieuBoPhan();

            gridControl1.DataSource = bangbophan;
            bp = XL_BoPhan.ChuyenDoiDTOBoPhan(bangbophan);
            //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;
                }
            }
        }
예제 #6
0
        private void buttonXoa_Click(object sender, EventArgs e)
        {
            string ma = comboBoxBP.Text;

            if (ma != "")
            {
                bool Xoa = XL_BoPhan.XoaBoPhan(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();
                }
            }
        }
예제 #7
0
        private void buttonSua_Click(object sender, EventArgs e)
        {
            string ma  = comboBoxMaBP.Text;
            string ten = textBoxTenBP.Text;

            if (ma != "" && ten != "")
            {
                bool Sua = XL_BoPhan.SuaBoPhan(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();
                }
            }
        }