private void btnLuu_Click_1(object sender, EventArgs e)
 {
     if (this.txtMaSV.Text != "" && cbxNhiemKy.Text != "")
     {
         if (this.dangthem == true)
         {
             try
             {
                 nghiepvu.ThemBanDieuHanh(this.txtMaSV.Text, Convert.ToInt32(this.cbxNhiemKy.SelectedValue.ToString()), this.cbxChucVu.Text);
                 NeedReload.Invoke(this, e);
                 MessageBox.Show("Thêm thành công!");
             }
             catch (SqlException a)
             {
                 MessageBox.Show(a.Message);
                 return;
             }
         }
     }
     else if (this.txtMaSV.Text == "")
     {
         MessageBox.Show("Bạn chưa điền mã sinh viên!");
     }
     else if (this.cbxNhiemKy.Text == "")
     {
         MessageBox.Show("Bạn chưa chọn khóa Đội viên!");
     }
 }
Example #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (this.txtMaSV.Text == "")
            {
                MessageBox.Show("Vui lòng chọn Đội viên muốn xóa!");
                return;
            }
            DialogResult xoadialog;

            xoadialog = MessageBox.Show("Bạn thật sự muốn xóa Đội viên này!", ""
                                        , MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            if (xoadialog == DialogResult.Yes)
            {
                try
                {
                    nghiepvu.XoaDoiVien(this.txtMaSV.Text);
                    NeedReload.Invoke(this, e);
                    MessageBox.Show("Đã xóa thành công!");
                }
                catch (SqlException a)
                {
                    MessageBox.Show(a.Message);
                }
            }
        }
Example #3
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     lock (locker) {
         currentTime = DateTime.Now;
         var interval = (int)currentTime.Subtract(LastHeartbeat).TotalSeconds;
         //Debug.WriteLine($"interval = {interval}");
         if (interval > HeartbeatTimeout)
         {
             if (interval > SwitchMirrorTimeout)
             {
                 NeedChangeMirror?.Invoke(this, EventArgs.Empty);
                 LastHeartbeat = DateTime.Now;
             }
             else
             {
                 if (ReloadAttempts == 0)
                 {
                     NeedReload?.Invoke(this, EventArgs.Empty);
                     ReloadAttempts++;
                 }
                 else
                 {
                     ReloadAttempts++;
                     if (ReloadAttempts == 10)
                     {
                         ReloadAttempts = 0;
                     }
                 }
             }
         }
     }
 }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (dangthem == true)
            {
                if (txtMaSV.Text.ToString() == "")
                {
                    MessageBox.Show("Nhập Mã sinh");
                }
                else
                {
                    try {
                        nghiepvu.SinhvienThamgiaCT(this.txtMaSV.Text.ToString(),
                                                   this.cbxMaCT.SelectedValue.ToString(),
                                                   this.txtDiemCTXH.Text.ToString(),
                                                   this.txtDanhgia.Text.ToString());
                        MessageBox.Show("Thêm thành công");
                        this.NeedReload(this, e);
                    }
                    catch (SqlException a)
                    {
                        MessageBox.Show(a.Message);
                    }
                }
            }
            else
            {
                if (dangcapnhat == true)
                {
                    string MaCT = cbxMaCT.SelectedValue.ToString();

                    try
                    {
                        nghiepvu.CapNhatThamgia(MaCT, txtMaSV.Text.ToString(),
                                                txtDiemCTXH.Text.ToString(), txtDanhgia.Text.ToString());
                        MessageBox.Show("Cập nhật thông tin thành công");
                        NeedReload(this, e);
                    }
                    catch
                    {
                        MessageBox.Show("Cập nhật không thành công");
                    }
                }
                else
                {
                    MessageBox.Show("Chọn thông tin sinh viên cần cập nhật");
                }
            }
            NeedReload.Invoke(this, e);
        }
Example #5
0
 private void btnOKKetNap_Click(object sender, EventArgs e)
 {
     if (this.txtMaSV.Text == "")
     {
         MessageBox.Show("Bạn chưa nhập Mã sinh viên!");
         return;
     }
     try
     {
         nghiepvu.KetNap(txtMaSV.Text, txtMaKhoa.Text);
         NeedReload.Invoke(this, e);
         MessageBox.Show("Đã kết nạp " + this.txtHoTen.Text + "!");
     }
     catch { MessageBox.Show("Bị lỗi, không kết nạp được!"); }
 }
Example #6
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (this.txtMaSV.Text != "" && cbxKhoaDV.Text != "")
     {
         if (this.dangthem == true)
         {
             try
             {
                 nghiepvu.ThemDoiVien(this.txtMaSV.Text, this.txtHoTen.Text,
                                      this.dtpNgaySinh.Value, this.cbxQueQuan.Text, this.cbxNganh.Text,
                                      this.cbxKhoa.SelectedValue.ToString(), this.cbxKhoaDV.Text);
                 NeedReload.Invoke(this, e);
                 MessageBox.Show("Thêm thành công!");
             }
             catch
             {
                 MessageBox.Show("Xảy ra lỗi!");
                 return;
             }
         }
         else if (this.dangcapnhat == true)
         {
             try
             {
                 nghiepvu.UpdateDoiVien(this.txtMaSV.Text, this.txtHoTen.Text,
                                        this.dtpNgaySinh.Value, this.cbxQueQuan.Text, this.cbxNganh.Text,
                                        this.cbxKhoa.SelectedValue.ToString(), this.cbxKhoaDV.Text);
                 NeedReload.Invoke(this, e);
                 MessageBox.Show("Cập nhật thành công!");
             }
             catch
             {
                 MessageBox.Show("Xảy ra lỗi!");
                 return;
             }
         }
     }
     else if (this.txtMaSV.Text == "")
     {
         MessageBox.Show("Bạn chưa điền mã sinh viên!");
     }
     else if (this.cbxKhoaDV.Text == "")
     {
         MessageBox.Show("Bạn chưa chọn khóa Đội viên!");
     }
 }
