protected static void Copy(DataAccess.Student obj, Student newObj) { newObj.ID = obj.ID; newObj.MajorID = obj.MajorID; newObj.SSN = obj.SSN; newObj.FirstName = obj.FirstName; newObj.LastName = obj.LastName; newObj.Active = obj.Active; }
void GetUser() { oStudent = new DataAccess.Student(); foreach (DataRow row in oStudent.getStudent("ID", sVoters_ID).Rows) { lblUser.Text = row["FIRST_NAME"].ToString() + " " + row["LAST_NAME"].ToString(); } }
private void btnSave_Click(object sender, EventArgs e) { oStudent = new DataAccess.Student(); oMStudent = new Model.Student(); foreach (var oText in pnlMain.Controls.OfType <TextBox>().ToList()) { if (oText.Text.Trim() == String.Empty) { oFrmMsgBox = new Forms.frmMessageBox(eVariable.MESSAGE.ALL_FIELDS_ARE_ALL_REQUIRED.ToString().Replace("_", " ")); oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); return; } } oMStudent.UNIQUE_ID = txtStudentID.Text; oMStudent.FIRST_NAME = txtFname.Text; oMStudent.MIDDLE_NAME = txtMname.Text; oMStudent.LAST_NAME = txtLname.Text; oMStudent.DOB = dtDOB.Value.ToString("yyyy-MM-dd"); oMStudent.AGE = txtAge.Text; oMStudent.COURSE = txtCourse.Text; oMStudent.SECTION = txtSection.Text; oMStudent.CONTACT_NO = txtContactNo.Text; oMStudent.ADDRESS = txtAddress.Text; if (TransactionType == eVariable.TransactionType.EDIT) { oStudent.UpdateStudent(oMStudent); } else { if (!oStudent.IsRecordExists(oMStudent)) { oStudent.InsertStudent(oMStudent); } else { oFrmMsgBox = new frmMessageBox(eVariable.MESSAGE.RECORD_ALREADY_EXISTS.ToString().Replace("_", " ")); oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); return; } } oFrmStudents.LoadStudents(); oFrmMsgBox = new frmMessageBox(eVariable.MESSAGE.RECORD_HAS_BEEN_SUCCESSFULLY_SAVE.ToString().Replace("_", " ")); oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); TransactionType = eVariable.TransactionType.ADD; Close(); }
public static Student FromDataAccessObject(DataAccess.Student obj) { if (obj == null) { return(null); } Student newObj = new Student(); ServiceObjects.Student.Copy(obj, newObj); return(newObj); }
private void chkAutoNumber_Click(object sender, EventArgs e) { oStudent = new DataAccess.Student(); if (chkAutoNumber.Checked) { txtStudentID.Enabled = false; txtStudentID.Text = oStudent.GetStudentAutoNo(); } else { txtStudentID.Enabled = true; txtStudentID.Text = ""; } }
public static Student FromDataAccessObject(DataAccess.Student obj) { if (obj == null) { return(null); } Student newObj = new Student(); ServiceObjects.Student.Copy(obj, newObj); newObj.Links.Add(new Link("Major", LinkType.Major, RESTUrlUtil.Service.RESTSvc.GetMajorByID(newObj.MajorID))); newObj.Links.Add(new Link("Enrollments", LinkType.Enrollments, RESTUrlUtil.Service.RESTSvc.GetEnrollmentsByStudentID(newObj.ID, 1))); return(newObj); }
public void LoadStudent() { try { dgExport.Rows.Clear(); StudentStructure(); oStudent = new DataAccess.Student(); foreach (DataRow row in oStudent.getStudent("", "").Rows) { dgExport.Rows.Add(row["STUDENT_ID"], row["FIRST_NAME"], row["MIDDLE_NAME"], row["LAST_NAME"], row["DOB"], row["AGE"], row["COURSE"], row["SECTION"], row["ADDRESS"], row["CONTACT_NO"]); } } catch (Exception ex) { } }
private void frmStudentEntry_Load(object sender, EventArgs e) { oStudent = new DataAccess.Student(); LoadStudents(); txtStudentID.Focus(); if (TransactionType == eVariable.TransactionType.ADD) { txtStudentID.Enabled = false; txtStudentID.Text = oStudent.GetStudentAutoNo(); } else { txtStudentID.Enabled = false; chkAutoNumber.Enabled = false; } }
//删除学生 public void Delete(int studentNo, string studentName, string className) { if (DialogResult.Yes == MessageBox.Show("真的要删除学生' " + studentName + " '吗?\n删除学生,将同时删除与该学生相关的所有成绩信息,要继续吗?", "删除确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { DataAccess.Student objStudent = new DataAccess.Student(studentNo); objStudent.ClassName = className; if (objStudent.Delete() > 0) { UpdateDataGrid(); MessageBox.Show("成功删除学生' " + studentName + " '!", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("删除操作失败!", "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnArchive_Click(object sender, EventArgs e) { try { oStudent = new DataAccess.Student(); if (MessageBox.Show("You want to archive this record?", sTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { oStudent.DeleteStudents(oMStudent.UNIQUE_ID); LoadStudents(); MessageBox.Show("Record has been succesfully archived", sTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { } }
public void LoadStudents() { try { oStudent = new DataAccess.Student(); dgStudents.Rows.Clear(); foreach (DataRow row in oStudent.getStudent(cboSearchBy.Text, tbxSearch.Text).Rows) { dgStudents.Rows.Add(row["STUDENT_ID"], row["FIRST_NAME"], row["MIDDLE_NAME"], row["LAST_NAME"], row["DOB"], row["AGE"], row["COURSE"], row["SECTION"], row["ADDRESS"], row["CONTACT_NO"]); } lblTotalRecords.Text = dgStudents.Rows.Count.ToString(); } catch (Exception ex) { } }
private void LoadRecords() { try { if (RecordType == RECORD_TYPE.STUDENT) { StudentGrid(); oStudent = new DataAccess.Student(); dgDetails.Rows.Clear(); foreach (DataRow row in oStudent.getCandidate(cboSearch.Text, txtSearch.Text).Rows) { dgDetails.Rows.Add(row["STUDENT_ID"], row["FIRST_NAME"], row["MIDDLE_NAME"], row["LAST_NAME"], row["DOB"], row["AGE"], row["COURSE"], row["SECTION"], row["ADDRESS"], row["CONTACT_NO"]); } } else if (RecordType == RECORD_TYPE.POSITION) { PositionGrid(); oPosition = new DataAccess.Position(); dgDetails.Rows.Clear(); foreach (DataRow row in oPosition.getCandidatePosition(cboSearch.Text, txtSearch.Text).Rows) { dgDetails.Rows.Add(row[0], row[1]); } } else if (RecordType == RECORD_TYPE.PARTY) { PartyGrid(); oParty = new DataAccess.Party(); dgDetails.Rows.Clear(); foreach (DataRow row in oParty.getCandidateParty(cboSearch.Text, txtSearch.Text).Rows) { dgDetails.Rows.Add(row[0], row[1]); } } } catch (Exception ex) { } }
//修改学生资料 public void Update(int studentNo, string studentName, string gender, DateTime birthday, string className, string imagePath, string remark) { string newFileName = imagePath; if (imagePath.Trim().Length > 0) { newFileName = studentNo.ToString() + new FileInfo(imagePath).Extension; } DataAccess.Student objStudent = new DataAccess.Student(studentNo); objStudent.StudentName = studentName; objStudent.Gender = gender; objStudent.Birthday = birthday; objStudent.ClassName = className; objStudent.Picture = newFileName; objStudent.Remark = remark; int result = 0; if (className.Equals(_className)) { result = objStudent.Update(); } else { result = objStudent.Update(_className); } if (result > 0) { UpdateDataGrid(); //更新图片 if (imagePath.Trim().Length > 0) { BusinessRuler.ImageManage.UpdateImageFile(imagePath, newFileName); } MessageBox.Show("修改学生资料成功!", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("更新操作失败!", "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnGenerate_Click(object sender, EventArgs e) { oStudent = new DataAccess.Student(); oElection = new DataAccess.SystemFunction(); if (!oElection.IsElectionCodeActive()) { oFrmMsgBox = new Forms.frmMessageBox("THERE IS NO ACTIVE ELECTION TICKET NUMBER. PLEASE OPEN FIRST TO START. THANK YOU. CLICK : UTILITY ELECTION TICKET NO"); oFrmMsgBox.MessageType = Forms.frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); return; } foreach (DataRow row in oElection.getElectionCode("", "").Rows) { sElectionCode = row["CODE"].ToString(); } foreach (DataRow row in oStudent.getStudent("", "").Rows) { oKeyGenerator = new CommonFunction.CommonFunction(); oGenerateKey = new DataAccess.SystemFunction(); oMGenerateKey = new Model.GenerateKey(); oMGenerateKey.GENERATED_KEY = oKeyGenerator.GetAssortedString(5); oMGenerateKey.VOTERS_ID = row["STUDENT_ID"].ToString(); oMGenerateKey.DATED_ADDED = DateTime.Now.ToString("yyyy-MM-dd"); oMGenerateKey.ELECTION_CODE = sElectionCode; oMGenerateKey.STATUS = "ACTIVE"; if (!oGenerateKey.IsKeyExists(oMGenerateKey.VOTERS_ID)) { oGenerateKey.InsertKey(oMGenerateKey); } } LoadRecords(); }
private void cboStudentNo_SelectedIndexChanged(object sender, EventArgs e) { //根据学号将相应内容填入 int studentNo = Int32.Parse(this.cboStudentNo.SelectedItem.ToString()); DataAccess.Student objStudent = DataAccess.Student.CreateInstance(studentNo); this.txtName.Text = objStudent.StudentName; if (objStudent.Gender.Equals("女")) { this.rdoFemale.Checked = true; } else { this.rdoMale.Checked = true; } this.dtpBirthday.Value = objStudent.Birthday; this.chxChangeClass.Checked = false; this.cboClass.Enabled = false; //填充班级名称列表 BusinessRuler.Classes objClass = new BusinessRuler.Classes(); objClass.FillCboByAllClassName(this.cboClass, objStudent.ClassName); LoadImage(objStudent.Picture); this.txtRemark.Text = objStudent.Remark; }
private void btnButton_Click(object sender, EventArgs e) { if (btnButton.Text.Trim() == "IMPORT") { if (txtImportPath.Text.Trim() == String.Empty) { MessageBox.Show("Please select file to import"); return; } #region Import try { if (cboImport.SelectedText == "STUDENT" || cboImport.Text == "STUDENT") { if (dgImport.Rows.Count > 0) { foreach (var iData in lstStudent) { oStudent = new DataAccess.Student(); if (!oStudent.IsRecordExists(iData)) { oStudent.InsertStudent(iData); } } MessageBox.Show("Record has been succesfully saved", sTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (cboImport.SelectedText == "POSITION" || cboImport.Text == "POSITION") { if (dgImport.Rows.Count > 0) { foreach (var iData in lstCandidate) { oCandidate = new DataAccess.Candidate(); oCandidate.InsertCandidate(iData); } MessageBox.Show("Record has been succesfully saved", sTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { } #endregion } else { if (txtExportPath.Text.Trim() == string.Empty) { MessageBox.Show("PLEASE SELECT DISTINATION FILE PATH"); return; } if (dgExport.Rows.Count == 0) { MessageBox.Show("POPULATE RECORD FIRST"); return; } #region Export ExtractData(); #endregion } }
private void btnBrowseI_Click(object sender, EventArgs e) { try { if (cboImport.SelectedText == "STUDENT" || cboImport.Text == "STUDENT") { OpenFileDialog oDiaglog = new OpenFileDialog { InitialDirectory = @"D:\", Title = "Browse CSV Files", CheckFileExists = true, CheckPathExists = true, DefaultExt = "csv", Filter = "CSV files (*.CSV)|*.CSV", FilterIndex = 2, RestoreDirectory = true, ReadOnlyChecked = true, ShowReadOnly = true }; if (oDiaglog.ShowDialog() == DialogResult.OK) { txtImportPath.Text = oDiaglog.FileName; oStudent = new DataAccess.Student(); lstStudent = oStudent.RetrieveCSVData(txtImportPath.Text); dgImport.DataSource = lstStudent; } } if (cboImport.SelectedText == "CANDIDATE" || cboImport.Text == "CANDIDATE") { OpenFileDialog oDiaglog = new OpenFileDialog { InitialDirectory = @"D:\", Title = "Browse CSV Files", CheckFileExists = true, CheckPathExists = true, DefaultExt = "csv", Filter = "CSV files (*.CSV)|*.CSV", FilterIndex = 2, RestoreDirectory = true, ReadOnlyChecked = true, ShowReadOnly = true }; } if (txtImportPath.Text.Trim() != String.Empty) { foreach (DataGridViewColumn col in dgImport.Columns) { col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } for (int i = 0; i < dgImport.RowCount; i++) { for (int j = 0; j < dgImport.ColumnCount; j++) { if (dgImport.Rows[i].Cells[j].Value.ToString() == string.Empty) { dgImport.Columns[j].Visible = false; } } } } } catch (Exception ex) { } }