public static bool Delete(Guid Id) { bool result = false; DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clFamilyPayment, "Delete", "Delete Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clFamilyPayment, "Delete", "Debug Delete Method", DayCarePL.Common.GUID_DEFAULT); SchoolProgramFeesDetail DBSchoolProgram = db.SchoolProgramFeesDetails.FirstOrDefault(s => s.Id.Equals(Id)); if (DBSchoolProgram != null) { db.SchoolProgramFeesDetails.DeleteOnSubmit(DBSchoolProgram); db.SubmitChanges(); result = true; } else { result = false; } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clFamilyPayment, "Delete", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static DayCarePL.Result SaveCheckInCheckOutTime(Guid StaffSchoolYearId, bool CheckInCheckOut, string CheckInCheckOutDateTime) { clConnection.DoConnection(); DayCarePL.Result objResult = new DayCarePL.Result(); objResult.result = "true"; DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clStaffAttendenceHistory, "SaveCheckInCheckOutTime", "Execute SaveCheckInCheckOutTime Method", DayCarePL.Common.GUID_DEFAULT); DayCareDataContext db = new DayCareDataContext(); StaffAttendenceHistory DBStaffAttendenceHistory = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clStaffAttendenceHistory, "SaveCheckInCheckOutTime", "", StaffSchoolYearId.ToString()); DBStaffAttendenceHistory = new StaffAttendenceHistory(); DBStaffAttendenceHistory.Id = Guid.NewGuid(); DBStaffAttendenceHistory.StaffSchoolYearId = StaffSchoolYearId; DBStaffAttendenceHistory.CheckInCheckOut = CheckInCheckOut; DBStaffAttendenceHistory.CheckInCheckOutDateTime = Convert.ToDateTime(CheckInCheckOutDateTime); DBStaffAttendenceHistory.CreatedDateTime = DateTime.Now; db.StaffAttendenceHistories.InsertOnSubmit(DBStaffAttendenceHistory); db.SubmitChanges(); objResult.result = "true"; } catch (Exception ex) { objResult.result = "false"; DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clStaffAttendenceHistory, "SaveCheckInCheckOutTime", ex.Message.ToString(), StaffSchoolYearId.ToString()); } return(objResult); }
public static bool DeleteAdditionalNotes(Guid Id) { bool result = false; DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.AdditionalNote, "Delete", "Delete Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.AdditionalNote, "Delete", "Debug Delete Method", DayCarePL.Common.GUID_DEFAULT); AdditionalNote DBAdditionalNotes = db.AdditionalNotes.FirstOrDefault(c => c.Id.Equals(Id)); if (DBAdditionalNotes != null) { db.AdditionalNotes.DeleteOnSubmit(DBAdditionalNotes); db.SubmitChanges(); result = true; } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.AdditionalNote, "Delete", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static DayCarePL.Result Save(Guid ChildSchoolYearId, bool CheckInCheckOut, string CheckInCheckOutDateTime) { clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); DayCarePL.Result objResult = new DayCarePL.Result(); ChildAttendenceHistory DBChildAttendaceHistory = null; try { DBChildAttendaceHistory = new ChildAttendenceHistory(); DBChildAttendaceHistory.Id = System.Guid.NewGuid(); DBChildAttendaceHistory.ChildSchoolYearId = ChildSchoolYearId; DBChildAttendaceHistory.CheckInCheckOut = CheckInCheckOut; DBChildAttendaceHistory.CheckInCheckOutDateTime = Convert.ToDateTime(CheckInCheckOutDateTime); db.ChildAttendenceHistories.InsertOnSubmit(DBChildAttendaceHistory); db.SubmitChanges(); objResult.result = "true"; } catch (Exception ex) { objResult.result = ex.Message.ToString(); } return(objResult); }
public static bool Delete(Guid Id, Guid SchoolYearID) { bool result = false; DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clClassRoom, "Delete", "Delete Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clClassRoom, "Delete", "Debug Delete Method", DayCarePL.Common.GUID_DEFAULT); ClassRoom DBClassRoom = db.ClassRooms.FirstOrDefault(c => c.Id.Equals(Id)); ProgClassRoom DBProgClassRoom = db.ProgClassRooms.FirstOrDefault(pc => pc.ClassRoomId.Equals(Id) && pc.ClassRoomSchoolYearId.Equals(SchoolYearID)); ClassRoomSchoolYear DBClassRoomSchoolYear = db.ClassRoomSchoolYears.FirstOrDefault(crsy => crsy.ClassRoomId.Equals(Id) && crsy.SchoolYearId.Equals(SchoolYearID)); if (DBClassRoomSchoolYear != null) { db.ClassRoomSchoolYears.DeleteOnSubmit(DBClassRoomSchoolYear); } if (DBProgClassRoom != null) { db.ProgClassRooms.DeleteOnSubmit(DBProgClassRoom); db.SubmitChanges(); result = true; } if (DBClassRoom != null) { db.ClassRooms.DeleteOnSubmit(DBClassRoom); db.SubmitChanges(); result = true; } else { result = false; } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clClassRoom, "Delete", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool Save(DayCarePL.LedgerProperties objLedger) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clLedgerOfFamily, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); Ledger DBLedger = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clLedgerOfFamily, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objLedger.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBLedger = new Ledger(); DBLedger.Id = Guid.NewGuid(); DBLedger.CreatedById = objLedger.CreatedById; DBLedger.CreatedDateTime = DateTime.Now; } else { DBLedger = db.Ledgers.FirstOrDefault(i => i.Id.Equals(objLedger.Id)); } DBLedger.SchoolYearId = objLedger.SchoolYearId; DBLedger.ChildFamilyId = objLedger.ChildFamilyId; DBLedger.TransactionDate = objLedger.TransactionDate; DBLedger.Debit = objLedger.Debit; DBLedger.Credit = 0; DBLedger.Balance = objLedger.Debit - objLedger.Credit; DBLedger.AllowEdit = false; DBLedger.Comment = objLedger.Comment; DBLedger.LateFee = objLedger.LateFee; // 1. LateFee 0. No Late Fee DBLedger.LastModifiedById = objLedger.LastModifiedById; DBLedger.LastModifiedDatetime = DateTime.Now; if (objLedger.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.Ledgers.InsertOnSubmit(DBLedger); } db.SubmitChanges(); try { //update closing balance on 10 May 2013 By Akash Guid SchoolId = clSchool.GetSchoolIdbySchoolYearId(objLedger.SchoolYearId.Value); if (clSchoolYear.IsSelectedYearPrevYearORNot(SchoolId, objLedger.SchoolYearId.Value))//only prev year can only allow to edit closing balance. because in current year or in future year closing balance is not genrated in these year { clSchoolYear.UpdateClosingBalance(SchoolId, objLedger.SchoolYearId.Value, objLedger.ChildFamilyId); } //end } catch { } return(true); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clLedgerOfFamily, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(false); } }
public static bool Save(DayCarePL.ClassRoomProperties objClassRoom) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clClassRoom, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); ClassRoom DBClassRoom = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clClassRoom, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objClassRoom.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBClassRoom = new ClassRoom(); DBClassRoom.Id = System.Guid.NewGuid(); } else { DBClassRoom = db.ClassRooms.SingleOrDefault(D => D.Id.Equals(objClassRoom.Id)); } DBClassRoom.LastModifiedById = objClassRoom.LastModifiedById; DBClassRoom.LastModifiedDatetime = DateTime.Now; DBClassRoom.Name = objClassRoom.Name; DBClassRoom.SchoolId = objClassRoom.SchoolId; DBClassRoom.MaxSize = objClassRoom.MaxSize; DBClassRoom.Active = objClassRoom.Active; DBClassRoom.StaffId = objClassRoom.StaffId; if (objClassRoom.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.ClassRooms.InsertOnSubmit(DBClassRoom); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clClassRoom, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } finally { } return(result); }
public static bool ImportAllActiveChild(Guid SchoolYearId, Guid SchoolId, Guid OldCurrentSchoolYearId, System.Data.Common.DbTransaction tran, DayCareDataContext dbold) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clChildSchoolYear, "ImportAllActiveChild", "Execute ImportAllActiveChild Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = dbold; db.Transaction = tran; ChildSchoolYear DBChildSchoolYear = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clChildSchoolYear, "ImportAllActiveChild", "Debug ImportAllActiveChild Method", DayCarePL.Common.GUID_DEFAULT); //Guid currentschoolyearid = (from sy in db.SchoolYears // where sy.CurrentId.Equals(true) // select sy.Id).SingleOrDefault(); List <Guid> lstChild = (from c in db.ChildDatas join csy in db.ChildSchoolYears on c.Id equals csy.ChildDataId join cf in db.ChildFamilies on c.ChildFamilyId equals cf.Id where cf.SchoolId.Equals(SchoolId) && csy.active.Equals(true) && csy.SchoolYearId.Equals(OldCurrentSchoolYearId) && !(from cy in db.ChildSchoolYears where cy.SchoolYearId.Equals(SchoolYearId) select cy.ChildDataId).Contains(c.Id) select c.Id).ToList(); //var Data = db.spGetChildIdNotInChildSchoolYear(SchoolId, SchoolYearId); foreach (Guid ChildDataId in lstChild) { try { DBChildSchoolYear = new ChildSchoolYear(); DBChildSchoolYear.Id = Guid.NewGuid(); DBChildSchoolYear.ChildDataId = ChildDataId; DBChildSchoolYear.SchoolYearId = SchoolYearId; DBChildSchoolYear.active = true; db.ChildSchoolYears.InsertOnSubmit(DBChildSchoolYear); db.SubmitChanges(); } catch { } } return(true); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clChildSchoolYear, "ImportAllActiveChild", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(false); } }
public static bool ImportAllActiveClassRoom(Guid SchoolYearId, Guid SchoolId, Guid OldCurrentSchoolYearId, System.Data.Common.DbTransaction tran, DayCareDataContext dbold) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.ClassRoom, "ImportAllActiveClassRoom", "Execute ImportAllActiveClassRoom Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = dbold; db.Transaction = tran; ClassRoomSchoolYear DBClassRoomSchoolYear = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.ClassRoom, "ImportAllActiveClassRoom", "Debug ImportAllActiveClassRoom Method", DayCarePL.Common.GUID_DEFAULT); Guid currentschoolyearid = SchoolYearId; List <DayCarePL.ClassRoomProperties> lstClassroom = (from cr in db.ClassRooms join sy in db.SchoolYears on cr.SchoolId equals sy.SchoolId where cr.SchoolId.Equals(SchoolId) && sy.Id.Equals(OldCurrentSchoolYearId) && !(from crsy in db.ClassRoomSchoolYears where crsy.SchoolYearId.Equals(currentschoolyearid) select crsy.ClassRoomId).Contains(cr.Id) select new DayCarePL.ClassRoomProperties() { Id = cr.Id, SchoolYearId = sy.Id, Active = cr.Active, StaffId = cr.StaffId, LastModifiedById = cr.LastModifiedById, Name = cr.Name }).ToList(); foreach (DayCarePL.ClassRoomProperties objClassroom in lstClassroom) { DBClassRoomSchoolYear = new ClassRoomSchoolYear(); DBClassRoomSchoolYear.Id = Guid.NewGuid(); DBClassRoomSchoolYear.ClassRoomId = objClassroom.Id; DBClassRoomSchoolYear.SchoolYearId = SchoolYearId; DBClassRoomSchoolYear.Active = objClassroom.Active; DBClassRoomSchoolYear.StaffId = objClassroom.StaffId; DBClassRoomSchoolYear.CreatedById = objClassroom.LastModifiedById; DBClassRoomSchoolYear.CreatedDateTime = DateTime.Now.Date; DBClassRoomSchoolYear.LastModifiedById = objClassroom.LastModifiedById; DBClassRoomSchoolYear.LastModifiedDateTime = DateTime.Now.Date; DBClassRoomSchoolYear.ClassRoomName = objClassroom.Name; db.ClassRoomSchoolYears.InsertOnSubmit(DBClassRoomSchoolYear); db.SubmitChanges(); } } catch { } return(true); }
public static bool ImportAllActiveStaff(Guid SchoolYearId, Guid SchoolId, Guid OldCurrentSchoolYearId, System.Data.Common.DbTransaction tran, DayCareDataContext dbold) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clStaffSchoolYear, "ImportAllActiveStaff", "Execute ImportAllActiveStaff Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = dbold; db.Transaction = tran; StaffSchoolYear DBStaffSchoolYear = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clStaffSchoolYear, "ImportAllActiveStaff", "Debug ImportAllActiveStaff Method", DayCarePL.Common.GUID_DEFAULT); /* Guid currentschoolyearid = (from sy in db.SchoolYears * where sy.CurrentId.Equals(true) && sy.SchoolId.Equals(SchoolId) * select sy.Id).SingleOrDefault(); */ Guid currentschoolyearid = SchoolYearId; List <Guid> lstStaff = (from s in db.Staffs join ug in db.UserGroups on s.UserGroupId equals ug.Id join ssy in db.StaffSchoolYears on s.Id equals ssy.StaffId where ug.SchoolId.Equals(SchoolId) && ssy.active.Equals(true) && ssy.SchoolYearId.Equals(OldCurrentSchoolYearId) && !(from sy in db.StaffSchoolYears where sy.SchoolYearId.Equals(currentschoolyearid) select sy.StaffId).Contains(s.Id) select s.Id).ToList(); foreach (Guid staffid in lstStaff) { try { DBStaffSchoolYear = new StaffSchoolYear(); DBStaffSchoolYear.Id = Guid.NewGuid(); DBStaffSchoolYear.StaffId = staffid; DBStaffSchoolYear.SchoolYearId = SchoolYearId; DBStaffSchoolYear.active = true; db.StaffSchoolYears.InsertOnSubmit(DBStaffSchoolYear); db.SubmitChanges(); } catch { } } return(true); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clStaffSchoolYear, "ImportAllActiveStaff", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(false); } }
public static bool Save(List <DayCarePL.LedgerProperties> lstLedger) { // DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clLedger, "Save", "Save method called", DayCarePL.Common.GUID_DEFAULT); DayCareDataContext db = new DayCareDataContext(); Ledger DBLedger = null; try { ///DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clLedger, "Save", "Debug Save called", DayCarePL.Common.GUID_DEFAULT); foreach (DayCarePL.LedgerProperties objLedger in lstLedger) { try { if (!CheckChildProgInLedger(objLedger.SchoolYearId, objLedger.ChildFamilyId, objLedger.ChildDataId, objLedger.TransactionDate, objLedger.SchoolProgramId)) { DBLedger = new Ledger(); DBLedger.Id = Guid.NewGuid(); DBLedger.SchoolYearId = objLedger.SchoolYearId; DBLedger.ChildFamilyId = objLedger.ChildFamilyId; DBLedger.ChildDataId = objLedger.ChildDataId; DBLedger.TransactionDate = objLedger.TransactionDate; DBLedger.Comment = objLedger.Comment; DBLedger.Detail = objLedger.Detail; DBLedger.Debit = objLedger.Debit; DBLedger.Credit = objLedger.Credit; DBLedger.Balance = objLedger.Debit - objLedger.Credit; DBLedger.AllowEdit = objLedger.AllowEdit; DBLedger.PaymentId = objLedger.PaymentId; DBLedger.CreatedById = objLedger.CreatedById.HasValue == true ? objLedger.CreatedById.Value : new Guid(DayCarePL.Common.GUID_DEFAULT); DBLedger.CreatedDateTime = objLedger.CreatedDateTime; DBLedger.LastModifiedById = objLedger.LastModifiedById; DBLedger.LastModifiedDatetime = objLedger.LastModifiedDatetime; DBLedger.SchoolProgramId = objLedger.SchoolProgramId; db.Ledgers.InsertOnSubmit(DBLedger); db.SubmitChanges(); } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clLedger, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); } } return(true); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clLedger, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(false); } }
public static bool Save(DayCarePL.StateProperties objState) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clState, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); State DBState = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clState, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); Configuration myConfiguration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); XDocument xDoc = XDocument.Load(myConfiguration.FilePath.ToLower().Remove(myConfiguration.FilePath.ToLower().IndexOf("web.config")) + "XML\\StateList.xml"); if (objState.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBState = new State(); DBState.Id = Guid.NewGuid(); xDoc.Element("States").Add(new XElement("State", new XElement("Id", DBState.Id), new XElement("Name", objState.Name), new XElement("CountryId", objState.CountryId))); xDoc.Save(myConfiguration.FilePath.ToLower().Remove(myConfiguration.FilePath.ToLower().IndexOf("web.config")) + "XML\\StateList.xml"); } else { DBState = db.States.SingleOrDefault(c => c.Id.Equals(objState.Id)); var statedata = (from c in xDoc.Descendants("State") where c.Element("Id").Value.Equals(objState.Id.ToString()) select c).Single(); statedata.Element("Name").Value = objState.Name; statedata.Element("CountryId").Value = Convert.ToString(objState.CountryId); xDoc.Save(myConfiguration.FilePath.ToLower().Remove(myConfiguration.FilePath.ToLower().IndexOf("web.config")) + "XML\\StateList.xml"); } DBState.Name = objState.Name; DBState.CountryId = objState.CountryId; if (objState.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.States.InsertOnSubmit(DBState); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clState, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool UpdateClassRoomSchoolYearID(Guid SchoolYearId, Guid OldCurrentSchoolYearID, System.Data.Common.DbTransaction tran, DayCareDataContext dbold) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clClassRoom, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; //declare trans variable // System.Data.Common.DbTransaction trans = null; DayCareDataContext db = dbold; db.Transaction = tran; ProgClassRoom DBProgClassRoom = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clClassRoom, "Update", "Debug Update Method", DayCarePL.Common.GUID_DEFAULT); var ClassRoomSchoolYear = (from pcr in db.ProgClassRooms join sp in db.SchoolPrograms on pcr.SchoolProgramId equals sp.Id join csy in db.ClassRoomSchoolYears on pcr.ClassRoomSchoolYearId equals csy.Id where sp.SchoolYearId.Equals(OldCurrentSchoolYearID) && csy.ClassRoomId == pcr.ClassRoomId select new { pcrId = pcr.Id, csyId = csy.Id }).ToList(); var cl = ClassRoomSchoolYear; for (int cnt = 0; cnt < cl.Count(); cnt++) { DBProgClassRoom = db.ProgClassRooms.FirstOrDefault(pc => pc.Id.Equals(cl[cnt].pcrId)); if (DBProgClassRoom != null) { DBProgClassRoom.ClassRoomSchoolYearId = cl[cnt].csyId; db.SubmitChanges(); DBProgClassRoom = null; } } } catch { return(false); } return(true); }
public static bool Save(DayCarePL.AbsentResonProperties objAbsentReason) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clAbsentReason, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); AbsentReason DBAbsentReason = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clAbsentReason, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objAbsentReason.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBAbsentReason = new AbsentReason(); DBAbsentReason.Id = System.Guid.NewGuid(); } else { DBAbsentReason = db.AbsentReasons.SingleOrDefault(A => A.Id.Equals(objAbsentReason.Id)); } DBAbsentReason.LastModifiedById = objAbsentReason.LastModifiedById; DBAbsentReason.LastModifiedDatetime = DateTime.Now; // DBAbsentReason.Id=objAbsentReason.Id; DBAbsentReason.Reason = objAbsentReason.Reason; DBAbsentReason.SchoolId = objAbsentReason.SchoolId; DBAbsentReason.Active = objAbsentReason.Active; DBAbsentReason.BillingAffected = objAbsentReason.BillingAffected; DBAbsentReason.Comments = objAbsentReason.Comments; DBAbsentReason.LastModifiedById = objAbsentReason.LastModifiedById; DBAbsentReason.LastModifiedDatetime = DateTime.Now; if (objAbsentReason.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.AbsentReasons.InsertOnSubmit(DBAbsentReason); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clAbsentReason, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool Save(DayCarePL.EnrollmentStatusProperties objEnrollment) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clEnrollmentStatus, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); EnrollmentStatus DBEnrollmentStatus = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clEnrollmentStatus, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objEnrollment.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBEnrollmentStatus = new EnrollmentStatus(); DBEnrollmentStatus.Id = System.Guid.NewGuid(); } else { DBEnrollmentStatus = db.EnrollmentStatus.SingleOrDefault(E => E.Id.Equals(objEnrollment.Id)); } DBEnrollmentStatus.LastModifiedById = objEnrollment.LastModifiedById; DBEnrollmentStatus.LastModifiedDatetime = DateTime.Now; DBEnrollmentStatus.SchoolId = objEnrollment.SchoolId; DBEnrollmentStatus.Status = objEnrollment.Status; DBEnrollmentStatus.Active = objEnrollment.Active; DBEnrollmentStatus.Comments = objEnrollment.Comments; DBEnrollmentStatus.LastModifiedById = objEnrollment.LastModifiedById; DBEnrollmentStatus.LastModifiedDatetime = DateTime.Now; if (objEnrollment.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.EnrollmentStatus.InsertOnSubmit(DBEnrollmentStatus); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clEnrollmentStatus, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool Save(DayCarePL.UserGroupProperties objUserGroup) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clUserGroup, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); UserGroup DBUserGroup = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clUserGroup, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objUserGroup.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBUserGroup = new UserGroup(); DBUserGroup.Id = System.Guid.NewGuid(); } else { DBUserGroup = db.UserGroups.SingleOrDefault(U => U.Id.Equals(objUserGroup.Id)); } DBUserGroup.LastModifiedById = objUserGroup.LastModifiedById; DBUserGroup.LastModifiedDatetime = DateTime.Now; DBUserGroup.SchoolId = objUserGroup.SchoolId; DBUserGroup.GroupTitle = objUserGroup.GroupTitle; DBUserGroup.RoleId = objUserGroup.RoleId; DBUserGroup.Comments = objUserGroup.Comments; DBUserGroup.LastModifiedById = objUserGroup.LastModifiedById; DBUserGroup.LastModifiedDatetime = DateTime.Now; if (objUserGroup.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.UserGroups.InsertOnSubmit(DBUserGroup); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clUserGroup, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool Save(DayCarePL.HoursOfOperationProperties objHoursOfOperation) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clHoursOfOperation, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); HoursOfOperation DBHourOfOeration = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clHoursOfOperation, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objHoursOfOperation.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBHourOfOeration = new HoursOfOperation(); DBHourOfOeration.Id = Guid.NewGuid(); } else { DBHourOfOeration = db.HoursOfOperations.SingleOrDefault(id => id.Id.Equals(objHoursOfOperation.Id)); } DBHourOfOeration.LastModifiedById = objHoursOfOperation.LastModifiedById; DBHourOfOeration.LastModifiedDatetime = DateTime.Now; DBHourOfOeration.Day = objHoursOfOperation.Day; DBHourOfOeration.DayIndex = objHoursOfOperation.DayIndex; DBHourOfOeration.OpenTime = objHoursOfOperation.OpenTime; DBHourOfOeration.CloseTime = objHoursOfOperation.CloseTime; DBHourOfOeration.Comments = objHoursOfOperation.Comments; DBHourOfOeration.SchoolId = objHoursOfOperation.SchoolId; if (objHoursOfOperation.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.HoursOfOperations.InsertOnSubmit(DBHourOfOeration); } db.SubmitChanges(); return(true); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clHoursOfOperation, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(false); } }
public static bool Save(DayCarePL.AdditionalNotesProperties objNotes) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clAbsentReason, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); AdditionalNote DBAdditionalNote = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clAbsentReason, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objNotes.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBAdditionalNote = new AdditionalNote(); DBAdditionalNote.Id = System.Guid.NewGuid(); DBAdditionalNote.CreatedById = objNotes.CreatedById; DBAdditionalNote.CreatedDateTime = DateTime.Now; } else { DBAdditionalNote = db.AdditionalNotes.SingleOrDefault(A => A.Id.Equals(objNotes.Id)); } DBAdditionalNote.ChildSchoolYearId = objNotes.ChildSchoolYearId; DBAdditionalNote.CommentDate = objNotes.CommentDate; DBAdditionalNote.Comments = objNotes.Comments; DBAdditionalNote.LastModifiedById = objNotes.LastModifiedById; DBAdditionalNote.LastMidifiedDateTime = DateTime.Now; if (objNotes.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.AdditionalNotes.InsertOnSubmit(DBAdditionalNote); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clAbsentReason, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool Save(DayCarePL.RelationshipProperties objRelationship) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clRelationship, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); Relationship DBRelationship = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clRelationship, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objRelationship.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBRelationship = new Relationship(); DBRelationship.Id = System.Guid.NewGuid(); } else { DBRelationship = db.Relationships.SingleOrDefault(u => u.Id.Equals(objRelationship.Id)); } DBRelationship.Name = objRelationship.Name; DBRelationship.SchoolId = objRelationship.SchoolId; DBRelationship.Active = objRelationship.Active; DBRelationship.Comments = objRelationship.Comments; DBRelationship.LastModifiedById = objRelationship.LastModifiedById; DBRelationship.LastModifiedDatetime = DateTime.Now; if (objRelationship.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.Relationships.InsertOnSubmit(DBRelationship); } db.SubmitChanges(); return(true); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clRelationship, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(false); } }
public static bool Save(DayCarePL.ChargeCodeProperties objChargesCode) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clChargeCode, "Save", "Save method called", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); ChargeCode DBChargeCode = null; bool result = false; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clChargeCode, "Save", "Debug Save called", DayCarePL.Common.GUID_DEFAULT); if (objChargesCode.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBChargeCode = new ChargeCode(); DBChargeCode.Id = Guid.NewGuid(); DBChargeCode.CreatedDateTime = DateTime.Now; DBChargeCode.CreatedById = objChargesCode.CreatedById; } else { DBChargeCode = db.ChargeCodes.SingleOrDefault(cc => cc.Id.Equals(objChargesCode.Id)); } DBChargeCode.LastModifiedDatetime = DateTime.Now; DBChargeCode.LastModifiedById = objChargesCode.LastModifiedById; DBChargeCode.Name = objChargesCode.Name; DBChargeCode.Category = objChargesCode.Category; DBChargeCode.DebitCrdit = objChargesCode.DebitCrdit; if (objChargesCode.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.ChargeCodes.InsertOnSubmit(DBChargeCode); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clChargeCode, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool Save(DayCarePL.FeesPeriodProperties objFeesPeriod) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clFeesPeriod, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); FeesPeriod DBFeesPeriod = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clFeesPeriod, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objFeesPeriod.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBFeesPeriod = new FeesPeriod(); DBFeesPeriod.Id = System.Guid.NewGuid(); DBFeesPeriod.CreatedDateTime = DateTime.Now; DBFeesPeriod.CreatedById = objFeesPeriod.CreatedById; } else { DBFeesPeriod = db.FeesPeriods.SingleOrDefault(F => F.Id.Equals(objFeesPeriod.Id)); } DBFeesPeriod.LastModifiedById = objFeesPeriod.LastModifiedById; DBFeesPeriod.LastModifiedDatetime = DateTime.Now; DBFeesPeriod.Name = objFeesPeriod.Name; DBFeesPeriod.Active = objFeesPeriod.Active; if (objFeesPeriod.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.FeesPeriods.InsertOnSubmit(DBFeesPeriod); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clFeesPeriod, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool ExportStafftoStaffSchoolYear(Guid StaffId, Guid SchoolId, Guid SchoolYearId, bool Active, System.Data.Common.DbTransaction tran, DayCareDataContext dbold) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clStaffSchoolYear, "ExportStafftoStaffSchoolYear", "Execute ExportStafftoStaffSchoolYear Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = dbold; db.Transaction = tran; StaffSchoolYear DBStaffSchoolYear = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clStaffSchoolYear, "ExportStafftoStaffSchoolYear", "Debug ExportStafftoStaffSchoolYear Method", DayCarePL.Common.GUID_DEFAULT); //Guid SchoolYearId = (from sy in db.SchoolYears // where sy.CurrentId.Equals(true) && sy.SchoolId.Equals(SchoolId) // select sy.Id).SingleOrDefault(); int staffcount = (from ssy in db.StaffSchoolYears where ssy.SchoolYearId.Equals(SchoolYearId) && ssy.StaffId.Equals(StaffId) select ssy.Id).Count(); if (staffcount == 0) { DBStaffSchoolYear = new StaffSchoolYear(); DBStaffSchoolYear.Id = Guid.NewGuid(); DBStaffSchoolYear.StaffId = StaffId; DBStaffSchoolYear.SchoolYearId = SchoolYearId; DBStaffSchoolYear.active = Active; db.StaffSchoolYears.InsertOnSubmit(DBStaffSchoolYear); db.SubmitChanges(); } return(true); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clStaffSchoolYear, "ExportStafftoStaffSchoolYear", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(false); } }
public static bool Save(DayCarePL.StaffAttendenceHistoryProperties objStaffAttendance) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clAbsentReason, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); StaffAttendenceHistory DBStaffAttendance = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clAbsentReason, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objStaffAttendance.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBStaffAttendance = new StaffAttendenceHistory(); DBStaffAttendance.Id = System.Guid.NewGuid(); DBStaffAttendance.CreatedDateTime = DateTime.Now; } else { DBStaffAttendance = db.StaffAttendenceHistories.SingleOrDefault(A => A.Id.Equals(objStaffAttendance.Id)); } DBStaffAttendance.StaffSchoolYearId = objStaffAttendance.StaffSchoolYearId; DBStaffAttendance.CheckInCheckOutDateTime = objStaffAttendance.CheckInCheckOutDateTime; DBStaffAttendance.CheckInCheckOut = objStaffAttendance.CheckInCheckOut; if (objStaffAttendance.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.StaffAttendenceHistories.InsertOnSubmit(DBStaffAttendance); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clAbsentReason, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool Save(DayCarePL.FontProperties objFont) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clFont, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); Font DBFont = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clFont, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (objFont.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBFont = new Font(); DBFont.Id = System.Guid.NewGuid(); } else { DBFont = db.Fonts.SingleOrDefault(F => F.Id.Equals(objFont.Id)); } DBFont.Name = objFont.Name; DBFont.Color = objFont.Color; DBFont.Size = objFont.Size; DBFont.Active = objFont.Active; if (objFont.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.Fonts.InsertOnSubmit(DBFont); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clFont, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static DayCarePL.ResultStatus Save(string UserId, string DateTime) { clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); DayCarePL.ResultStatus objResultStatus = new DayCarePL.ResultStatus(); SyncLog DBSyncLog = null; try { DBSyncLog = new SyncLog(); DBSyncLog.Id = Guid.NewGuid(); DBSyncLog.UserId = new Guid(UserId); DBSyncLog.Datetime = Convert.ToDateTime(DateTime); db.SyncLogs.InsertOnSubmit(DBSyncLog); db.SubmitChanges(); objResultStatus.Status = "true"; } catch { objResultStatus.Status = "false"; } return(objResultStatus); }
public static bool Save(DayCarePL.StaffProperties objStaff) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clMyAccount, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); bool result = false; DayCareDataContext db = new DayCareDataContext(); Staff DBStaff = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clMyAccount, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (!objStaff.Id.Equals(DayCarePL.Common.GUID_DEFAULT)) { DBStaff = db.Staffs.SingleOrDefault(s => s.Id.Equals(objStaff.Id)); } DBStaff.LastModifiedById = objStaff.LastModifiedById; DBStaff.LastModifiedDatetime = DateTime.Now; DBStaff.FirstName = objStaff.FirstName; DBStaff.LastName = objStaff.LastName; DBStaff.UserName = objStaff.UserName; DBStaff.Password = objStaff.Password; DBStaff.code = objStaff.Code; if (objStaff.Id.Equals(DayCarePL.Common.GUID_DEFAULT)) { db.Staffs.InsertOnSubmit(DBStaff); } db.SubmitChanges(); result = true; } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clMyAccount, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public static bool Save(List <DayCarePL.FamilyPaymentProperties> lstFamilyPayment) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clFamilyPayment, "Save", "Save method called", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); System.Data.Common.DbTransaction Tran = null; Payment DBPayment = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clFamilyPayment, "Save", "Debug Save called", DayCarePL.Common.GUID_DEFAULT); if (db.Connection.State == System.Data.ConnectionState.Closed) { db.Connection.Open(); } Tran = db.Connection.BeginTransaction(); db.Transaction = Tran; int cntSuccess = 0; foreach (DayCarePL.FamilyPaymentProperties objFamilyPayment in lstFamilyPayment) { try { if (objFamilyPayment.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBPayment = new Payment(); DBPayment.Id = Guid.NewGuid(); DBPayment.CreatedDateTime = DateTime.Now; DBPayment.CreatedById = objFamilyPayment.CreatedById; } else { DBPayment = db.Payments.FirstOrDefault(i => i.Id.Equals(objFamilyPayment.Id)); } DBPayment.SchoolYearId = objFamilyPayment.SchoolYearId; DBPayment.ChildFamilyId = objFamilyPayment.ChildFamilyId; DBPayment.PostDate = objFamilyPayment.PostDate; DBPayment.PaymentMethod = objFamilyPayment.PaymentMethod; DBPayment.PaymentDetail = objFamilyPayment.PaymentDetail; DBPayment.Amount = objFamilyPayment.Amount; DBPayment.LastModifiedDatetime = DateTime.Now; DBPayment.LastModifiedById = objFamilyPayment.LastModifiedById; if (objFamilyPayment.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.Payments.InsertOnSubmit(DBPayment); } db.SubmitChanges(); Ledger DBLedger = new Ledger(); if (objFamilyPayment.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBLedger.Id = Guid.NewGuid(); DBLedger.PaymentId = DBPayment.Id; DBLedger.CreatedById = (objFamilyPayment.CreatedById).Value; DBLedger.CreatedDateTime = DateTime.Now; } else { DBLedger = db.Ledgers.FirstOrDefault(i => i.PaymentId.Equals(objFamilyPayment.Id)); } DBLedger.SchoolYearId = objFamilyPayment.SchoolYearId; DBLedger.ChildFamilyId = objFamilyPayment.ChildFamilyId; DBLedger.TransactionDate = Convert.ToDateTime(objFamilyPayment.PostDate); string paymentmethod = ""; if (!string.IsNullOrEmpty(objFamilyPayment.PaymentMethod)) { switch (objFamilyPayment.PaymentMethod) { case "0": paymentmethod = "Cash"; break; case "1": paymentmethod = "Check"; break; case "2": paymentmethod = "Credit"; break; } } DBLedger.PaymentMethodId = Convert.ToInt16(objFamilyPayment.PaymentMethod); DBLedger.Comment = paymentmethod + (string.IsNullOrEmpty(objFamilyPayment.PaymentDetail) ? "" : "-" + objFamilyPayment.PaymentDetail); DBLedger.Debit = 0; DBLedger.Credit = objFamilyPayment.Amount; DBLedger.Balance = DBLedger.Debit - DBLedger.Credit; DBLedger.AllowEdit = true; DBLedger.LastModifiedDatetime = DateTime.Now; DBLedger.LastModifiedById = objFamilyPayment.LastModifiedById; if (objFamilyPayment.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.Ledgers.InsertOnSubmit(DBLedger); } db.SubmitChanges(); //update closing balance on 10 May 2013 By Akash try { Guid SchoolId = clSchool.GetSchoolIdbySchoolYearId(objFamilyPayment.SchoolYearId.Value); if (clSchoolYear.IsSelectedYearPrevYearORNot(SchoolId, objFamilyPayment.SchoolYearId.Value))//only prev year can only allow to edit closing balance. because in current year or in future year closing balance is not genrated in these year { clSchoolYear.UpdateClosingBalance(SchoolId, objFamilyPayment.SchoolYearId.Value, objFamilyPayment.ChildFamilyId.Value, Tran, db); } } catch { } //End cntSuccess++; } catch { } } Tran.Commit(); if (cntSuccess > 0) { return(true); } else { return(false); } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clFamilyPayment, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); if (Tran != null) { Tran.Rollback(); } return(false); } }
public static bool SaveProgramWithOtherSchoolYear(Guid OldCurrentSchoolYearId, Guid CurrentSchoolYearId, Guid SchoolId, System.Data.Common.DbTransaction tran, DayCareDataContext dbold) { DayCareDataContext db = dbold; db.Transaction = tran; SchoolProgram DBSchoolProgram = null; SchoolProgramFeesDetail DBSchoolProgramFeesDetail = null; try { /* Guid currentschoolyearid = (from sy in db.SchoolYears * where sy.CurrentId.Equals(true) && sy.SchoolId.Equals(SchoolId) * select sy.Id).SingleOrDefault(); */ Guid currentschoolyearid = CurrentSchoolYearId; List <Guid> lstProgram = (from sp in db.SchoolPrograms where sp.SchoolYearId.Equals(OldCurrentSchoolYearId) && sp.Active.Equals(true) && !(from sp1 in db.SchoolPrograms where sp1.SchoolYearId.Equals(currentschoolyearid) select sp1.ProgUniqueId).Contains(sp.ProgUniqueId) select sp.Id).ToList(); ProgClassRoom DBProgClassRoom = null; foreach (Guid ProgramId in lstProgram) { //try //{ SchoolProgram DBSchoolProgramOld = db.SchoolPrograms.FirstOrDefault(i => i.Id.Equals(ProgramId)); if (DBSchoolProgramOld != null) { DBSchoolProgram = new SchoolProgram(); //DBSchoolProgram = DBSchoolProgramOld; DBSchoolProgram.Id = Guid.NewGuid(); DBSchoolProgram.Title = DBSchoolProgramOld.Title; DBSchoolProgram.Comments = DBSchoolProgramOld.Comments; DBSchoolProgram.Active = DBSchoolProgramOld.Active; DBSchoolProgram.IsPrimary = DBSchoolProgramOld.IsPrimary; DBSchoolProgram.CreatedById = DBSchoolProgramOld.CreatedById; DBSchoolProgram.LastModifiedById = DBSchoolProgramOld.LastModifiedById; DBSchoolProgram.ProgUniqueId = DBSchoolProgramOld.ProgUniqueId; DBSchoolProgram.SchoolYearId = CurrentSchoolYearId; DBSchoolProgram.CreatedDateTime = DateTime.Now; DBSchoolProgram.LastModifiedDatetime = DateTime.Now; db.SchoolPrograms.InsertOnSubmit(DBSchoolProgram); db.SubmitChanges(); //Automatic add to progclassroom change on 28-Aug-2012 by Akash List <Guid> lstProgClass = (from pcr in db.ProgClassRooms where pcr.Active.Equals(true) && pcr.SchoolProgramId.Equals(ProgramId) select pcr.ClassRoomId).ToList(); foreach (Guid ClassroomId in lstProgClass) { DBProgClassRoom = new ProgClassRoom(); DBProgClassRoom.Id = Guid.NewGuid(); DBProgClassRoom.SchoolProgramId = DBSchoolProgram.Id; DBProgClassRoom.ClassRoomId = ClassroomId; DBProgClassRoom.Active = true; DBProgClassRoom.CreatedDateTime = DateTime.Now; DBProgClassRoom.LastModifiedDatetime = DateTime.Now; DBProgClassRoom.CreatedById = DBSchoolProgramOld.CreatedById; DBProgClassRoom.LastModifiedById = DBSchoolProgramOld.LastModifiedById; db.ProgClassRooms.InsertOnSubmit(DBProgClassRoom); db.SubmitChanges(); } } var lstDBSchoolProgramFeesDetailOld = db.SchoolProgramFeesDetails.Where(i => i.SchoolProgramId.Equals(ProgramId)); if (lstDBSchoolProgramFeesDetailOld != null) { foreach (SchoolProgramFeesDetail objSchoolProgramFeesDetails in lstDBSchoolProgramFeesDetailOld) { DBSchoolProgramFeesDetail = new SchoolProgramFeesDetail(); DBSchoolProgramFeesDetail.Id = Guid.NewGuid(); //DBSchoolProgramFeesDetail = objSchoolProgramFeesDetails; DBSchoolProgramFeesDetail.SchoolProgramId = DBSchoolProgram.Id; DBSchoolProgramFeesDetail.Fees = objSchoolProgramFeesDetails.Fees; DBSchoolProgramFeesDetail.FeesPeriodId = objSchoolProgramFeesDetails.FeesPeriodId; DBSchoolProgramFeesDetail.EffectiveYearDate = objSchoolProgramFeesDetails.EffectiveYearDate; DBSchoolProgramFeesDetail.EffectiveMonthDay = objSchoolProgramFeesDetails.EffectiveMonthDay; DBSchoolProgramFeesDetail.EffectiveWeekDay = objSchoolProgramFeesDetails.EffectiveWeekDay; DBSchoolProgramFeesDetail.CreatedById = objSchoolProgramFeesDetails.CreatedById; DBSchoolProgramFeesDetail.LastModifiedById = objSchoolProgramFeesDetails.LastModifiedById; DBSchoolProgramFeesDetail.CreatedDateTime = DateTime.Now; DBSchoolProgramFeesDetail.LastModifiedDatetime = DateTime.Now; db.SchoolProgramFeesDetails.InsertOnSubmit(DBSchoolProgramFeesDetail); db.SubmitChanges(); } } //} //catch //{ } } return(true); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clSchoolYear, "SaveProgramWithOtherSchoolYear", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(false); } }
public static bool Delete(Guid Id) { bool result = false; DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clFamilyPayment, "Delete", "Delete Method", DayCarePL.Common.GUID_DEFAULT); //SqlConnection conn = clConnection.CreateConnection(); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); System.Data.Common.DbTransaction Tran = null; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clFamilyPayment, "Delete", "Debug Delete Method", DayCarePL.Common.GUID_DEFAULT); //clConnection.OpenConnection(conn); //SqlCommand cmd; //cmd = clConnection.CreateCommand("spDeleteFamilyPayment", conn); //cmd.Parameters.Add(clConnection.GetInputParameter("@Id", Id)); //object Result = cmd.ExecuteScalar(); //result = Convert.ToBoolean(Result); if (db.Connection.State == System.Data.ConnectionState.Closed) { db.Connection.Open(); } Tran = db.Connection.BeginTransaction(); db.Transaction = Tran; Ledger DBLedger = db.Ledgers.FirstOrDefault(i => i.PaymentId.Equals(Id)); if (DBLedger != null) { db.Ledgers.DeleteOnSubmit(DBLedger); db.SubmitChanges(); } else { Tran.Rollback(); result = false; } Payment DBPayment = db.Payments.FirstOrDefault(i => i.Id.Equals(Id)); if (DBPayment != null) { db.Payments.DeleteOnSubmit(DBPayment); db.SubmitChanges(); Tran.Commit(); result = true; } else { result = false; } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clFamilyPayment, "Delete", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; if (Tran != null) { Tran.Rollback(); } } return(result); }
public static Guid Save(DayCarePL.SchoolYearProperties objSchoolYear, Guid OldCurrentSchoolYearId) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clSchoolYear, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); System.Data.Common.DbTransaction tran = null; SchoolYear DBSchoolYear = null; bool result = true; //Guid LastCurrentId = new Guid(); try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clSchoolYear, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); if (db.Connection.State == System.Data.ConnectionState.Closed) { db.Connection.Open(); } tran = db.Connection.BeginTransaction(); db.Transaction = tran; //if (objSchoolYear.CurrentId == true) if (objSchoolYear.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT) && objSchoolYear.CurrentId == false) // remove condition if you wish to import staff and programs on update event. { DBSchoolYear = new SchoolYear(); DBSchoolYear = db.SchoolYears.SingleOrDefault(Currentid => Currentid.CurrentId.Equals(true) && Currentid.SchoolId == objSchoolYear.SchoolId); if (DBSchoolYear != null) { OldCurrentSchoolYearId = DBSchoolYear.Id; // DBSchoolYear.CurrentId = false; // db.SubmitChanges(); } } if (objSchoolYear.CurrentId == true) { DBSchoolYear = new SchoolYear(); DBSchoolYear = db.SchoolYears.SingleOrDefault(Currentid => Currentid.CurrentId.Equals(true) && Currentid.SchoolId == objSchoolYear.SchoolId); if (DBSchoolYear != null) { OldCurrentSchoolYearId = DBSchoolYear.Id; DBSchoolYear.CurrentId = false; db.SubmitChanges(); } } if (objSchoolYear.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { DBSchoolYear = new SchoolYear(); DBSchoolYear.Id = System.Guid.NewGuid(); DBSchoolYear.CreatedById = objSchoolYear.CreatedById; DBSchoolYear.CreatedDateTime = DateTime.Now; } else { DBSchoolYear = db.SchoolYears.SingleOrDefault(u => u.Id.Equals(objSchoolYear.Id)); } DBSchoolYear.Year = objSchoolYear.Year; DBSchoolYear.SchoolId = objSchoolYear.SchoolId; DBSchoolYear.StartDate = objSchoolYear.StartDate; DBSchoolYear.EndDate = objSchoolYear.EndDate; DBSchoolYear.CurrentId = objSchoolYear.CurrentId; DBSchoolYear.Comments = objSchoolYear.Comments; DBSchoolYear.LastModifiedById = objSchoolYear.LastModifiedById; DBSchoolYear.LastModifiedDatetime = DateTime.Now; //if (objSchoolYear.CurrentId == true) //{ //if (!OldCurrentSchoolYearId.Equals(DBSchoolYear.Id)) //{ DBSchoolYear.OldCurrentSchoolYearId = OldCurrentSchoolYearId; //} //} if (objSchoolYear.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { db.SchoolYears.InsertOnSubmit(DBSchoolYear); } db.SubmitChanges(); if (objSchoolYear.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) // add ! (not equal to if you wish to import staff and programs on update event. //if (objSchoolYear.CurrentId == true) { if (DayCareDAL.clStaffSchoolYear.ImportAllActiveStaff(DBSchoolYear.Id, objSchoolYear.SchoolId, OldCurrentSchoolYearId, tran, db)) { //tran.Commit(); result = true; } else { //tran.Rollback(); result = false; } //clChildFamily objChildFamily = new clChildFamily(); //if (objChildFamily.ImportAllActiveChildFamily(DBSchoolYear.Id, objSchoolYear.SchoolId, OldCurrentSchoolYearId, tran, db)) //{ // //tran.Commit(); // result = true; // if (objChildFamily.ImportActiveChildFamilyCount > 0) // { // if (clChildSchoolYear.ImportAllActiveChild(objSchoolYear.Id, objSchoolYear.SchoolId, OldCurrentSchoolYearId, tran, db)) // { // result = true; // } // else // { // result = false; // } // } //} //else //{ // //tran.Rollback(); // result = false; //} //importschoolProgram Import if (result == true) { if (!OldCurrentSchoolYearId.Equals(DBSchoolYear.Id)) { if (SaveProgramWithOtherSchoolYear(OldCurrentSchoolYearId, DBSchoolYear.Id, objSchoolYear.SchoolId, tran, db)) { result = true; } else { result = false; } } } //end //if (result) //{ // tran.Commit(); //} //else //{ // tran.Rollback(); //} } else { //tran.Commit(); result = true; } #region "import classroom when changes current year" //start---import classroom when changes current year if (result == true) { if (objSchoolYear.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { if (DayCareDAL.clClassRoom.ImportAllActiveClassRoom(DBSchoolYear.Id, objSchoolYear.SchoolId, OldCurrentSchoolYearId, tran, db)) { //tran.Commit(); result = true; //update ClassRoomSchoolYearId into ProgClassRoom table. if (DayCareDAL.clClassRoom.UpdateClassRoomSchoolYearID(DBSchoolYear.Id, OldCurrentSchoolYearId, tran, db)) { result = true; } else { result = false; } //update classroomschoolyearid into last year, when first time added if (DayCareDAL.clClassRoom.UpdateLastAddedYearClassRoomSchoolYearID(DBSchoolYear.Id, OldCurrentSchoolYearId, tran, db)) { result = true; } else { result = false; } } else { //tran.Rollback(); result = false; } } else { result = true; } } //end---import classroom when changes current year #endregion if (result == true) { if (objSchoolYear.CurrentId == true) { if (!OldCurrentSchoolYearId.Equals(DBSchoolYear.Id)) { if (UpdateClosingBalance(objSchoolYear.SchoolId, OldCurrentSchoolYearId, null, tran, db)) { result = true; } else { result = false; } } } } if (result) { tran.Commit(); return(DBSchoolYear.Id); } else { tran.Rollback(); return(new Guid()); } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clSchoolYear, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); if (tran != null) { tran.Rollback(); } return(new Guid()); } finally { if (db.Connection.State == System.Data.ConnectionState.Open) { db.Connection.Close(); } } }