Example #7
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (this.txtMaNhanVien.Text != "")
            {
                if (this.dangthem == true)
                {
                    try
                    {
                        nv.ThemNhanVien(txtMaNhanVien.Text.ToString(), txtHoTen.Text.ToString(), cbxGioiTinh.Text.ToString(),
                                        dtpNgaySinh.Value, txtCMND.Text.ToString(), txtSoDienThoai.Text.ToString(),
                                        txtDiaChi.Text.ToString(), dtpNgayBatDau.Value, txtChucVu.Text.ToString(),
                                        txtMucLuong.Text.ToString(), cbxQuayLamViec.SelectedValue.ToString());

                        NeedReload.Invoke(this, e);
                        MessageBox.Show("Thêm thành công!");
                    }
                    catch (SqlException a)
                    {
                        MessageBox.Show(a.Message);
                        return;
                    }
                }
                else if (this.dangcapnhat == true)
                {
                    try
                    {
                        nv.UpdateNhanVien(txtMaNhanVien.Text.ToString(), txtHoTen.Text.ToString(), cbxGioiTinh.Text.ToString(),
                                          dtpNgaySinh.Value, txtCMND.Text.ToString(), txtSoDienThoai.Text.ToString(),
                                          txtDiaChi.Text.ToString(), dtpNgayBatDau.Value, txtChucVu.Text.ToString(),
                                          txtMucLuong.Text.ToString(), cbxQuayLamViec.SelectedValue.ToString());
                        NeedReload.Invoke(this, e);
                        MessageBox.Show("Cập nhật thành công!");
                    }
                    catch (SqlException a)
                    {
                        MessageBox.Show(a.Message);
                        return;
                    }
                }
            }
            else if (this.txtMaNhanVien.Text == "")
            {
                MessageBox.Show("Bạn chưa điền mã nhân viên!");
            }
        }
        private void btnImp_Click(object sender, EventArgs e)
        {
            string         filename = "";
            OpenFileDialog of       = new OpenFileDialog();

            if (of.ShowDialog() == DialogResult.OK)
            {
                filename = of.FileName;
            }
            if (filename != "")
            {
                try
                {
                    //Đọc dữ liệu từ file excel
                    var package = new ExcelPackage(new FileStream(filename, FileMode.Open, FileAccess.ReadWrite));
                    //Lấy dữ liệu từ sheet đầu tiên
                    ExcelWorksheet ws = package.Workbook.Worksheets[1];

                    //Đọc dữ liệu
                    for (int i = ws.Dimension.Start.Row + 1; i <= ws.Dimension.End.Row; i++)
                    {
                        try {
                            //Lấy dữ liệu từ từng cột
                            int    j        = 1;
                            string MaCT     = ws.Cells[i, j++].Value.ToString();
                            string MaSV     = ws.Cells[i, j++].Value.ToString();
                            string DiemCTXH = ws.Cells[i, j++].Value.ToString();
                            string Danhgia  = ws.Cells[i, j++].Value.ToString();

                            nghiepvu.SinhvienThamgiaCT(MaSV, MaCT, DiemCTXH, Danhgia);
                        }
                        catch
                        {
                            MessageBox.Show("Không thể thêm thông tin tại dòng thứ " + i);
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Chọn file định dạng xls hoặc xlsx để nhập danh sách!");
                }
            }
            NeedReload.Invoke(this, e);
        }
 private void btnOKThayThe_Click_1(object sender, EventArgs e)
 {
     if (txtMaSV1.Text.Length > 0 && txtMaSV2.Text.Length > 0)
     {
         try
         {
             nghiepvu.ThayTheBanDieuHanh(Convert.ToInt32(cbxNhiemKy.SelectedValue.ToString()), txtMaSV1.Text, txtMaSV2.Text);
         }
         catch (SqlException a)
         {
             MessageBox.Show(a.Message);;
         }
     }
     else
     {
         MessageBox.Show("Chưa điền đầy đủ thông tin");
     }
     NeedReload.Invoke(this, e);
 }
 private void btnXoa_Click(object sender, EventArgs e)
 {
     //Kiểm tra
     if (txtMaSV.Text.ToString() != "")
     {
         DialogResult kq = MessageBox.Show("Chắn chắn xóa sinh viên " + txtMaSV.Text.ToString() +
                                           " khỏi danh sách CT " + txtTenCT.Text.ToString(),
                                           "Xóa Tham gia", MessageBoxButtons.YesNo);
         if (kq == DialogResult.Yes)
         {
             nghiepvu.XoaThamgiaCT(txtMaSV.Text.ToString(), cbxMaCT.SelectedValue.ToString());
         }
     }
     else
     {
         MessageBox.Show("Chọn Sinh viên muốn xóa khỏi danh sách trước khi ấn xóa");
     }
     NeedReload.Invoke(this, e);
 }
Example #11
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (this.txtMaCT.Text != "")
     {
         if (this.dangthem == true)
         {
             try
             {
                 nghiepvu.ThemChuongTrinh(this.txtMaCT.Text, this.txtTenCT.Text,
                                          this.dtpNgayToChuc.Value, this.txtDiaDiem.Text, this.txtKinhPhi.Text,
                                          this.txtDiemCTXH.Text);
                 NeedReload.Invoke(this, e);
                 MessageBox.Show("Thêm thành công!");
             }
             catch
             {
                 MessageBox.Show("Xảy ra lỗi!");
                 return;
             }
         }
         else if (this.dangcapnhat == true)
         {
             try
             {
                 nghiepvu.UpdateChuongTrinh(this.txtMaCT.Text, this.txtTenCT.Text,
                                            this.dtpNgayToChuc.Value, this.txtDiaDiem.Text, this.txtKinhPhi.Text,
                                            this.txtDiemCTXH.Text);
                 NeedReload.Invoke(this, e);
                 MessageBox.Show("Cập nhật thành công!");
             }
             catch
             {
                 MessageBox.Show("Xảy ra lỗi!");
                 return;
             }
         }
     }
     else if (this.txtMaCT.Text == "")
     {
         MessageBox.Show("Bạn chưa điền mã chương trình!");
     }
 }
Example #12
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (this.txtMaVD.Text != "")
     {
         if (this.dangthem == true)
         {
             try
             {
                 nghiepvu.ThemVatDung(this.txtMaVD.Text, this.txtTenVD.Text,
                                      this.txtDonVi.Text, this.nmrSoLuong.Text);
                 NeedReload.Invoke(this, e);
                 MessageBox.Show("Thêm thành công!");
             }
             catch
             {
                 MessageBox.Show("Xảy ra lỗi!");
                 return;
             }
         }
         else if (this.dangcapnhat == true)
         {
             try
             {
                 nghiepvu.UpdateVatDung(this.txtMaVD.Text, this.txtTenVD.Text,
                                        this.txtDonVi.Text, this.nmrSoLuong.Text);
                 NeedReload.Invoke(this, e);
                 MessageBox.Show("Cập nhật thành công!");
             }
             catch
             {
                 MessageBox.Show("Xảy ra lỗi!");
                 return;
             }
         }
     }
     else if (this.txtMaVD.Text == "")
     {
         MessageBox.Show("Bạn chưa điền mã vật dụng!");
     }
 }
