public bool Compare(T_StudentInformation value) { using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString)) { return(dc.T_StudentInformations.Where(x => x.YearLevel == value.YearLevel && x.Active == value.Active && x.Address.ToLower() == value.Address.ToLower() && x.Application.ToLower() == value.Application.ToLower() && x.Bday == value.Bday && x.CompletedStatus == value.CompletedStatus && x.ContactNo == value.ContactNo && x.ContactNoStatus == value.ContactNoStatus && x.Course.ToLower() == value.Course.ToLower() && x.EnrolledStatus == value.EnrolledStatus && x.FatherID == value.FatherID && x.FirstName == value.FirstName && x.GraduateStatus == value.GraduateStatus && x.LastName == value.LastName && x.MiddleName == value.MiddleName && x.MotherID == value.MotherID && x.RFIDNo == value.RFIDNo && x.RFIDStatus == value.RFIDStatus && x.StudentID == value.StudentID).FirstOrDefault() == null?true:false); } }
private T_StudentInformation SetupStudentInfo(bool IsDelete) { T_StudentInformation value = new T_StudentInformation(); value.ID = isAdd?0:Convert.ToInt64(dgStudentRecord.SelectedRows[0].Cells[0].Value.ToString()); if (IsDelete) { value.ID = Convert.ToInt64(dgStudentRecord.SelectedRows[0].Cells[0].Value.ToString()); } value.StudentID = txtStudentID.Text; value.MotherID = isAdd?txtStudentID.Text + "-M":MotherID; value.FatherID = isAdd ? txtStudentID.Text + "-F" : FaterID; value.Application = cmbApplication.Text; value.LastName = txtStudentLastName.Text; value.FirstName = txtStudentFirstName.Text; value.MiddleName = txtStudentMiddleName.Text; value.ContactNo = txtStudentContactNo.Text.Replace("-", "").Replace("\r", ""); value.Bday = dtStudentBday.Value; value.Gender = rbStudentFemale.Checked ? rbStudentFemale.Text : rbStudentMale.Text; value.RFIDNo = txtStudentRFIDNo.Text;//.Remove(8); value.Course = cmbStudentCourse.Text; value.Address = txtStudentAddress.Text; value.CompletedStatus = cbCompleted.Checked; value.GraduateStatus = cbGraduated.Checked; value.EnrolledStatus = cbEnrolled.Checked; value.RFIDStatus = cbRFIDstd.Checked; value.ContactNoStatus = cbContactNoStd.Checked; value.Active = cbActiveStd.Checked; value.DateRegistered = UserDetail.CurrDate(); value.DisplayName = txtStudentFirstName.Text; value.YearLevel = cmbYearLevel.Text; return(value); }
public void Delete(T_StudentInformation value, ref string msg) { T_StudentInformation valuedelete = new T_StudentInformation(); using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString)) { valuedelete = dc.T_StudentInformations.Where(x => x.ID == value.ID).FirstOrDefault(); dc.T_StudentInformations.DeleteOnSubmit(valuedelete); dc.SubmitChanges(); msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine + "Student ID: {1}" + Environment.NewLine + "Last Name: {2}" + Environment.NewLine + "Firs Name: {3}" + Environment.NewLine + "RFID No.: {4}", SystemProperties.MessageNotification.Deleted, valuedelete.StudentID, valuedelete.LastName, valuedelete.FirstName, valuedelete.RFIDNo); } }
public void Save(T_StudentInformation value, ref string msg) { T_StudentInformation valueupdate = new T_StudentInformation(); using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString)) { if (Compare(value)) { if (value.ID == 0) { dc.T_StudentInformations.InsertOnSubmit(value); msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine + "Student ID: {1}" + Environment.NewLine + "Last Name: {2}" + Environment.NewLine + "Firs Name: {3}" + Environment.NewLine + "RFID No.: {4}", SystemProperties.MessageNotification.Saved, value.StudentID, value.LastName, value.FirstName, value.RFIDNo); } else { valueupdate = dc.T_StudentInformations.Where(x => x.ID == value.ID).FirstOrDefault(); valueupdate.StudentID = value.StudentID; valueupdate.MotherID = value.MotherID; valueupdate.FatherID = value.FatherID; valueupdate.Application = value.Application; valueupdate.LastName = value.LastName; valueupdate.FirstName = value.FirstName; valueupdate.MiddleName = value.MiddleName; valueupdate.ContactNo = value.ContactNo; valueupdate.Bday = value.Bday; valueupdate.Gender = value.Gender; valueupdate.RFIDNo = value.RFIDNo.Replace("\r", ""); valueupdate.Course = value.Course; valueupdate.Address = value.Address; valueupdate.CompletedStatus = value.CompletedStatus; valueupdate.GraduateStatus = value.GraduateStatus; valueupdate.EnrolledStatus = value.EnrolledStatus; valueupdate.RFIDStatus = value.RFIDStatus; valueupdate.ContactNoStatus = value.ContactNoStatus; valueupdate.Active = value.Active; valueupdate.YearLevel = value.YearLevel; //valueupdate.DateRegistered = value.DateRegistered; //valueupdate.DisplayName = value.DisplayName; msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine + "Student ID: {1}" + Environment.NewLine + "Last Name: {2}" + Environment.NewLine + "Firs Name: {3}" + Environment.NewLine + "RFID No.: {4}", SystemProperties.MessageNotification.Updated, valueupdate.StudentID, valueupdate.LastName, valueupdate.FirstName, valueupdate.RFIDNo); } } else { msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine + "Student ID: {1}" + Environment.NewLine + "Last Name: {2}" + Environment.NewLine + "Firs Name: {3}" + Environment.NewLine + "RFID No.: {4}", SystemProperties.MessageNotification.Exist, value.StudentID, value.LastName, value.FirstName, value.RFIDNo); } dc.SubmitChanges(); } }