private void buttonHoanTat_Click(object sender, EventArgs e)
        {
            try
            {
                string MaNV       = cbbMaNV.Text.Trim();
                string TenNV      = txtTenNV.Text.Trim();
                string HoNV       = txtHoNV.Text.Trim();
                string GTinh      = cbbGTinh.Text.TrimEnd();
                string NSinh      = dtpNS.Value.ToShortDateString();
                string QuocTich   = txtQuocTich.Text.Trim();
                string NguyenQuan = txtNguyenQuan.Text.Trim();
                string DiaChi     = txtDiaChi.Text.Trim();
                string SDT_Email  = txtEmail.Text.Trim();
                string NgoaiNgu   = txtNgoaiNgu.Text.Trim();
                string HocVan     = txtHocVan.Text.Trim();
                string GhiChu     = txtGhiChu.Text.Trim();

                if (MaNV.Length != 0 && TenNV.Length != 0 && HoNV.Length != 0 && GTinh.Length != 0 && QuocTich.Length != 0 &&
                    NguyenQuan.Length != 0 && DiaChi.Length != 0 && SDT_Email.Length != 0 && HocVan.Length != 0 && NgoaiNgu.Length != 0)
                {
                    bool check = database.Check(MaNV, "SELECT MaNV FROM dbo.TTNhanVienCoBan");
                    if (check == false)
                    {
                        //( MaNV ,TenNV ,HoDemNV ,GioiTinh ,NgaySinh ,QuocTich ,NguyenQuan ,DiaChi ,SDT_Email ,NgoaiNgu , HocVan , GhiChu )
                        string insert = "INSERT INTO dbo.TTNhanVienCoBan ( MaNV ,TenNV ,HoDemNV ,GioiTinh ,NgaySinh ,QuocTich ,NguyenQuan ,DiaChi ,SDT_Email ,NgoaiNgu , HocVan , GhiChu ) "
                                        + "VALUES(N'" + MaNV + "', N'" + TenNV + "', N'" + HoNV + "', N'" + GTinh + "','" + NSinh + "', N'" + QuocTich + "',"
                                        + "N'" + NguyenQuan + "', N'" + DiaChi + "', N'" + SDT_Email + "', N'" + NgoaiNgu + "', N'" + HocVan + "',N'" + GhiChu + "')";
                        database.ThucThiKetNoi(insert);
                        MessageBox.Show("Hoàn Tất!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        //load lại dataGridView1
                        dgvTTCN.DataSource = "";
                        string query = "SELECT * FROM dbo.TTNhanVienCoBan";
                        database.loadDataGridView(dgvTTCN, query);
                    }
                    else
                    {
                        MessageBox.Show("Thông tin NV " + HoNV + " " + TenNV + " đã tồn tại!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng nhập điền đầy đủ bắt buộc đến trường học vấn!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
            catch
            {
                MessageBox.Show("Đã xảy ra lỗi!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Exemplo n.º 2
0
        private void buttonHoanTat_Click(object sender, EventArgs e)
        {
            try
            {
                string userName = textBoxUsername.Text.Trim();
                string oldPass  = textBoxOldPassword.Text.Trim();
                string confirm  = textBoxConfirm.Text.Trim();
                string newPass  = textBoxNewPassword.Text.Trim();
                bool   check    = db.Check(oldPass, "SELECT MatKhau FROM dbo.TaiKhoan WHERE Username=N'" + userName + "'");
                bool   check1   = db.Check(userName, "SELECT Username FROM dbo.TaiKhoan");

                if (userName.Length != 0 && oldPass.Length != 0 && confirm.Length != 0 && newPass.Length != 0)
                {
                    if (check1 == true)    //Nếu tài khoản tồn tại
                    {
                        if (check == true) //Nếu mật khẩu là đúng
                        {
                            if (newPass == confirm)
                            {
                                string update = "UPDATE dbo.TaiKhoan SET MatKhau=N'" + newPass + "' WHERE Username=N'" + userName + "'";
                                db.ThucThiKetNoi(update);
                                MessageBox.Show("Mật khẩu của bạn đã được cập nhật!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show("Confirm không đúng!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Mật khẩu không đúng!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Username không tồn tại!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng điền đầy đủ các trường!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
            catch
            {
                MessageBox.Show("Vui lòng thử lại!", "Đã xảy ra lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Exemplo n.º 3
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            string search = textBoxSearch.Text.Trim();

            if (search.Length != 0)
            {
                if (check == 0)
                {
                    MessageBox.Show("Vui lòng chọn kiểu tìm kiếm!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else if (check == 1)
                {
                    try
                    {
                        string MaNV    = textBoxSearch.Text.Trim();
                        string timkiem = "EXEC.TimKiemMaNV @MaNV=N'" + MaNV + "'";
                        db.loadDataGridView(dataGridView1, timkiem);
                        textBoxSearch.Text = "";
                    }
                    catch
                    {
                    }
                }
                else if (check == 2)
                {
                    try
                    {
                        string PB   = textBoxSearch.Text.Trim();
                        bool   temp = db.Check(PB, "SELECT * FROM dbo.PhongBan WHERE MaPB = N'" + PB + "'");

                        //MessageBox.Show(temp.ToString());

                        if (temp == false)
                        {
                            db.loadDataGridView(dataGridView1, "SELECT * FROM dbo.PhongBan WHERE TenPB LIKE N'%" + PB + "%'");
                            textBoxSearch.Text = "";
                        }
                        else
                        {
                            db.loadDataGridView(dataGridView1, "SELECT * FROM dbo.PhongBan WHERE MaPB = N'" + PB + "'");
                            textBoxSearch.Text = "";
                        }
                    }
                    catch
                    {
                    }
                }
                else
                {
                    db.loadDataGridView(dataGridView1, "SELECT * FROM dbo.HoSoNV WHERE TenNV LIKE N'%" + search + "%'");
                    textBoxSearch.Text = "";
                }
            }
            else
            {
                MessageBox.Show("Vui lòng nhập khóa để tìm kiếm", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string MaPB          = cbbMaPB.Text.Trim();
                string TenPB         = txtTenPB.Text.Trim();
                string ChucNang      = txtChucNangPB.Text.Trim();
                string NgayThanhLap  = dtpNgayTL.Value.ToShortDateString();
                string SDT_Fax       = txtSDTPB.Text.Trim();
                string DiaChiPB      = txtDCPhong.Text.Trim();
                string GhiChu        = txtGhiChu.Text.Trim();
                string MaTruongPhong = cbbMaTruongPhong.Text.Trim();
                if (MaPB.Length != 0 && TenPB.Length != 0 && ChucNang.Length != 0 && SDT_Fax.Length != 0 && DiaChiPB.Length != 0 && MaTruongPhong.Length != 0)
                {
                    bool check = db.Check(MaPB, "SELECT MaPB FROM dbo.PhongBan");
                    if (check == false)
                    {
                        //( MaPB ,TenPB ,ChucNang ,NgayThanhLap ,SDT_Fax ,DiaChiPB ,GhiChu ,MaTruongPhong)
                        string insert = "INSERT INTO dbo.PhongBan VALUES  ( N'" + MaPB + "' , N'" + TenPB + "' , N'" + ChucNang + "' , '" + NgayThanhLap + "' , N'" + SDT_Fax + "' , N'" + DiaChiPB + "' , N'" + GhiChu + "' , N'" + MaTruongPhong + "'   )";
                        db.ThucThiKetNoi(insert);
                        // Update chức vụ cho trưởng phòng.
                        string updtruongphong = "UPDATE dbo.HoSoNV SET ChucVu=N'Trưởng Phòng' WHERE MaNV=N'" + MaTruongPhong + "'";
                        db.ThucThiKetNoi(updtruongphong);
                        //update trưởng phòng thuộc phòng ban.
                        string updtruongphongpb = "UPDATE dbo.HoSoNV SET MaPB=N'" + MaPB + "' WHERE MaNV=N'" + MaTruongPhong + "'";
                        db.ThucThiKetNoi(updtruongphongpb);

                        MessageBox.Show("Hoàn Tất!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        db.loadDataGridView(dgvPhongBan, "SELECT * FROM dbo.PhongBan");
                    }
                    else
                    {
                        MessageBox.Show("Phòng ban đã tồn lại!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
            catch
            {
                MessageBox.Show("Lỗi rồi!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Exemplo n.º 5
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         string MaNV     = cbbMaNV.Text.Trim();
         string TenNV    = txtTenNV.Text.Trim();
         string HoNV     = txtHoNV.Text.Trim();
         string MaPB     = cbbMaPB.Text.Trim();
         string NgayKyHD = dtpNgayKyHD.Value.ToShortDateString();
         string NgayHH   = dtpNgayHH.Value.ToShortDateString();
         string Chucvu   = txtChucVu.Text.Trim();
         string Luong    = cbbLuong.Text.Trim();
         if (MaNV.Length != 0 && TenNV.Length != 0 && HoNV.Length != 0 && MaPB.Length != 0 && Chucvu.Length != 0 && Luong.Length != 0)
         {
             bool check = database.Check(MaNV, "SELECT MaNV FROM dbo.HoSoNV");
             if (check == false)
             {
                 string input = "INSERT INTO dbo.HoSoNV VALUES  ( N'" + MaNV + "' , N'" + TenNV + "' , N'" + HoNV + "' ,N'" + Chucvu + "' ,  N'" + MaPB + "' , '" + NgayHH + "' , '" + NgayHH + "', N'" + Luong + "' )";
                 database.ThucThiKetNoi(input);
                 MessageBox.Show("Thêm hồ sơ " + HoNV + " " + TenNV + " thành công!", "Hoàn tất", MessageBoxButtons.OK);
                 //load lại combobox Mã NV
                 cbbMaNV.Items.Clear();
                 database.loadComboBox(cbbMaNV, "SELECT MaNV FROM dbo.HoSoNV");
                 string query = "SELECT * FROM dbo.HoSoNV ";
                 database.loadDataGridView(dgvHoSo, query);
             }
             else
             {
                 MessageBox.Show("Không thể thêm! Nhân viên đã tồn tại!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             }
         }
         else
         {
             MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         }
     }
     catch (Exception) {
         MessageBox.Show("Đã xảy ra lỗi hệ thống!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
 }
Exemplo n.º 6
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         string MaNV     = comboBoxMaNV.Text.Trim();
         string TenNV    = textBoxTenNV.Text.Trim();
         string HoNV     = textBoxHoNV.Text.Trim();
         string MaPB     = comboBoxMaPB.Text.Trim();
         string NgayKyHD = dateTimePicker2.Value.ToShortDateString();
         string NgayHH   = dateTimePicker1.Value.ToShortDateString();
         string Chucvu   = textBoxChucVu.Text.Trim();
         string Luong    = comboBoxLuong.Text.Trim();
         if (MaNV.Length != 0 && TenNV.Length != 0 && HoNV.Length != 0 && MaPB.Length != 0 && Chucvu.Length != 0 && Luong.Length != 0)
         {
             bool check = database.Check(MaNV, "SELECT MaNV FROM dbo.HoSoNV");
             if (check == false)
             {
                 string input = "INSERT INTO dbo.HoSoNV VALUES  ( N'" + MaNV + "' , N'" + TenNV + "' , N'" + HoNV + "' ,N'" + Chucvu + "' ,  N'" + MaPB + "' , '" + NgayHH + "' , '" + NgayHH + "', N'" + Luong + "' )";
                 database.ThucThiKetNoi(input);
                 MessageBox.Show("Hoàn Tất!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 //load lại combobox Mã NV
                 comboBoxMaNV.Items.Clear();
                 database.loadComboBox(comboBoxMaNV, "SELECT MaNV FROM dbo.HoSoNV");
                 string query = "SELECT * FROM dbo.HoSoNV WHERE MaNV='" + MaNV + "'";
                 database.loadDataGridView(dataGridView, query);
             }
             else
             {
                 MessageBox.Show("Không thể thêm! Nhân viên đã tồn tại!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             }
         }
         else
         {
             MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         }
     }
     catch (Exception) {
         MessageBox.Show("Lỗi rồi!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
 }
Exemplo n.º 7
0
 private void buttonAdd1_Click(object sender, EventArgs e)
 {
     try
     {
         string MaNV    = cbbMaNV1.Text.Trim();
         string HoTenNV = txtTenNV1.Text.Trim();
         string MaLuong = txtMaLuong1.Text.Trim();
         string MaBHXH  = txtMaBHXH.Text.Trim();
         string NgayCap = dtpNC.Value.ToShortDateString();
         string GhiChu  = txtGhiChu1.Text.Trim();
         if (MaNV.Length != 0 && HoTenNV.Length != 0 && MaLuong.Length != 0 && MaBHXH.Length != 0)
         {
             bool check1 = db.Check(MaNV, "SELECT MaNV FROM dbo.CDBaoHiemXaHoi");
             bool check2 = db.Check(MaBHXH, "SELECT MaBHXH FROM dbo.CDBaoHiemXaHoi");
             if (check1 == false)
             {
                 if (check2 == false)
                 {
                     string insert = "INSERT dbo.CDBaoHiemXaHoi( MaNV ,HoTenNV ,MaLuong ,MaBHXH ,NgayCapSo ,GhiChu)"
                                     + "  VALUES  ( N'" + MaNV + "' , N'" + HoTenNV + "' , N'" + MaLuong + "' ,  N'" + MaBHXH + "' ,  '" + NgayCap + "' , N'" + GhiChu + "')";
                     db.ThucThiKetNoi(insert);
                     MessageBox.Show("Thêm sổ BHXH cho NV: " + HoTenNV + " hoàn tất!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     db.loadDataGridView(dgvBH, "SELECT * FROM dbo.CDBaoHiemXaHoi");
                 }
                 else
                 {
                     MessageBox.Show("Mã sổ BHXH: " + MaBHXH + " đã tồn tại!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 }
             }
             else
             {
                 MessageBox.Show("NV: " + HoTenNV + " đã có sổ BHXH", "Không thể thêm mới!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             }
         }
         else
         {
             MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         }
     }
     catch
     {
         MessageBox.Show("Đã xảy ra lỗi!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
 }