Example #13
0
        private void btnXoaHoantoan_Click(object sender, EventArgs e)
        {
            if (this.txtMaSV.Text == "")
            {
                MessageBox.Show("Vui lòng chọn Cộng tác viên muốn xóa!");
                return;
            }
            DialogResult xoadialog = MessageBox.Show("Bạn thật sự muốn xóa Cộng tác viên này!", ""
                                                     , MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (xoadialog == DialogResult.Yes)
            {
                try
                {
                    nghiepvu.XoaToanBo(txtMaSV.Text.ToString());
                    NeedReload.Invoke(this, e);
                    MessageBox.Show("Đã xóa thành công!");
                }
                catch
                { MessageBox.Show("Xóa không thành công"); }
            }
        }
Example #14
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (this.txtMaVD.Text == "")
            {
                MessageBox.Show("Vui lòng chọn vật dụng muốn xóa!");
                return;
            }
            DialogResult xoadialog;

            xoadialog = MessageBox.Show("Bạn thật sự muốn xóa vật dụng này!", ""
                                        , MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            if (xoadialog == DialogResult.Yes)
            {
                try
                {
                    nghiepvu.XoaVatDung(this.txtMaVD.Text);
                    NeedReload.Invoke(this, e);
                    MessageBox.Show("Đã xóa thành công!");
                }
                catch
                { MessageBox.Show("Đã xảy ra lỗi, không xóa được!"); }
            }
        }
Example #15
0
 private void btnHuy_Click(object sender, EventArgs e)
 {
     NeedReload.Invoke(this, e);
 }
Example #16
0
        private void btnImp_Click(object sender, EventArgs e)
        {
            //Lấy tên file
            string         filename = "";
            OpenFileDialog of       = new OpenFileDialog();

            if (of.ShowDialog() == DialogResult.OK)
            {
                filename = of.FileName;
                MessageBox.Show(filename);
            }
            // Mở file
            if (filename != "")
            {
                try {
                    //Mở file excel
                    var package = new ExcelPackage(new FileStream(filename, FileMode.Open, FileAccess.ReadWrite));
                    //Lấy ra sheet để thao tác
                    ExcelWorksheet ws = package.Workbook.Worksheets[1];
                    //Duyệt từng dòng
                    for (int i = ws.Dimension.Start.Row + 1; i <= ws.Dimension.End.Row; i++)
                    {
                        try
                        {
                            int j = 1; //Thứ tự cột
                            //Lấy ra các giá trị tương ứng
                            string MaSV  = ws.Cells[i, j++].Value.ToString();
                            string Hoten = ws.Cells[i, j++].Value.ToString();
                            //Cột thứ 3 lưu ngày sinh
                            var      birthdaytemp = ws.Cells[i, j++].Value;
                            DateTime birthday     = new DateTime();
                            if (birthdaytemp != null)
                            {
                                birthday = (DateTime)birthdaytemp;
                            }
                            //Các cột tiếp theo
                            string Quequan = ws.Cells[i, j++].Value.ToString();
                            string Nganh   = ws.Cells[i, j++].Value.ToString();
                            string Khoa    = ws.Cells[i, j++].Value.ToString();


                            //Lưu lại dữ liệu
                            nghiepvu.ThemCongTacVien(MaSV, Hoten, birthday, Quequan, Nganh, Khoa);
                        }
                        catch
                        {
                            MessageBox.Show("Xãy ra lỗi khi đọc dữ liệu từ dòng thứ " + i.ToString());
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Lỗi trong quá trình đọc tập tin");
                }
            }
            else
            {
                MessageBox.Show("Chọn file dạng xls hoặc xlsx để nhập thông tin");
            }
            NeedReload.Invoke(this, e);
        }
Example #17
0
 private void btnNhiemKyMoi_Click(object sender, EventArgs e)
 {
     nghiepvu.ThemNhiemKyMoi();
     MessageBox.Show("Đã thêm nhiệm kỳ mới!");
     NeedReload.Invoke(this, e);
 }