Пример #1
0
        private void buttonSua_Click(object sender, EventArgs e)
        {
            NguoiLaoDong nguoilaodong = new NguoiLaoDong();

            if (radioButton1.Checked == true)
            {
                string   ma;
                string   hoten          = txtTen.Text;
                DateTime ngaysinh       = dateTimeNgaysinh.Value;
                string   dienthoai      = txtSDT.Text;
                string   diachi         = txtDCtamtru.Text;
                string   chucvu         = ComboBoxChucVu.Text;
                string   donvitructhuoc = ComboBoxDVTT.Text;
                string   trinhdo        = ComboBoxTrinhDo.Text;
                string   chuyenmon      = ComboBoxChuyenMon.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 (verif())
                {
                    try
                    {
                        ma = Convert.ToString(txtMa.Text);
                        pictureBoxImage.Image.Save(hinhanh, pictureBoxImage.Image.RawFormat);
                        if (nguoilaodong.UpdateNguoiLaoDong(ma, hoten, ngaysinh, gioitinh, diachi, dienthoai, trinhdo, chucvu, chuyenmon, donvitructhuoc, hinhanh))
                        {
                            MessageBox.Show("KySu Information Update", "Edit Kỹ Sư", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error", "Edit Kỹ Sư", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Edit Kỹ Sư", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Empty Fields", "Edit Kỹ Sư", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                getdata();
                labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount);
            }
            if (radioButton2.Checked == true)
            {
                string   ma;
                string   hoten          = txtTen.Text;
                DateTime ngaysinh       = dateTimeNgaysinh.Value;
                string   dienthoai      = txtSDT.Text;
                string   diachi         = txtDCtamtru.Text;
                string   chucvu         = ComboBoxChucVu.Text;
                string   donvitructhuoc = ComboBoxDVTT.Text;
                string   trinhdo        = ComboBoxTrinhDo.Text;
                string   chuyenmon      = ComboBoxChuyenMon.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 CongNhan Age Must Be Between 18 and 100 year", "Invalid Birth Date", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (verif())
                {
                    try
                    {
                        ma = Convert.ToString(txtMa.Text);
                        pictureBoxImage.Image.Save(hinhanh, pictureBoxImage.Image.RawFormat);
                        if (nguoilaodong.UpdateNguoiLaoDong(ma, hoten, ngaysinh, gioitinh, diachi, dienthoai, trinhdo, chucvu, chuyenmon, donvitructhuoc, hinhanh))
                        {
                            MessageBox.Show("NhanVien Information Update", "Edit Nhân Viên", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error", "Edit Nhân Viên", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Edit Nhân Viên", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Empty Fields", "Edit Nhân Viên", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                getdata();
                labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount);
            }
            if (radioButton3.Checked == true)
            {
                string   ma;
                string   hoten          = txtTen.Text;
                DateTime ngaysinh       = dateTimeNgaysinh.Value;
                string   dienthoai      = txtSDT.Text;
                string   diachi         = txtDCtamtru.Text;
                string   chucvu         = ComboBoxChucVu.Text;
                string   donvitructhuoc = ComboBoxDVTT.Text;
                string   trinhdo        = ComboBoxTrinhDo.Text;
                string   chuyenmon      = ComboBoxChuyenMon.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 CongNhan Age Must Be Between 18 and 100 year", "Invalid Birth Date", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (verif())
                {
                    try
                    {
                        ma = Convert.ToString(txtMa.Text);
                        pictureBoxImage.Image.Save(hinhanh, pictureBoxImage.Image.RawFormat);
                        if (nguoilaodong.UpdateNguoiLaoDong(ma, hoten, ngaysinh, gioitinh, diachi, dienthoai, trinhdo, chucvu, chuyenmon, donvitructhuoc, hinhanh))
                        {
                            MessageBox.Show("CongNhan Information Update", "Edit Công Nhân", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error", "Edit Công Nhân", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Edit Công Nhân", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Empty Fields", "Edit Công Nhân", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                getdata();
                labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount);
            }
        }
Пример #2
0
        private void buttonXoa_Click(object sender, EventArgs e)
        {
            NguoiLaoDong nguoilaodong = new NguoiLaoDong();

            if (radioButton1.Checked == true)
            {
                DangKi dk = new DangKi();
                try
                {
                    string ma = Convert.ToString(txtMa.Text);
                    dk.deleteTaiKhoan(ma);
                    if ((MessageBox.Show("Are You Sure You Want To Delete This KySu", "Delete KySu", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                    {
                        if (nguoilaodong.deleteNguoiLaoDong(ma))
                        {
                            MessageBox.Show("KySu Deleted", "Delete KySu", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtMa.Text              = null;
                            txtTen.Text             = null;
                            txtSDT.Text             = null;
                            txtDCtamtru.Text        = null;
                            ComboBoxChucVu.Text     = null;
                            ComboBoxDVTT.Text       = null;
                            ComboBoxTrinhDo.Text    = null;
                            ComboBoxChuyenMon.Text  = null;
                            radioButtonMale.Checked = true;
                            dateTimeNgaysinh.Value  = DateTime.Now;
                            pictureBoxImage.Image   = null;
                        }
                        else
                        {
                            MessageBox.Show("KySu Enter A Valid ID", "Delete KySu", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Please Enter A Valid ID", "Delete KySu", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                getdata();
                labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount);
            }
            if (radioButton2.Checked == true)
            {
                try
                {
                    string ma = Convert.ToString(txtMa.Text);
                    if ((MessageBox.Show("Are You Sure You Want To Delete This NhanVien", "Delete NhanVien", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                    {
                        if (nguoilaodong.deleteNguoiLaoDong(ma))
                        {
                            MessageBox.Show("NhanVien Deleted", "Delete NhanVien", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtMa.Text              = null;
                            txtTen.Text             = null;
                            txtSDT.Text             = null;
                            txtDCtamtru.Text        = null;
                            ComboBoxChucVu.Text     = null;
                            ComboBoxDVTT.Text       = null;
                            ComboBoxTrinhDo.Text    = null;
                            ComboBoxChuyenMon.Text  = null;
                            radioButtonMale.Checked = true;
                            dateTimeNgaysinh.Value  = DateTime.Now;
                            pictureBoxImage.Image   = null;
                        }
                        else
                        {
                            MessageBox.Show("NhanVien Enter A Valid ID", "Delete NhanVien", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Please Enter A Valid ID", "Delete NhanVien", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                getdata();
                labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount);
            }
            if (radioButton3.Checked == true)
            {
                try
                {
                    string ma = Convert.ToString(txtMa.Text);
                    if ((MessageBox.Show("Are You Sure You Want To Delete This CongNhan", "Delete CongNhan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                    {
                        if (nguoilaodong.deleteNguoiLaoDong(ma))
                        {
                            MessageBox.Show("CongNhan Deleted", "Delete CongNhan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtMa.Text              = null;
                            txtTen.Text             = null;
                            txtSDT.Text             = null;
                            txtDCtamtru.Text        = null;
                            ComboBoxChucVu.Text     = null;
                            ComboBoxDVTT.Text       = null;
                            ComboBoxTrinhDo.Text    = null;
                            ComboBoxChuyenMon.Text  = null;
                            radioButtonMale.Checked = true;
                            dateTimeNgaysinh.Value  = DateTime.Now;
                            pictureBoxImage.Image   = null;
                        }
                        else
                        {
                            MessageBox.Show("CongNhan Enter A Valid ID", "Delete CongNhan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Please Enter A Valid ID", "Delete CongNhan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                getdata();
                labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount);
            }
        }
Пример #3
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);
            }
        }