Пример #1
0
        private void buttonXoa_Click(object sender, EventArgs e)
        {
            PhongBan phongban = new PhongBan();

            try
            {
                string ma = Convert.ToString(txtMa.Text);
                if ((MessageBox.Show("Are You Sure You Want To Delete This PhongBan", "Delete PhongBan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                {
                    if (phongban.deletePhongBan(ma))
                    {
                        MessageBox.Show("PhongBan Deleted", "Delete PhongBan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtMa.Text  = null;
                        txtTen.Text = null;
                    }
                    else
                    {
                        MessageBox.Show("PhongBan Enter A Valid ID", "Delete PhongBan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Please Enter A Valid ID", "Delete PhongBan", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            getdata();
            clear();
        }
Пример #2
0
        private void buttonSua_Click(object sender, EventArgs e)
        {
            PhongBan phongban = new PhongBan();
            string   ma       = txtMa.Text;
            string   tenpb    = txtTen.Text;
            string   tenbp    = ComboBoxBoPhan.Text;

            if (verif())
            {
                try
                {
                    if (phongban.UpdatePhongBan(ma, tenpb, tenbp))
                    {
                        MessageBox.Show("PhongBan Information Update", "Edit PhongBan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Error", "Edit PhongBan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Edit PhongBan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Empty Fields", "Edit PhongBan", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            getdata();
        }
Пример #3
0
        private void buttonThem_Click(object sender, EventArgs e)
        {
            PhongBan phongban = new PhongBan();
            string   ma       = txtMa.Text;
            string   tenpb    = txtTen.Text;
            string   tenbp    = ComboBoxBoPhan.Text;

            if (verif() && kiemtraPhongBan(ma) && kiemtraBoPhan1(tenpb))
            {
                if (phongban.insertPhongBan(ma, tenpb, tenbp))
                {
                    MessageBox.Show("New Phòng Ban Added", "Add Phòng Ban", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Error", "Add Phòng Ban", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Empty Fields", "Add Phòng Ban", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            getdata();
        }
Пример #4
0
        private void buttonThem_Click(object sender, EventArgs e)
        {
            NguoiLaoDong nguoilaodong = new NguoiLaoDong();
            string       ma           = txtMa.Text;

            if (radioButton1.Checked == true)
            {
                if (verif() && kiemtra(ma))
                {
                    int      l              = ma.Length;
                    string   hoten          = txtTen.Text;
                    DateTime ngaysinh       = dateTimeNgaysinh.Value;
                    string   dienthoai      = txtSDT.Text;
                    string   diachi         = txtDCtamtru.Text;
                    string   chucvu         = ComboBoxChucVu.Text;
                    string   chuyenmon      = ComboBoxChuyenMon.Text;
                    string   donvitructhuoc = ComboBoxDVTT.Text;
                    string   trinhdo        = ComboBoxTrinhDo.Text;
                    string   gioitinh       = "Nam";
                    if (radioButtonFemale.Checked)
                    {
                        gioitinh = "Nữ";
                    }
                    MemoryStream hinhanh   = new MemoryStream();
                    int          born_year = dateTimeNgaysinh.Value.Year;
                    int          this_year = DateTime.Now.Year;
                    if (((this_year - born_year) < 18) || ((this_year - born_year) > 100))
                    {
                        MessageBox.Show("The KySu Age Must Be Between 18 and 100 year", "Invalid Birth Date", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else if (l > 2 && ((ma[0].ToString() == "K" && ma[1].ToString() == "S") || (ma[0].ToString() == "Q" && ma[1].ToString() == "L") && kiemtra(ma)))
                    {
                        pictureBoxImage.Image.Save(hinhanh, pictureBoxImage.Image.RawFormat);

                        if (nguoilaodong.insertNguoiLaoDong(ma, hoten, ngaysinh, gioitinh, diachi, dienthoai, trinhdo, chucvu, chuyenmon, donvitructhuoc, hinhanh))
                        {
                            MessageBox.Show("New Kỹ Sư Added", "Add Kỹ Sư", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error", "Add Kỹ Sư", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Empty Fields", "Add Kỹ Sư", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Empty Fields", "Add Kỹ Sư", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                getdata();
                labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount);
            }
            if (radioButton2.Checked == true)
            {
                MyDB mydb = new MyDB();
                mydb.openConnection();
                PhongBan pb = new PhongBan();
                if (verif() && kiemtra(ma))
                {
                    int      l              = ma.Length;
                    string   hoten          = txtTen.Text;
                    DateTime ngaysinh       = dateTimeNgaysinh.Value;
                    string   dienthoai      = txtSDT.Text;
                    string   diachi         = txtDCtamtru.Text;
                    string   chucvu         = ComboBoxChucVu.Text;
                    string   chuyenmon      = ComboBoxChuyenMon.Text;
                    string   donvitructhuoc = ComboBoxDVTT.Text;
                    string   trinhdo        = ComboBoxTrinhDo.Text;
                    string   gioitinh       = "Nam";
                    if (radioButtonFemale.Checked)
                    {
                        gioitinh = "Nữ";
                    }
                    MemoryStream hinhanh   = new MemoryStream();
                    int          born_year = dateTimeNgaysinh.Value.Year;
                    int          this_year = DateTime.Now.Year;
                    if (((this_year - born_year) < 18) || ((this_year - born_year) > 100))
                    {
                        MessageBox.Show("The KySu Age Must Be Between 18 and 100 year", "Invalid Birth Date", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else if (l > 2 && ((ma[0].ToString() == "N" && ma[1].ToString() == "V") && kiemtra(ma)))
                    {
                        pictureBoxImage.Image.Save(hinhanh, pictureBoxImage.Image.RawFormat);

                        if (nguoilaodong.insertNguoiLaoDong(ma, hoten, ngaysinh, gioitinh, diachi, dienthoai, trinhdo, chucvu, chuyenmon, donvitructhuoc, hinhanh))
                        {
                            MessageBox.Show("New Nhân Viên Added", "Add Nhân Viên", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error", "Add Nhân Viên", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Empty Fields", "Add Nhân Viên", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Empty Fields", "Add Nhân Viên", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                getdata();
                labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount);
            }
            if (radioButton3.Checked == true)
            {
                if (verif() && kiemtra(ma))
                {
                    int      l              = ma.Length;
                    string   hoten          = txtTen.Text;
                    DateTime ngaysinh       = dateTimeNgaysinh.Value;
                    string   dienthoai      = txtSDT.Text;
                    string   diachi         = txtDCtamtru.Text;
                    string   chucvu         = ComboBoxChucVu.Text;
                    string   chuyenmon      = ComboBoxChuyenMon.Text;
                    string   donvitructhuoc = ComboBoxDVTT.Text;
                    string   trinhdo        = ComboBoxTrinhDo.Text;
                    string   gioitinh       = "Nam";
                    if (radioButtonFemale.Checked)
                    {
                        gioitinh = "Nữ";
                    }
                    MemoryStream hinhanh   = new MemoryStream();
                    int          born_year = dateTimeNgaysinh.Value.Year;
                    int          this_year = DateTime.Now.Year;
                    if (((this_year - born_year) < 18) || ((this_year - born_year) > 100))
                    {
                        MessageBox.Show("The KySu Age Must Be Between 18 and 100 year", "Invalid Birth Date", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else if (l > 2 && ((ma[0].ToString() == "C" && ma[1].ToString() == "N") && kiemtra(ma)))
                    {
                        pictureBoxImage.Image.Save(hinhanh, pictureBoxImage.Image.RawFormat);

                        if (nguoilaodong.insertNguoiLaoDong(ma, hoten, ngaysinh, gioitinh, diachi, dienthoai, trinhdo, chucvu, chuyenmon, donvitructhuoc, hinhanh))
                        {
                            MessageBox.Show("New Công Nhân Added", "Add Công Nhân", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error", "Add Công Nhân", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Empty Fields", "Add Công Nhân", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Empty Fields", "Add Công Nhân", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                getdata();
                labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount);
            }
        }