public void save(SmsMis.Models.Console.Admin.Type Type, bool isNew) { try { using (var context = new SmsMisDB()) { Type.AddDateTime = DateTime.Now; var entry = context.Entry(Type); if (entry != null) { if (isNew) { Type.TypeCode = Functions.getNextPk("Type", Type.TypeCode, Type.CompanyCode); if (Type.TypeBranch != null && Type.TypeBranch.Count > 0) { Type.TypeBranch.ToList().ForEach(i => { i.TypeCode = Type.TypeCode; }); } entry.State = EntityState.Added; } else { if (Type.TypeBranch != null && Type.TypeBranch.Count > 0) { Type.TypeBranch.ToList().ForEach(i => { i.TypeCode = Type.TypeCode; }); } entry.State = EntityState.Modified; } if (Type.TypeBranch != null && Type.TypeBranch.Count > 0) { Type.TypeBranch.ToList <TypeBranch>().ForEach(x => context.Entry(x).State = EntityState.Added); } context.TypeBranch.ToList().Where(i => i.TypeCode == Type.TypeCode && i.CompanyCode == Type.CompanyCode).ToList <TypeBranch>().ForEach(s => context.Entry(s).State = EntityState.Deleted); context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public void save(Religion Religion) { try { using (var context = new SmsMisDB()) { Religion.AddDateTime = DateTime.Now; var entry = context.Entry(Religion); if (entry != null) { if (Religion.ReligionCode == 0) { Religion.ReligionCode = Functions.getNextPk("Religion", Religion.ReligionCode, 0); entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public void save(MarketingReference MarketingReference) { try { using (var context = new SmsMisDB()) { MarketingReference.AddDateTime = DateTime.Now; var entry = context.Entry(MarketingReference); if (entry != null) { if (MarketingReference.MarketingReferenceCode == 0) { MarketingReference.MarketingReferenceCode = Functions.getNextPk("MarketingReference", MarketingReference.MarketingReferenceCode, 0); entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public void delete(Branch branch) { try { var context = new SmsMisDB(); context.Branch.Attach(branch); var entry = context.Entry(branch); if (entry != null) { entry.State = EntityState.Deleted; context.BranchContactPerson.ToList <BranchContactPerson>().Where(i => i.CompanyCode == branch.CompanyCode && i.BranchCode == branch.BranchCode && i.SrNo > 0).ToList <BranchContactPerson>().ForEach(s => context.Entry(s).State = EntityState.Deleted); context.SaveChanges(); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } catch (Exception ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } }
public void delete(Department Department) { try { var context = new SmsMisDB(); context.Department.Attach(Department); var entry = context.Entry(Department); if (entry != null) { entry.State = EntityState.Deleted; context.DepartmentBranch.ToList().Where(i => i.DepartmentCode == Department.DepartmentCode && i.CompanyCode == Department.CompanyCode).ToList <DepartmentBranch>().ForEach(s => context.Entry(s).State = EntityState.Deleted); context.SaveChanges(); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } catch (Exception ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } }
public void save(SeatType SeatType) { try { using (var context = new SmsMisDB()) { SeatType.AddDateTime = DateTime.Now; var entry = context.Entry(SeatType); if (entry != null) { if (SeatType.SeatTypeCode == 0) { SeatType.SeatTypeCode = Functions.getNextPk("SeatType", SeatType.SeatTypeCode, SeatType.CompanyCode); entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public void save(BranchBuilding BranchBuilding) { try { using (var context = new SmsMisDB()) { BranchBuilding.AddDateTime = DateTime.Now; var entry = context.Entry(BranchBuilding); if (entry != null) { if (BranchBuilding.BuildingCode == 0) { BranchBuilding.BuildingCode = Functions.getNextPk("BranchBuilding", BranchBuilding.BuildingCode, BranchBuilding.CompanyCode, BranchBuilding.BranchCode); entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public void save(FeeParticular FeeParticular) { try { using (var context = new SmsMisDB()) { FeeParticular.AddDateTime = DateTime.Now; var entry = context.Entry(FeeParticular); if (entry != null) { if (FeeParticular.ParticularCode == 0) { FeeParticular.ParticularCode = Functions.getNextPk("FeeParticular", FeeParticular.ParticularCode, FeeParticular.CompanyCode); entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public void save(Department Department, bool isNew) { try { using (var context = new SmsMisDB()) { Department.AddDateTime = DateTime.Now; var entry = context.Entry(Department); if (entry != null) { if (isNew) { Department.DepartmentCode = Functions.getNextPk("Department", Department.DepartmentCode, Department.CompanyCode); if (Department.DepartmentBranch != null && Department.DepartmentBranch.Count > 0) { Department.DepartmentBranch.ToList().ForEach(i => { i.DepartmentCode = Department.DepartmentCode; }); } entry.State = EntityState.Added; } else { if (Department.DepartmentBranch != null && Department.DepartmentBranch.Count > 0) { Department.DepartmentBranch.ToList().ForEach(i => { i.DepartmentCode = Department.DepartmentCode; }); } entry.State = EntityState.Modified; } if (Department.DepartmentBranch != null && Department.DepartmentBranch.Count > 0) { Department.DepartmentBranch.ToList <DepartmentBranch>().ForEach(x => context.Entry(x).State = EntityState.Added); } context.DepartmentBranch.ToList().Where(i => i.DepartmentCode == Department.DepartmentCode && i.CompanyCode == Department.CompanyCode).ToList <DepartmentBranch>().ForEach(s => context.Entry(s).State = EntityState.Deleted); context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public void delete(FeeParticular FeeParticular) { try { var context = new SmsMisDB(); context.FeeParticular.Attach(FeeParticular); var entry = context.Entry(FeeParticular); if (entry != null) { entry.State = EntityState.Deleted; context.SaveChanges(); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public void delete(Religion Religion) { try { var context = new SmsMisDB(); context.Religion.Attach(Religion); var entry = context.Entry(Religion); if (entry != null) { entry.State = EntityState.Deleted; context.SaveChanges(); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } catch (Exception ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } }
public void save(Branch branch, string imgFile, string path) { try { using (var context = new SmsMisDB()) { if (imgFile != string.Empty) { branch.LogoPath = string.Concat("../upload/Branches/", branch.CompanyCode, '_', branch.BranchCode, ".png"); } branch.AddDateTime = DateTime.Now; var entry = context.Entry(branch); if (entry != null) { if (branch.BranchCode == 0) { branch.BranchCode = Functions.getNextPk("Branch", branch.BranchCode, branch.CompanyCode); if (imgFile != string.Empty) { branch.LogoPath = string.Concat("../upload/Branches/", branch.CompanyCode, '_', branch.BranchCode, ".png"); } if (branch.BranchContactPersonList != null) { branch.BranchContactPersonList.ToList <BranchContactPerson>().ForEach(i => i.BranchCode = branch.BranchCode); } entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } if (branch.BranchContactPersonList != null) { branch.BranchContactPersonList.ToList <BranchContactPerson>().ForEach(entry1 => context.Entry(entry1).State = EntityState.Added); } context.BranchContactPerson.ToList <BranchContactPerson>().Where(i => i.CompanyCode == branch.CompanyCode && i.BranchCode == branch.BranchCode && i.SrNo > 0).ToList <BranchContactPerson>().ForEach(s => context.Entry(s).State = EntityState.Deleted); context.SaveChanges(); try { char[] split = { ',' }; string base64Image = imgFile.Split(split)[1];// data:image/jpeg;base64, byte[] imageBytes = Convert.FromBase64String(base64Image); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); ms.Write(imageBytes, 0, imageBytes.Length); Image image = Image.FromStream(ms, true); image.Save(string.Concat(path, branch.CompanyCode, '_', branch.BranchCode, ".png")); ms.Close(); ms.Dispose(); } catch (Exception ex) { } } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public void delete(List <BranchSession> branchSession, int iCompanyCode, int iBranchCode) { try { using (var context = new SmsMisDB()) { if (branchSession != null) { branchSession.ToList <BranchSession>().ForEach(i => i.AddDateTime = DateTime.Now); context.BranchSession.ToList <BranchSession>().Where(s => s.CompanyCode == branchSession[0].CompanyCode && s.BranchCode == branchSession[0].BranchCode).ToList().ForEach(entry2 => context.Entry(entry2).State = EntityState.Deleted); } //else // context.BranchSession.ToList<BranchSession>().Where(s => s.CompanyCode == iCompanyCode && s.BranchCode == iBranchCode).ToList().ForEach(entry2 => context.Entry(entry2).State = EntityState.Deleted); context.SaveChanges(); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public void save(List <ClassCourseSubject> ClassCourseSubject, int iCompanyCode, int iBranchCode, int iClassCode, int iCourseCode) { try { using (var context = new SmsMisDB()) { if (ClassCourseSubject != null) { ClassCourseSubject.ToList <ClassCourseSubject>().ForEach(i => i.AddDateTime = DateTime.Now); foreach (var row in ClassCourseSubject) { context.ClassCourseSubject.Add(row); } context.ClassCourseSubject.ToList <ClassCourseSubject>().Where(s => s.CompanyCode == iCompanyCode && s.BranchCode == iBranchCode && s.ClassCode == iClassCode && s.CourseCode == iCourseCode).ToList().ForEach(entry2 => context.Entry(entry2).State = System.Data.Entity.EntityState.Deleted); } else { context.ClassCourseSubject.ToList <ClassCourseSubject>().Where(s => s.CompanyCode == iCompanyCode && s.BranchCode == iBranchCode && s.ClassCode == iClassCode && s.CourseCode == iCourseCode).ToList().ForEach(entry2 => context.Entry(entry2).State = System.Data.Entity.EntityState.Deleted); } context.SaveChanges(); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } }