コード例 #1
0
        private void btnAddSub_Click(object sender, EventArgs e)
        {
            try
            {
                this.chucVu.insert(this.txtMaCV.Text, this.txtTenCV.Text);
                ShowMessageBox.information("Thêm thành công");
                loadTableChucVu();//Load lai bang chuc vu
            }
            catch (InsertException CVEx)
            {
                ShowMessageBox.erorr(CVEx.Message, "Lỗi");
            }
            catch (Exception ex)
            {
                ShowMessageBox.erorr(ex.Message, "Lỗi");
            }

            //Reload table ChucVu
            loadTableChucVu();

            //Remove btnCancelAdd and after that add btnAdd
            this.btnCancelAdd.Visible = false;
            this.btnAddSub.Visible    = false;
            //Turn on comeback
            restartAllBtnFunctuinMain();
        }
コード例 #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtMaCVTim.Text != string.Empty || txtMaCVTim.Text.Equals("nhập mã chức vụ tìm..."))
            {
                try
                {
                    DataRow CVSearch = this.chucVu.find(txtMaCVTim.Text);

                    if (CVSearch != null)
                    {
                        txtMaCV.Text    = CVSearch[0].ToString();
                        txtTenCV.Text   = CVSearch[1].ToString();
                        txtMaCVTim.Text = "nhập mã chức vụ tìm...";
                    }
                    else
                    {
                        ShowMessageBox.erorr("Không tìm thấy chức vụ có mã là " + txtMaCVTim.Text, "Thông báo");
                        txtMaCVTim.Focus();
                    }
                }
                catch (Exception ex)
                {
                    ShowMessageBox.erorr(ex.Message, "Lỗi");
                }
            }
            else
            {
                errorTxt.SetError(txtMaCVTim, "Chưa nhập dữ liệu để tìm");
            }
        }
コード例 #3
0
 /*
  *  ________________ EVENT CLICK ________________
  */
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         this.adminM.drAdmin = adminM.login(txtUsername.Text, txtPassword.Text);
         ShowMessageBox.information("Đăng nhập thành công", "Xin chào");
         this.Close();
     }
     catch (FindException findEx)
     {
         ShowMessageBox.erorr(findEx.Message, "Đăng nhập thất bại");
     }
 }
コード例 #4
0
        private void btnSubUpdate_Click(object sender, EventArgs e)
        {
            if (inputAllNotEmpty())               //Kiem tra tat ca thong tin nhan vien muon cap nhat da nhap day du
            {
                this.AcceptButton = btnSubUpdate; //set acceptButton

                int    maGioiTinh = int.Parse((cbGioTinh.SelectedItem as ComboboxItem).Value.ToString());
                string maPB       = (cbPhongBan.SelectedItem as ComboboxItem).Value.ToString();
                string maCV       = (cbChucVu.SelectedItem as ComboboxItem).Value.ToString();
                string maTDHV     = (cbTrinhDoHocVan.SelectedItem as ComboboxItem).Value.ToString();
                int    bacLuong   = int.Parse((cbLuong.SelectedItem as ComboboxItem).Value.ToString());
                string maHD       = (cbLoaiHopDong.SelectedItem as ComboboxItem).Value.ToString();
                string ngaySinh   = dtpNgaySinh.Value.ToString("yyyy-MM-dd");;

                try
                {
                    //Insert
                    this.nhanVienM.update(txtMaNV.Text, txtHoTen.Text, txtSDT.Text, maGioiTinh, ngaySinh, txtDanToc.Text, txtQueQuan.Text,
                                          txtDiaChi.Text, txtCMND.Text, maPB, maCV, maTDHV, bacLuong, maHD);

                    ShowMessageBox.information("Cập nhật thông tin nhân viên có mã là " + txtMaNV.Text + " thành công", "Thông báo");

                    //Reset table NhanVien
                    loadTableNhanVien();
                    //reset all button function main
                    resetAllButton();
                    //clear
                    clearAllInput();

                    txtMaNV.Enabled = true;

                    //visible
                    btnSubUpdate.Visible    = false;
                    btnCancelUpdate.Visible = false;
                }
                catch (InsertException insertEx)
                {
                    ShowMessageBox.erorr(insertEx.Message);
                }
                catch (Exception ex)
                {
                    ShowMessageBox.erorr(ex.Message);
                }
            }
            else
            {
                ShowMessageBox.erorr("ComboBox dữ liệu chưa được bạn chọn \nHoặc còn thiếu một số thông tin", "Lỗi");
            }
        }
