Ejemplo n.º 1
0
        private void buttonXoa_Click(object sender, EventArgs e)
        {
            Nhom nhom = new Nhom();

            try
            {
                string ma = Convert.ToString(txtMa.Text);
                if ((MessageBox.Show("Are You Sure You Want To Delete This Nhom", "Delete Nhom", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                {
                    if (nhom.deleteNhom(ma))
                    {
                        MessageBox.Show("Nhom Deleted", "Delete Nhom", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtMa.Text  = null;
                        txtTen.Text = null;
                    }
                    else
                    {
                        MessageBox.Show("Nhom Enter A Valid ID", "Delete Nhom", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Please Enter A Valid ID", "Delete Nhom", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            getdata();
            clear();
        }
Ejemplo n.º 2
0
        private void buttonSua_Click(object sender, EventArgs e)
        {
            Nhom   nhom  = new Nhom();
            string ma    = txtMa.Text;
            string tenn  = txtTen.Text;
            string tenpb = ComboBoxPhongBan.Text;

            if (verif())
            {
                try
                {
                    if (nhom.UpdateNhom(ma, tenn, tenpb))
                    {
                        MessageBox.Show("Nhom Information Update", "Edit Nhom", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Error", "Edit Nhom", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Edit Nhom", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Empty Fields", "Edit Nhom", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            getdata();
        }
Ejemplo n.º 3
0
        private void ButtonXoa_Click(object sender, EventArgs e)
        {
            BoPhan   bophan   = new BoPhan();
            PhongBan phongban = new PhongBan();
            Nhom     nhom     = new Nhom();

            try
            {
                string ma = Convert.ToString(txtMa.Text);
                if ((MessageBox.Show("Are You Sure You Want To Delete This BoPhan", "Delete BoPhan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                {
                    if (bophan.deleteBoPhan(ma))
                    {
                        MessageBox.Show("BoPhan Deleted", "Delete BoPhan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtMa.Text  = null;
                        txtTen.Text = null;
                    }
                    else
                    {
                        MessageBox.Show("BoPhan Enter A Valid ID", "Delete BoPhan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Please Enter A Valid ID", "Delete BoPhan", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            getdata();
        }
Ejemplo n.º 4
0
        private void dgvNhom_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int  n       = dgvNhom.CurrentCell.RowIndex;
            int  iMaNhom = Convert.ToInt32(dgvNhom.Rows[n].Cells[0].Value.ToString());
            Nhom nh      = dbs.Nhoms.First(p => p.MaNhom == iMaNhom);

            txtSV1.Text = nh.SV1;
            txtSV2.Text = nh.SV2;
        }
Ejemplo n.º 5
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DialogResult tl = MessageBox.Show("Bạn Muốn Xóa ?", "Thông Báo", MessageBoxButtons.OKCancel);

            if (tl == DialogResult.OK)
            {
                int n       = dgvNhom.CurrentCell.RowIndex;
                int iMaNhom = Convert.ToInt32(dgvNhom.Rows[n].Cells[0].Value.ToString());

                if (dbs.PhanCongs.FirstOrDefault(p => p.MaNhom == iMaNhom) != null)
                {
                    MessageBox.Show("Nhóm Này Đang Được Phân Công ,Không Thể Xóa", "Thông Báo");
                }
                else
                {
                    Nhom nh = dbs.Nhoms.First(p => p.MaNhom == iMaNhom);
                    dbs.Nhoms.DeleteOnSubmit(nh);
                    dbs.SubmitChanges();
                    LoadData();
                }
            }
        }
Ejemplo n.º 6
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            DialogResult tl = MessageBox.Show("Bạn Muốn Lưu ?", "Thông Báo", MessageBoxButtons.OKCancel);

            if (tl == DialogResult.OK)
            {
                Nhom nh;
                if (flag)
                {
                    nh = new Nhom();
                    if (dbs.Nhoms.Count() == 0)
                    {
                        nh.myIndex = 1;
                    }
                    else
                    {
                        nh.myIndex = Convert.ToInt32(dbs.Nhoms.Max(p => p.myIndex)) + 1;
                    }
                    nh.MaNhom = Convert.ToInt32(nh.myIndex) + 1;
                }
                else
                {
                    int n       = dgvNhom.CurrentCell.RowIndex;
                    int iMaNhom = Convert.ToInt32(dgvNhom.Rows[n].Cells[0].Value.ToString());
                    nh = dbs.Nhoms.FirstOrDefault(p => p.MaNhom == iMaNhom);
                }

                nh.SV1 = txtSV1.Text;
                nh.SV2 = txtSV2.Text;

                if (flag)
                {
                    dbs.Nhoms.InsertOnSubmit(nh);
                }
                dbs.SubmitChanges();
            }

            LoadData();
        }
Ejemplo n.º 7
0
        private void buttonThem_Click(object sender, EventArgs e)
        {
            Nhom   nhom  = new Nhom();
            string ma    = txtMa.Text;
            string tenn  = txtTen.Text;
            string tenpb = ComboBoxPhongBan.Text;

            if (verif() && kiemtraNhom(ma) && kiemtraBoPhan1(tenn))
            {
                if (nhom.insertNhom(ma, tenn, tenpb))
                {
                    MessageBox.Show("New Nhóm Added", "Add Nhóm", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Error", "Add Nhóm", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Empty Fields", "Add Nhóm", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            getdata();
        }