}//----------------- //this procedure will Update Student Information public void UpdateForIdMakerStudentInformation(CommonExchange.SysAccess userInfo, CommonExchange.Student studentInfo) { using (RemoteClient.RemCntIdMakerManager remClient = new RemoteClient.RemCntIdMakerManager()) { remClient.UpdateForIdMakerStudentInformation(userInfo, studentInfo); } EditStudentEmployeeDataTable(studentInfo, null, this.IsStudent(studentInfo.StudentId)); }//--------------------------
} //------------------------------- //this function is used to determine if the student card number exists private Boolean IsExistCardNumberStudentInformation(CommonExchange.SysAccess userInfo, String cardNumber, String studentSysId) { Boolean isExist = false; using (RemoteClient.RemCntIdMakerManager remClient = new RemoteClient.RemCntIdMakerManager()) { isExist = remClient.IsExistsCardNumberStudentInformation(userInfo, cardNumber, studentSysId); } return(isExist); } //------------------------------
}//----------------- #endregion #region Programer-Define Function Procedures //this funtion gets the select Employee or Student public DataTable GetSearchEmployeeStudentInformation(CommonExchange.SysAccess userInfo, String queryString, Boolean isNewQuery) { if (isNewQuery) { using (RemoteClient.RemCntIdMakerManager remClient = new RemoteClient.RemCntIdMakerManager()) { _studentEmployeeTable = remClient.SelectByQueryStringStudentEmployeeInformation(userInfo, queryString, true); } } DataTable newTable = new DataTable("EmployeeStudentSearchByNameID"); newTable.Columns.Add("student_employee_id", System.Type.GetType("System.String")); newTable.Columns.Add("student_employee_name", System.Type.GetType("System.String")); newTable.Columns.Add("card_number", System.Type.GetType("System.String")); newTable.Columns.Add("acronym", System.Type.GetType("System.String")); newTable.Columns.Add("course_title_department_name", System.Type.GetType("System.String")); newTable.Columns.Add("present_address", System.Type.GetType("System.String")); newTable.Columns.Add("present_phone_nos", System.Type.GetType("System.String")); if (_studentEmployeeTable != null) { foreach (DataRow row in _studentEmployeeTable.Rows) { DataRow newRow = newTable.NewRow(); newRow["student_employee_id"] = RemoteServerLib.ProcStatic.DataRowConvert(row, "student_employee_id", ""); newRow["student_employee_name"] = RemoteClient.ProcStatic.GetCompleteNameMiddleInitial(row, "last_name", "first_name", "middle_name"); newRow["card_number"] = RemoteServerLib.ProcStatic.DataRowConvert(row, "card_number", ""); newRow["acronym"] = RemoteServerLib.ProcStatic.DataRowConvert(row, "acronym_employment_type", ""); newRow["course_title_department_name"] = RemoteServerLib.ProcStatic.DataRowConvert(row, "course_title_department_name", String.Empty); newRow["present_address"] = RemoteServerLib.ProcStatic.DataRowConvert(row, "present_address", String.Empty); newRow["present_phone_nos"] = RemoteServerLib.ProcStatic.DataRowConvert(row, "present_phone_nos", String.Empty); newTable.Rows.Add(newRow); } } newTable.AcceptChanges(); return(newTable); }//------------------
} //---------------------------------- //this fucntion will determine if the card number is already exist public Boolean IsExistCardNumber(CommonExchange.SysAccess userInfo, String cardNumber, String id, Boolean isStudent) { Boolean value = false; if (isStudent) { using (RemoteClient.RemCntIdMakerManager remClient = new RemoteClient.RemCntIdMakerManager()) { value = remClient.IsExistsCardNumberStudentInformation(userInfo, cardNumber, id); } } else { using (RemoteClient.RemCntIdMakerManager remClient = new RemoteClient.RemCntIdMakerManager()) { value = remClient.IsExistsCardNumberEmployeeInformation(userInfo, cardNumber, id); } } return(value); }//----------------------------
} //------------------------ //this procedure exports the student data to the sql server private void ExportStudentDataToSqlServer() { try { this.Cursor = Cursors.WaitCursor; Int32 deniedCount = 0; Int32 successCount = 0; Int32 rowCount = 0; pgbImport.Step = 1; pgbImport.Maximum = this.dgvList.Rows.Count; foreach (DataRow studRow in _studentTable.Rows) { this.SetDataGridViewBehavior(rowCount); String studentId = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "ACCESSION", ""); String cardNumber = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "KEYWORDS", ""); String studentName = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "TITLE0", ""); if (!this.IsExistStudentIdStudentInformation(_userInfo, studentId, "") && !this.IsExistCardNumberStudentInformation(_userInfo, cardNumber, "") && !String.Equals("(blank)", studentName) && !String.IsNullOrEmpty(RemoteClient.ProcStatic.TrimStartEndString(cardNumber)) && !String.IsNullOrEmpty(RemoteClient.ProcStatic.TrimStartEndString(studentId))) { String remarks = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "REMARKS", ""); CommonExchange.Student studentInfo = new CommonExchange.Student(); studentInfo.ObjectState = DataRowState.Added; studentInfo.PersonInfo.ObjectState = DataRowState.Added; StudentName studName = this.GetStudentNameDetails(studentName); RemarksDetails remarkInfo = this.GetRemarksDetails(remarks); studentInfo.StudentId = RemoteClient.ProcStatic.TrimStartEndString(studentId); studentInfo.PersonInfo.LastName = studName.LastName; studentInfo.PersonInfo.FirstName = studName.FirstName; studentInfo.CardNumber = cardNumber; studentInfo.Scholarship = studName.Scholoarship; studentInfo.CourseInfo.CourseId = this.GetCourseId(remarkInfo.CourseName); studentInfo.PersonInfo.OtherPersonInformation = remarkInfo.OtherInformation; studentInfo.PersonInfo.BirthDate = String.Empty; if (!String.IsNullOrEmpty(_imagePath) && this.chkImage.Checked) { StudentImage imageInfo = this.GetStudentImageDetails(studentId); if (!String.IsNullOrEmpty(imageInfo.ImagePath)) { studentInfo.PersonInfo.FilePath = imageInfo.ImagePath; studentInfo.PersonInfo.FileData = RemoteClient.ProcStatic.GetFileArrayBytes(imageInfo.ImagePath); studentInfo.PersonInfo.FileExtension = imageInfo.ImageExtension; studentInfo.PersonInfo.FileName = Path.GetFileName(imageInfo.ImagePath); this.txtDirectory.Text = imageInfo.ImagePath; } } using (RemoteClient.RemCntStudentManager remClient = new RemoteClient.RemCntStudentManager()) { remClient.InsertStudentInformation(_userInfo, ref studentInfo); } using (RemoteClient.RemCntIdMakerManager remClient = new RemoteClient.RemCntIdMakerManager()) { remClient.UpdateForIdMakerStudentInformation(_userInfo, studentInfo); } successCount++; } else { deniedCount++; } pgbImport.PerformStep(); rowCount++; Application.DoEvents(); this.Refresh(); } MessageBox.Show("Student data has been successfully exported to the SQL Server" + "\n\nSuccess: " + successCount.ToString() + " Record(s)" + "\nDenied: " + deniedCount.ToString() + " Record(s)", "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); pgbImport.Value = 0; } catch (Exception ex) { MessageBox.Show("Error in exporting: " + ex.Message, "Error"); } finally { this.Cursor = Cursors.Arrow; } } //--------------------------------------