コード例 #5
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                DataRow drResulut = this.nhanVienM.find(txtMaNVTim.Text);

                //Load du lieu len tren form khi tim thay nhanvien voi ma truyen vao
                loadAllTxt(drResulut);
                txtMaNV.Enabled = false;
            }
            catch (FindException findEx)
            {
                ShowMessageBox.erorr(findEx.Message);
            }
        }
コード例 #6
0
 //Load form NhanVien main
 private void frmChucVu_Load(object sender, EventArgs e)
 {
     try
     {
         loadTableChucVu();
     }
     catch (SelectException cvSeEx)
     {
         ShowMessageBox.erorr(cvSeEx.Message, "Lỗi nghiêm trọng");
         //Khoa tat cac nut function khi gap loi
         enbledAllBtnFunctuinMain();
     }
     catch (Exception ex)
     {
         ShowMessageBox.erorr(ex.Message, "Lỗi nghiêm trọng");
         //Khoa tat cac nut function khi gap loi
         enbledAllBtnFunctuinMain();
     }
 }
コード例 #7
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!isTxtEmpty())
            {
                DialogResult result = new DialogResult();

                result = MessageBox.Show(
                    "Bạn có chắc chắn muốn xoá Chức Vụ " + txtTenCV.Text + " không?",
                    "Thông báo",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    try
                    {
                        //Thuc thu xoa chuc vu
                        this.chucVu.delete(txtMaCV.Text);

                        //reload table chuc vu
                        loadTableChucVu();
                        ShowMessageBox.information("Xoá thành công");

                        clearTxtInput();
                    }
                    catch (DeleteException cvDelEx)
                    {
                        ShowMessageBox.erorr(cvDelEx.Message);
                    }
                    catch (Exception ex)
                    {
                        ShowMessageBox.erorr(ex.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Dữ liệu Mã Chức Vụ đang còn trống", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtMaNV.Text != string.Empty)
            {
                try
                {
                    DataRow dtResult = nhanVienM.find(txtMaNV.Text);
                    //set
                    this.dangThaoTac = true;

                    //Visible
                    btnSubUpdate.Visible    = true;
                    btnCancelUpdate.Visible = true;
                    btnUpdate.Visible       = false;

                    //Enabled
                    btnSearch.Enabled   = false;
                    btnDelete.Enabled   = false;
                    btnAdd.Enabled      = false;
                    dgvNhanVien.Enabled = false;
                    txtMaNV.Enabled     = false;

                    //Tai thong tin nhan vien mua sua vao form
                    loadAllTxt(dtResult);
                }
                catch (FindException findEx)
                {
                    ShowMessageBox.erorr(findEx.Message);
                }
                catch (Exception ex)
                {
                    ShowMessageBox.erorr(ex.Message);
                }
            }
            else
            {
                ShowMessageBox.erorr("Vui lòng chọn hoặc nhập thông tin nhân viên cần cập nhật", "Thông tin thiếu");
            }
        }
コード例 #9
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (txtMaNV.Text != string.Empty)
            {
                DialogResult result = new DialogResult();
                result = MessageBox.Show("Bạn có muốn xoá nhân viên có mã là " + txtMaNV.Text + " không?",
                                         "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result != DialogResult.No)
                {
                    try
                    {
                        nhanVienM.delete(txtMaNV.Text);

                        //Thong bao
                        ShowMessageBox.information("Xoá thông tin của nhân viên thông");

                        //reload table NhanVien
                        loadTableNhanVien();

                        //Clear
                        clearAllInput();
                    }
                    catch (DeleteException delEx)
                    {
                        ShowMessageBox.erorr(delEx.Message);
                    }
                    catch (Exception ex)
                    {
                        ShowMessageBox.erorr(ex.Message);
                    }
                }
            }
            else
            {
                ShowMessageBox.erorr("Vui lòng nhập thông tin mã Nhân Viên muốn xoá", "Thông tin thiếu");
            }
        }