Ejemplo n.º 1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (txtMaChucVu.Text.Equals("") || txtTenChucVu.Text.Equals(""))
            {
                MessageBox.Show("Vui lòng chọn đối tượng cần sửa!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (!txtMaChucVu.Text.Equals("") && !txtTenChucVu.Text.Equals(""))
            {
                //MessageBox.Show(CV.MaChucVu);
                string err = "";

                if (!Regex.IsMatch(txtTenChucVu.Text, pTencv))
                {
                    err += "\n Tên chức vụ là các ký tự Alphabet ";
                }

                if (err == "")
                {
                    string[] param = lopcv.layThongTinCVu(txtMaChucVu.Text);
                    if (param[0] == null)
                    {
                        MessageBox.Show("Không được thay đổi mã chức vụ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //clearText();
                        return;
                    }
                    CV.MaChucVu  = txtMaChucVu.Text;
                    CV.TenChucVu = txtTenChucVu.Text;
                    lopcv.Sua(CV.MaChucVu, CV.TenChucVu);
                    MessageBox.Show("Sửa thành công!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadData();
                    btnNhapLai_Click(sender, e);
                }
                else
                {
                    MessageBox.Show(err, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }