//load Courses private void loadDepartment() { dt_dept = Attendance_Methods.getDepartment(); select_dept_comboBox.DisplayMember = "C_Alias"; select_dept_comboBox.ValueMember = "C_TotalSem"; select_dept_comboBox.DataSource = dt_dept; }
private void select_file_button_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog() { Filter = "Excel File|*.xls;*.xlsx;", Multiselect = false, Title = "Upload Attendance Sheet" }; if (ofd.ShowDialog() == DialogResult.OK) { file_path_textBox.Text = ofd.FileName; string filenm = ofd.FileName; bool hasSheet = false; dt_file = Attendance_Methods.ExcelToDGV(filenm, out hasSheet); attendance_dataGridView.DataSource = null; if (hasSheet) { //If Sheets r available in Excel file the it will check for valid column names & data available if (dt_file.Rows.Count > 0 && dt_file.Columns.Count > 0) { if (columnNameValidation()) { attendance_dataGridView.DataSource = dt_file; attendance_dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader; attendance_dataGridView.Columns[0].Frozen = true; //After successfull checking of column names, will check the valid data in Grid View if not will give error if (!ValidatingDataGridView()) { AlertBox.ShowDialog("AttendanceSheet is not in the specified format.", AlertBox.AlertType.error, false); } } else { AlertBox.ShowDialog("We won't open :(,\r\n bcz AttendanceSheet has not the valid column name.", AlertBox.AlertType.error, false); } } else { AlertBox.ShowDialog("AttendanceSheet doesn't have any data.", AlertBox.AlertType.warning, false); } } else { AlertBox.ShowDialog("Your Excel File doesn't have Sheet, Named with 'AttendanceSheet'", AlertBox.AlertType.error, false); } } }
//upload file to specific folder private void UploadFile(Attendance_Entity ae) { string saveFilePath = Properties.Settings.Default.AttendancePath + select_dept_comboBox.Text + @"\"; string msg = ""; bool isUpload = true; if (!Directory.Exists(Properties.Settings.Default.AttendancePath + select_dept_comboBox.Text)) { Directory.CreateDirectory(Properties.Settings.Default.AttendancePath + select_dept_comboBox.Text); } if (!File.Exists(saveFilePath + ae.file + ".xls")) { ae.file = ae.file + ".xls"; int affected = Attendance_Methods.UploadAttendance(ae); if (affected > 0) { msg = "Attendance Uploaded Successfully :)"; } } else { System.GC.Collect(); System.GC.WaitForPendingFinalizers(); DialogResult result; result = MessageBox.Show("This Attendance file is already exists,\r\nDo u want to override the existing file?", "File Exists!!!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { File.Delete(saveFilePath + ae.file + ".xls"); msg = "File Overriden successfully :)"; } else { isUpload = false; } } if (isUpload) { saveDataInExcel(saveFilePath, ae); } if (msg != "") { AlertBox.ShowDialog(msg, AlertBox.AlertType.success, true); } System.GC.Collect(); System.GC.WaitForPendingFinalizers(); }
private void loadBatchYear() { DataTable dt = Attendance_Methods.getBatchYears(); if (dt.Rows.Count > 0) { select_batch_comboBox.DisplayMember = "BatchYear"; select_batch_comboBox.DataSource = dt; } else { select_batch_comboBox.Items.Add("select"); select_batch_comboBox.SelectedIndex = 0; view_button.Enabled = false; } }
private void generat_sheet_button_Click(object sender, EventArgs e) { SaveFileDialog obj = new SaveFileDialog() { Filter = "Excel File|*.xls", AddExtension = true, Title = "Save Attendace Sheet As ", }; if (obj.ShowDialog() == DialogResult.OK) { int sem = int.Parse(select_sem_numericUpDown.Value.ToString()); Attendance_Methods.GenerateSheet(select_dept_comboBox.Text, sem, obj.FileName); AlertBox.ShowDialog("Attendance Sheet generated Successfully.", AlertBox.AlertType.success, true); } }
private void loadDepartment() { dt_dept = Attendance_Methods.getDepartment(); if (dt_dept.Rows.Count > 0) { select_dept_comboBox.DisplayMember = "C_Alias"; select_dept_comboBox.ValueMember = "C_TotalSem"; select_dept_comboBox.DataSource = dt_dept; } else { select_dept_comboBox.Items.Add("select"); select_dept_comboBox.SelectedIndex = 0; select_sem_numericUpDown.Enabled = false; generat_sheet_button.Enabled = false; } }
private void loadBatchYear() { int sem = int.Parse(select_sem_numericUpDown.Value.ToString()); string reply = Attendance_Methods.getBatchYear(select_dept_comboBox.Text, sem).ToString(); if (reply != "0") { batch_year_TextBox.Text = reply; select_file_button.Enabled = true; } else { batch_year_TextBox.Text = "No Student Presents"; select_file_button.Enabled = false; upload_button.Enabled = false; attendance_dataGridView.DataSource = null; file_path_textBox.Clear(); } }
private void view_button_Click(object sender, EventArgs e) { filenm = Attendance_Methods.getFileName(loadEntity()); fnm = Properties.Settings.Default.AttendancePath + select_dept_comboBox.Text + @"\" + filenm; if (filenm != "null") { bool hassheet = false; dt_file = Attendance_Methods.ExcelToDGV(fnm, out hassheet); attendance_dataGridView.DataSource = null; if (hassheet) { //If Sheets r available in Excel file the it will check for valid column names & data available attendance_dataGridView.DataSource = dt_file; attendance_dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader; for (int i = 0; i < attendance_dataGridView.Columns.Count; i++) { attendance_dataGridView.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } attendance_dataGridView.Columns[0].Frozen = true; this.attendance_dataGridView.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.attendance_dataGridView_RowEnter); total_numericTextBox.Text = attendance_dataGridView.Rows.Count.ToString(); download_button.Enabled = true; filter_enable_button.Enabled = true; counting(); dv = dt_file.DefaultView; } } else { AlertBox.ShowDialog("You didn't upload the attendance sheet for this month.", AlertBox.AlertType.information, false); } }