public IList <object> SelectAllStudentsByCompanyBranchSession(string strValues) { string[] strArray = strValues.ToString().Split('/'); int companyCode = Convert.ToInt32(strArray[0]); int BranchCode = Convert.ToInt32(strArray[1]); int SessionCode = Convert.ToInt32(strArray[2]); SmsMisDB db = new SmsMisDB(); var otherItems = (from br in db.Student select new { CompanyCode = br.CompanyCode, BranchCode = br.BranchCode, SessionCode = br.SessionCode, FirstName = br.FirstName, FullName = br.FullName, StudentNo = br.StudentNo }). Where(s => s.CompanyCode == companyCode && s.BranchCode == BranchCode && s.SessionCode == SessionCode) .OrderBy(opr => opr.StudentNo) .ToArray(); return(otherItems); ////return db.Student.Where(s => s.StudentRollNo == null && s.CompanyCode == companyCode //// && s.BranchCode == BranchCode //// && s.SessionCode == SessionCode //// ).ToList(); }
//public InstrumentType SelectByIDs(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(InstrumentType InstrumentType, string userId) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(InstrumentType); if (entry != null) { InstrumentType.AddDateTime = DateTime.Now; InstrumentType.AddByUserId = userId; if (InstrumentType.InstrumentCode == 0) { InstrumentType.InstrumentCode = Functions.getNextPk("InstrumentType", InstrumentType.InstrumentCode, 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 FeeReceipt SelectByIDs(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(FeeReceipt FeeReceipt, string userId) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(FeeReceipt); if (entry != null) { FeeReceipt.AddDateTime = DateTime.Now; FeeReceipt.AddByUserId = userId; if (FeeReceipt.ReceiptNo == 0) { FeeReceipt.ReceiptNo = Functions.getNextPk("FeeReceipt", "ReceiptNo", string.Concat(" Where CompanyCode = ", FeeReceipt.CompanyCode, " AND BranchCode = ", FeeReceipt.BranchCode)); entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { } catch (Exception ex) { } }
public IList <CostCenter> SelectAllCostCenterBranch(int CompanyCode, int BranchCode) { SmsMisDB db = new SmsMisDB(); var costCenterCodes = db.CostCenterBranch.Where(x => x.CompanyCode == CompanyCode && x.BranchCode == BranchCode).Select(x => x.CostCenterCode).ToList(); return(db.CostCenter.Where(x => costCenterCodes.Contains(x.CostCenterCode)).ToList()); }
public void save(StudentBillingCycle StudentBillingCycle, string userId, bool isNew) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(StudentBillingCycle); if (entry != null) { if (isNew) { entry.State = System.Data.Entity.EntityState.Added; } else { entry.State = System.Data.Entity.EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { } catch (Exception ex) { } }
//public Currency SelectByIDs(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(Currency Currency, string userId) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(Currency); if (entry != null) { Currency.AddDateTime = DateTime.Now; Currency.AddByUserId = userId; if (Currency.CurrencyCode == 0) { Currency.CurrencyCode = Functions.getNextPk("Currency", "CurrencyCode", string.Empty); 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(IList <VoucherTypeBranch> VoucherTypeBranch, string userId, int CompanyCode, int BranchCode) { try { using (var context = new SmsMisDB()) { if (VoucherTypeBranch != null) { VoucherTypeBranch.ToList <VoucherTypeBranch>().ForEach(i => i.AddDateTime = DateTime.Now); VoucherTypeBranch.ToList <VoucherTypeBranch>().ForEach(i => i.AddByUserId = userId); VoucherTypeBranch.ToList <VoucherTypeBranch>().ForEach(i => i.CompanyCode = CompanyCode); VoucherTypeBranch.ToList <VoucherTypeBranch>().ForEach(i => i.BranchCode = BranchCode); foreach (var row in VoucherTypeBranch) { context.VoucherTypeBranch.Add(row); } context.VoucherTypeBranch.ToList <VoucherTypeBranch>().Where(s => s.CompanyCode == CompanyCode && s.BranchCode == BranchCode && s.VoucherCode == VoucherTypeBranch[0].VoucherCode).ToList().ForEach(entry2 => context.Entry(entry2).State = EntityState.Deleted); } else { context.VoucherTypeBranch.ToList <VoucherTypeBranch>().Where(s => s.CompanyCode == CompanyCode && s.BranchCode == BranchCode && s.VoucherCode == VoucherTypeBranch[0].VoucherCode).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 FeeTerm SelectByIDs(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(FeeTerm FeeTerm, string userId) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(FeeTerm); if (entry != null) { FeeTerm.AddDateTime = DateTime.Now; FeeTerm.AddByUserId = userId; if (FeeTerm.FeeTermCode == 0) { FeeTerm.FeeTermCode = Functions.getNextPk("FeeTerm", FeeTerm.FeeTermCode, FeeTerm.CompanyCode); entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { } catch (Exception ex) { } }
public void delete(IList <VoucherTypeBranch> VoucherTypeBranch) { try { using (var context = new SmsMisDB()) { if (VoucherTypeBranch != null) { VoucherTypeBranch.ToList <VoucherTypeBranch>().ForEach(i => i.AddDateTime = DateTime.Now); VoucherTypeBranch.ToList <VoucherTypeBranch>().ForEach(i => i.CompanyCode = VoucherTypeBranch[0].CompanyCode); VoucherTypeBranch.ToList <VoucherTypeBranch>().ForEach(i => i.BranchCode = VoucherTypeBranch[0].BranchCode); context.VoucherTypeBranch.ToList <VoucherTypeBranch>().Where(s => s.CompanyCode == VoucherTypeBranch[0].CompanyCode && s.BranchCode == VoucherTypeBranch[0].BranchCode && s.VoucherCode == VoucherTypeBranch[0].VoucherCode).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 StudentFixedDiscount SelectByIDs(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(StudentFixedDiscount StudentFixedDiscount, string userId, bool isNew) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(StudentFixedDiscount); if (entry != null) { StudentFixedDiscount.AddDateTime = DateTime.Now; StudentFixedDiscount.AddByUserId = userId; if (isNew) { entry.State = System.Data.Entity.EntityState.Added; } else { entry.State = System.Data.Entity.EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public IList <object> getFeeBillMasterWithStudent(int CompanyCode, int BranchCode, int SessionCode) { SmsMisDB db = new SmsMisDB(); var otherItems = (from st in db.Student join fee in db.FeeBillMasters on st.CompanyCode equals fee.CompanyCode where st.BranchCode == fee.BranchCode && st.SessionCode == fee.SessionCode && st.StudentNo == fee.StudentNo join clas in db.Classes on st.CompanyCode equals clas.CompanyCode where clas.ClassCode == fee.ClassCode join session in db.Session on st.CompanyCode equals session.CompanyCode where session.SessionCode == fee.SessionCode select new { StudentNo = st.StudentNo, FullName = st.FullName, ChallanNo = fee.ChallanNo, SessionName = session.SessionName, ClassName = clas.ClassName, TotalAmount = fee.TotalAmount, DiscountAmount = fee.DiscountAmount, OutstandingAmount = fee.NetAmount, CompanyCode = fee.CompanyCode, BranchCode = fee.BranchCode, SessionCode = fee.SessionCode, }).Where(a => a.CompanyCode == CompanyCode && a.BranchCode == BranchCode && a.SessionCode == SessionCode).ToArray(); return(otherItems); }
public void save(Bank Bank, string userId) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(Bank); if (entry != null) { //Bank.AddDateTime = DateTime.Now; //Bank.UserId = userId; Bank bank = SelectBankByAccountCode(Bank.AccountCode, Bank.CompanyCode); if (bank == null) { //Bank.BankCode = Functions.getNextPk("Bank", "BankCode", " WHERE CompanyCode = "+ Bank.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 IList <AnalysisType> SelectAllBranchAnalysisType(int CompanyCode, int BranchCode) { SmsMisDB db = new SmsMisDB(); var analysisTypeCodes = db.AnalysisTypeBranch.Where(x => x.CompanyCode == CompanyCode && x.BranchCode == BranchCode).Select(x => x.AnalysisTypeCode).ToList(); return(db.AnalysisType.Where(x => analysisTypeCodes.Contains(x.AnalysisTypeCode)).ToList()); }
public IList <Project> SelectAllBranchProjects(int CompanyCode, int BranchCode) { SmsMisDB db = new SmsMisDB(); var projectCodes = db.ProjectBranch.Where(x => x.CompanyCode == CompanyCode && x.BranchCode == BranchCode).Select(x => x.ProjectCode).ToList(); var result = db.Project.Where(x => projectCodes.Contains(x.ProjectCode)).ToList(); return(result); }
public void save(InstrumentSerialMaster InstrumentSerialMaster, string userId, bool isNew) { try { using (var context = new SmsMisDB()) { var entrymain = context.Entry(InstrumentSerialMaster); if (entrymain != null) { InstrumentSerialMaster.AddDateTime = DateTime.Now; InstrumentSerialMaster.AddByUserId = userId; InstrumentSerialMaster.InstrumentSerialDetail = new List <InstrumentSerialDetail>(); for (int i = Convert.ToInt32(InstrumentSerialMaster.StartingInstrumentNo); i <= Convert.ToInt32(InstrumentSerialMaster.EndingInstrumentNo); i++) { InstrumentSerialDetail detail = new InstrumentSerialDetail(); detail.CompanyCode = InstrumentSerialMaster.CompanyCode; detail.BranchCode = InstrumentSerialMaster.BranchCode; detail.AccountCode = InstrumentSerialMaster.AccountCode; detail.Cancelled = false; detail.InstrumentTypeCode = InstrumentSerialMaster.InstrumentTypeCode; detail.InstrumentNo = i; InstrumentSerialMaster.InstrumentSerialDetail.Add(detail); } if (isNew) { //InstrumentSerialMaster.InstrumentTypeSerial = Functions.getNextPk("InstrumentSerialMaster", "InstrumentTypeSerial", string.Concat(" WHERE CompanyCode=", InstrumentSerialMaster.CompanyCode, " AND BranchCode=", InstrumentSerialMaster.BranchCode, " AND AccountCode='", InstrumentSerialMaster.AccountCode, "' AND InstrumentTypeCode=", InstrumentSerialMaster.InstrumentTypeCode)); entrymain.State = EntityState.Added; } else { if (InstrumentSerialMaster.InstrumentSerialDetail != null && InstrumentSerialMaster.InstrumentSerialDetail.Count > 0) { InstrumentSerialMaster.InstrumentSerialDetail.ToList().ForEach(i => { i.CompanyCode = InstrumentSerialMaster.CompanyCode; }); InstrumentSerialMaster.InstrumentSerialDetail.ToList().ForEach(i => { i.BranchCode = InstrumentSerialMaster.BranchCode; }); InstrumentSerialMaster.InstrumentSerialDetail.ToList().ForEach(i => { i.AccountCode = InstrumentSerialMaster.AccountCode; }); InstrumentSerialMaster.InstrumentSerialDetail.ToList().ForEach(i => { i.InstrumentTypeCode = InstrumentSerialMaster.InstrumentTypeCode; }); } entrymain.State = EntityState.Modified; } if (InstrumentSerialMaster.InstrumentSerialDetail != null && InstrumentSerialMaster.InstrumentSerialDetail.Count > 0) { InstrumentSerialMaster.InstrumentSerialDetail.ToList <InstrumentSerialDetail>().ForEach(entry => context.Entry(entry).State = EntityState.Added); } context.InstrumentSerialDetail.ToList().Where(i => i.BranchCode == InstrumentSerialMaster.BranchCode && i.CompanyCode == InstrumentSerialMaster.CompanyCode && i.AccountCode == InstrumentSerialMaster.AccountCode && i.InstrumentTypeCode == InstrumentSerialMaster.InstrumentTypeCode).ToList <InstrumentSerialDetail>().ForEach(entry => context.Entry(entry).State = EntityState.Deleted); context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public IList <VoucherMaster> SelectAll() { using (SmsMisDB db = new SmsMisDB()) { db.Configuration.LazyLoadingEnabled = false; List <VoucherMaster> voucherMaster = db.VoucherMaster.ToList(); return(voucherMaster); } }
//public CSMaster SelectByIDs(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(CSMaster CSMaster, string userId) { try { using (var context = new SmsMisDB()) { var mainentry = context.Entry(CSMaster); if (mainentry != null) { int count = 0; CSMaster.AddDateTime = DateTime.Now; CSMaster.UserId = userId; if (CSMaster.CSDetail != null && CSMaster.CSDetail.Count > 0) { foreach (var x in CSMaster.CSDetail) { x.SrNo = count; //x.NoteCode = x.NoteCode == null ? string.Empty: x.NoteCode; //x.FontStyle = x.FontStyle == null ? string.Empty : x.FontStyle; //x.TopBorder = x.TopBorder == null ? string.Empty : x.TopBorder; //x.BottomBorder = x.BottomBorder == null ? string.Empty : x.BottomBorder; count++; } } if (CSMaster.ReportCode == 0) { CSMaster.ReportCode = Functions.getNextPk("CSMaster", "ReportCode", string.Concat(" Where CompanyCode =", CSMaster.CompanyCode)); mainentry.State = System.Data.Entity.EntityState.Added; context.CSMaster.Add(CSMaster); } else { if (CSMaster.CSDetail != null && CSMaster.CSDetail.Count > 0) { CSMaster.CSDetail.ToList().ForEach(i => { i.CompanyCode = CSMaster.CompanyCode; }); CSMaster.CSDetail.ToList().ForEach(i => { i.ReportCode = CSMaster.ReportCode; }); } mainentry.State = System.Data.Entity.EntityState.Modified; } if (CSMaster.CSDetail != null && CSMaster.CSDetail.Count > 0) { CSMaster.CSDetail.ToList <CSDetail>().ForEach(entry => context.Entry(entry).State = System.Data.Entity.EntityState.Added); } context.CSDetail.ToList().Where(i => i.CompanyCode == CSMaster.CompanyCode && i.ReportCode == CSMaster.ReportCode).ToList <CSDetail>().ForEach(entry => context.Entry(entry).State = System.Data.Entity.EntityState.Deleted); context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { } catch (Exception ex) { } }
//public IList<Branch> SelectBranch(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(AnalysisType AnalysisType, string userId, int CompanyCode) { try { using (var context = new SmsMisDB()) { var mainentry = context.Entry(AnalysisType); if (mainentry != null) { AnalysisType.AddDateTime = DateTime.Now; AnalysisType.AddByUserId = userId; AnalysisType.CompanyCode = CompanyCode; if (AnalysisType.AnalysisTypeCode == 0) { AnalysisType.AnalysisTypeCode = Functions.getNextPk("AnalysisType", "AnalysisTypeCode", string.Concat(" Where CompanyCode =", AnalysisType.CompanyCode)); mainentry.State = EntityState.Added; context.AnalysisType.Add(AnalysisType); } else { if (AnalysisType.AnalysisTypeBranch != null && AnalysisType.AnalysisTypeBranch.Count > 0) { AnalysisType.AnalysisTypeBranch.ToList().ForEach(i => { i.CompanyCode = AnalysisType.CompanyCode; }); //AnalysisType.AnalysisTypeBranch.ToList().ForEach(i => { i.BranchCode = AnalysisType.BranchCode; }); AnalysisType.AnalysisTypeBranch.ToList().ForEach(i => { i.AnalysisTypeCode = AnalysisType.AnalysisTypeCode; }); //AnalysisType.AnalysisTypeBranch.ToList().ForEach(i => { i.VoucherCode = AnalysisType.VoucherCode; }); } mainentry.State = EntityState.Modified; } //if(AnalysisType) //Student.StudentNo = Functions.getNextPk("Student", Student.StudentNo, Student.CompanyCode, Student.BranchCode, Student.SessionCode); //foreach (var row in AnalysisType) if (AnalysisType.AnalysisTypeBranch != null && AnalysisType.AnalysisTypeBranch.Count > 0) { AnalysisType.AnalysisTypeBranch.ToList <AnalysisTypeBranch>().ForEach(entry => context.Entry(entry).State = EntityState.Added); } context.AnalysisTypeBranch.ToList().Where(i => i.AnalysisTypeCode == AnalysisType.AnalysisTypeCode && i.CompanyCode == AnalysisType.CompanyCode).ToList <AnalysisTypeBranch>().ForEach(entry => context.Entry(entry).State = EntityState.Deleted); context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public DataTable SelectAllStudentActiveSubjects() { //SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); //return db.Subject.Where(s => s.Status == true).ToList(); //Select ss.SubjectCode,ss.SubjectName,ccs.CompanyCode,ccs.BranchCode,ccs.ClassCode,ccs.CourseCode from Subject ss with(nolock) inner join ClassCourseSubject ccs with(nolock) on ss.SubjectCode=ccs.SubjectCode Where ss.Status=1 DataTable dt = new DataTable(); var context = new SmsMisDB(); var conn = context.Database.Connection; var connectionState = conn.State; try { using (context) { if (connectionState != ConnectionState.Open) { conn.Open(); } using (var cmd = conn.CreateCommand()) { cmd.CommandText = "Select ss.SubjectCode,ss.SubjectName,ccs.CompanyCode,ccs.BranchCode,ccs.ClassCode,ccs.CourseCode from Subject ss with(nolock) inner join ClassCourseSubject ccs with(nolock) on ss.SubjectCode=ccs.SubjectCode Where ss.Status=1"; //cmd.CommandText = "Select * from ClassCourseSubject"; cmd.CommandType = CommandType.Text; //cmd.Parameters.Add(new SqlParameter("jobCardId", 100525)); using (var reader = cmd.ExecuteReader()) { dt.Load(reader); } } } } catch (Exception ex) { throw ex; } finally { if (connectionState != ConnectionState.Open) { conn.Close(); } } return(dt); }
public DataTable SelectAllClassWithCompanyAndBranch() { //SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); //DataTable dt = new DbContext("name=ValencySGIEntities").Database.SqlQuery("Select distinct css.CompanyCode,css.BranchCode,css.ClassCode,css.CourseCode,css.SubjectCode,co.CourseName,su.SubjectName,cl.ClassName from ClassCourseSubject css with(nolock) inner join Course co with(nolock) on css.CourseCode = co.CourseCode and css.CompanyCode = co.CompanyCode inner join [Subject] su with(nolock) on css.SubjectCode = su.SubjectCode inner join Class cl with(nolock) on cl.ClassCode = css.ClassCode and cl.CompanyCode = css.CompanyCode"); DataTable dt = new DataTable(); var context = new SmsMisDB(); var conn = context.Database.Connection; var connectionState = conn.State; try { using (context) { if (connectionState != ConnectionState.Open) { conn.Open(); } using (var cmd = conn.CreateCommand()) { //cmd.CommandText = "Select distinct css.CompanyCode,css.BranchCode,css.ClassCode,cl.ClassName,css.Mandatory from ClassCourseSubject css with(nolock) inner join Course co with(nolock) on css.CourseCode = co.CourseCode and css.CompanyCode = co.CompanyCode inner join [Subject] su with(nolock) on css.SubjectCode = su.SubjectCode inner join Class cl with(nolock) on cl.ClassCode = css.ClassCode and cl.CompanyCode = css.CompanyCode where co.Status = 1 and su.Status =1 and cl.Status = 1"; cmd.CommandText = "Select distinct css.CompanyCode,css.BranchCode,css.ClassCode, cl.ClassName from ClassCourseSubject css with(nolock) inner join Class cl with(nolock) on cl.ClassCode = css.ClassCode and cl.CompanyCode = css.CompanyCode"; //cmd.CommandText = "Select * from ClassCourseSubject"; cmd.CommandType = CommandType.Text; //cmd.Parameters.Add(new SqlParameter("jobCardId", 100525)); using (var reader = cmd.ExecuteReader()) { dt.Load(reader); } } } } catch (Exception ex) { throw ex; } finally { if (connectionState != ConnectionState.Open) { conn.Close(); } } return(dt); }
public IList <object> getFeeBillDetailForFeeReciept(int CompanyCode, int BranchCode, int SessionCode, int ChallanNo) { SmsMisDB db = new SmsMisDB(); var otherItems = (from p in db.FeeParticular join d in db.FeeBillDetails on p.CompanyCode equals d.CompanyCode where d.ParticularCode == p.ParticularCode select new { ParticularName = p.ParticularName, TotalAmount = d.TotalAmount, CompanyCode = d.CompanyCode, BranchCode = d.BranchCode, SessionCode = d.SessionCode, ChallanNo = d.ChallanNo, }).Where(a => a.CompanyCode == CompanyCode && a.BranchCode == BranchCode && a.SessionCode == SessionCode && a.ChallanNo == ChallanNo).ToArray(); return(otherItems); }
public void save(ChartOfAccounts ChartOfAccounts, string userId, bool isNew) { try { using (var context = new SmsMisDB()) { var mainentry = context.Entry(ChartOfAccounts); if (mainentry != null) { ChartOfAccounts.AddDateTime = DateTime.Now; ChartOfAccounts.AddByUserId = userId; if (isNew) { //ChartOfAccounts.VoucherCode = Functions.getNextPk("VoucherType", ChartOfAccounts.VoucherCode, ChartOfAccounts.CompanyCode); mainentry.State = EntityState.Added; context.ChartOfAccounts.Add(ChartOfAccounts); } else { mainentry.State = EntityState.Modified; } if (ChartOfAccounts.COABranch != null && ChartOfAccounts.COABranch.Count > 0) { ChartOfAccounts.COABranch.ToList <COABranch>().ForEach(entry => context.Entry(entry).State = EntityState.Added); } context.COABranch.ToList().Where(i => i.CompanyCode == ChartOfAccounts.CompanyCode && i.AccountCode == ChartOfAccounts.AccountCode).ToList <COABranch>().ForEach(entry => context.Entry(entry).State = EntityState.Deleted); context.SaveChanges(); Bank bnk = new hdlBank().SelectBankByAccountCode(ChartOfAccounts.AccountCode, ChartOfAccounts.CompanyCode); if (bnk != null && ChartOfAccounts.AccountType != "B") { new hdlBank().delete(bnk); } } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public void delete(IList <COAGroup> COAGroup) { try { using (var context = new SmsMisDB()) { //context.COAGroup.Attach(COAGroup); //var entry = context.Entry(COAGroup); if (COAGroup != null) { COAGroup.ToList <COAGroup>().ForEach(i => i.AddDateTime = DateTime.Now); COAGroup.ToList <COAGroup>().ForEach(i => i.AddByUserId = COAGroup[0].AddByUserId); COAGroup.ToList <COAGroup>().ForEach(i => i.CompanyCode = COAGroup[0].CompanyCode); COAGroup.ToList <COAGroup>().ForEach(i => i.Code = COAGroup[0].Code); COAGroup.ToList <COAGroup>().ForEach(i => i.Description = COAGroup[0].Description); COAGroup.ToList <COAGroup>().ForEach(i => i.ShortName = COAGroup[0].ShortName); //entry.State = System.Data.Entity.EntityState.Deleted; //foreach (var row in COAGroup) //{ // context.COAGroup.Add(row); //} context.COAGroup.ToList <COAGroup>().Where(s => s.CompanyCode == COAGroup[0].CompanyCode && s.Code == COAGroup[0].Code).ToList().ForEach(entry2 => context.Entry(entry2).State = EntityState.Deleted); //} //else // context.COAGroup.ToList<COAGroup>().Where(s => s.CompanyCode == COAGroup[0].CompanyCode && s.BranchCode == COAGroup[0].BranchCode && s.SessionCode == COAGroup[0].SessionCode && s.ClassCode == COAGroup[0].ClassCode).ToList().ForEach(entry2 => context.Entry(entry2).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 IList <Student> SelectAllStudent(string strValues) { string[] strArray = strValues.ToString().Split('/'); int companyCode = Convert.ToInt32(strArray[0]); int BranchCode = Convert.ToInt32(strArray[1]); int SessionCode = Convert.ToInt32(strArray[2]); int ClassCode = Convert.ToInt32(strArray[3]); string Gender = strArray[4].ToString(); SmsMisDB db = new SmsMisDB(); return(db.Student.Where(s => s.StudentRollNo == null && s.CompanyCode == companyCode && s.BranchCode == BranchCode && s.SessionCode == SessionCode && s.ClassCode == ClassCode && s.Gender == Gender ).ToList()); }
//public IList<Branch> SelectBranch(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(IList <SubjectPracticleFee> SubjectPracticleFee, string userId, int CompanyCode, int BranchCode, int SessionCode, int ClassCode, int CourseCode) { try { using (var context = new SmsMisDB()) { if (SubjectPracticleFee != null) { SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.AddDateTime = DateTime.Now); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.AddByUserId = userId); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.CompanyCode = CompanyCode); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.BranchCode = BranchCode); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.SessionCode = SessionCode); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.ClassCode = ClassCode); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.CourseCode = CourseCode); //if(SubjectPracticleFee) //Student.StudentNo = Functions.getNextPk("Student", Student.StudentNo, Student.CompanyCode, Student.BranchCode, Student.SessionCode); foreach (var row in SubjectPracticleFee) { context.SubjectPracticleFee.Add(row); } //entry.State = EntityState.Added; context.SubjectPracticleFee.ToList <SubjectPracticleFee>().Where(s => s.CompanyCode == CompanyCode && s.BranchCode == BranchCode && s.SessionCode == SessionCode && s.ClassCode == ClassCode && s.CourseCode == CourseCode).ToList().ForEach(entry2 => context.Entry(entry2).State = EntityState.Deleted); } else { context.SubjectPracticleFee.ToList <SubjectPracticleFee>().Where(s => s.CompanyCode == CompanyCode && s.BranchCode == BranchCode && s.SessionCode == SessionCode && s.ClassCode == ClassCode && s.CourseCode == CourseCode).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 delete(IList <FeeParticularRate> FeeParticularRate) { try { using (var context = new SmsMisDB()) { //context.FeeParticularRate.Attach(FeeParticularRate); //var entry = context.Entry(FeeParticularRate); if (FeeParticularRate != null) { FeeParticularRate.ToList <FeeParticularRate>().ForEach(i => i.AddDateTime = DateTime.Now); FeeParticularRate.ToList <FeeParticularRate>().ForEach(i => i.AddByUserId = FeeParticularRate[0].AddByUserId); FeeParticularRate.ToList <FeeParticularRate>().ForEach(i => i.CompanyCode = FeeParticularRate[0].CompanyCode); FeeParticularRate.ToList <FeeParticularRate>().ForEach(i => i.BranchCode = FeeParticularRate[0].BranchCode); FeeParticularRate.ToList <FeeParticularRate>().ForEach(i => i.SessionCode = FeeParticularRate[0].SessionCode); FeeParticularRate.ToList <FeeParticularRate>().ForEach(i => i.ClassCode = FeeParticularRate[0].ClassCode); //entry.State = System.Data.Entity.EntityState.Deleted; //foreach (var row in FeeParticularRate) //{ // context.FeeParticularRate.Add(row); //} context.FeeParticularRate.ToList <FeeParticularRate>().Where(s => s.CompanyCode == FeeParticularRate[0].CompanyCode && s.BranchCode == FeeParticularRate[0].BranchCode && s.SessionCode == FeeParticularRate[0].SessionCode && s.ClassCode == FeeParticularRate[0].ClassCode).ToList().ForEach(entry2 => context.Entry(entry2).State = EntityState.Deleted); //} //else // context.FeeParticularRate.ToList<FeeParticularRate>().Where(s => s.CompanyCode == FeeParticularRate[0].CompanyCode && s.BranchCode == FeeParticularRate[0].BranchCode && s.SessionCode == FeeParticularRate[0].SessionCode && s.ClassCode == FeeParticularRate[0].ClassCode).ToList().ForEach(entry2 => context.Entry(entry2).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 IList<Branch> SelectBranch(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(IList <COAGroup> COAGroup, string userId) { try { using (var context = new SmsMisDB()) { if (COAGroup != null) { COAGroup.ToList <COAGroup>().ForEach(i => i.AddDateTime = DateTime.Now); COAGroup.ToList <COAGroup>().ForEach(i => i.AddByUserId = userId); COAGroup.ToList <COAGroup>().ForEach(i => i.CompanyCode = COAGroup[0].CompanyCode); COAGroup.ToList <COAGroup>().ForEach(i => i.Code = COAGroup[0].Code); COAGroup.ToList <COAGroup>().ForEach(i => i.Description = COAGroup[0].Description); COAGroup.ToList <COAGroup>().ForEach(i => i.ShortName = COAGroup[0].ShortName); //if(COAGroup) //Student.StudentNo = Functions.getNextPk("Student", Student.StudentNo, Student.CompanyCode, Student.BranchCode, Student.SessionCode); foreach (var row in COAGroup) { context.COAGroup.Add(row); } //entry.State = EntityState.Added; context.COAGroup.ToList <COAGroup>().Where(s => s.CompanyCode == COAGroup[0].CompanyCode && s.Code == COAGroup[0].Code).ToList().ForEach(entry2 => context.Entry(entry2).State = EntityState.Deleted); } else { context.COAGroup.ToList <COAGroup>().Where(s => s.CompanyCode == COAGroup[0].CompanyCode && s.Code == COAGroup[0].Code).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 delete(IList <SubjectPracticleFee> SubjectPracticleFee) { try { using (var context = new SmsMisDB()) { if (SubjectPracticleFee != null) { SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.AddDateTime = DateTime.Now); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.AddByUserId = SubjectPracticleFee[0].AddByUserId); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.CompanyCode = SubjectPracticleFee[0].CompanyCode); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.BranchCode = SubjectPracticleFee[0].BranchCode); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.SessionCode = SubjectPracticleFee[0].SessionCode); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.ClassCode = SubjectPracticleFee[0].ClassCode); SubjectPracticleFee.ToList <SubjectPracticleFee>().ForEach(i => i.CourseCode = SubjectPracticleFee[0].CourseCode); foreach (var row in SubjectPracticleFee) { context.SubjectPracticleFee.Add(row); } context.SubjectPracticleFee.ToList <SubjectPracticleFee>().Where(s => s.CompanyCode == SubjectPracticleFee[0].CompanyCode && s.BranchCode == SubjectPracticleFee[0].BranchCode && s.SessionCode == SubjectPracticleFee[0].SessionCode && s.ClassCode == SubjectPracticleFee[0].ClassCode && s.CourseCode == SubjectPracticleFee[0].CourseCode).ToList().ForEach(entry2 => context.Entry(entry2).State = EntityState.Deleted); } else { context.SubjectPracticleFee.ToList <SubjectPracticleFee>().Where(s => s.CompanyCode == SubjectPracticleFee[0].CompanyCode && s.BranchCode == SubjectPracticleFee[0].BranchCode && s.SessionCode == SubjectPracticleFee[0].SessionCode && s.ClassCode == SubjectPracticleFee[0].ClassCode && s.CourseCode == SubjectPracticleFee[0].CourseCode).ToList().ForEach(entry2 => context.Entry(entry2).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(IList <StudentOptionalFeeParticular> StudentOptionalFeeParticular) { try { using (var context = new SmsMisDB()) { if (StudentOptionalFeeParticular != null) { StudentOptionalFeeParticular.ToList <StudentOptionalFeeParticular>().ForEach(i => i.AddDateTime = DateTime.Now); StudentOptionalFeeParticular.ToList <StudentOptionalFeeParticular>().ForEach(i => i.AddByUserId = StudentOptionalFeeParticular[0].AddByUserId); StudentOptionalFeeParticular.ToList <StudentOptionalFeeParticular>().ForEach(i => i.CompanyCode = StudentOptionalFeeParticular[0].CompanyCode); StudentOptionalFeeParticular.ToList <StudentOptionalFeeParticular>().ForEach(i => i.BranchCode = StudentOptionalFeeParticular[0].BranchCode); StudentOptionalFeeParticular.ToList <StudentOptionalFeeParticular>().ForEach(i => i.SessionCode = StudentOptionalFeeParticular[0].SessionCode); StudentOptionalFeeParticular.ToList <StudentOptionalFeeParticular>().ForEach(i => i.StudentNo = StudentOptionalFeeParticular[0].StudentNo); foreach (var row in StudentOptionalFeeParticular) { context.StudentOptionalFeeParticular.Add(row); } context.StudentOptionalFeeParticular.ToList <StudentOptionalFeeParticular>().Where(s => s.CompanyCode == StudentOptionalFeeParticular[0].CompanyCode && s.BranchCode == StudentOptionalFeeParticular[0].BranchCode && s.SessionCode == StudentOptionalFeeParticular[0].SessionCode && s.StudentNo == StudentOptionalFeeParticular[0].StudentNo).ToList().ForEach(entry2 => context.Entry(entry2).State = EntityState.Deleted); } else { context.StudentOptionalFeeParticular.ToList <StudentOptionalFeeParticular>().Where(s => s.CompanyCode == StudentOptionalFeeParticular[0].CompanyCode && s.BranchCode == StudentOptionalFeeParticular[0].BranchCode && s.SessionCode == StudentOptionalFeeParticular[0].SessionCode && s.StudentNo == StudentOptionalFeeParticular[0].StudentNo).ToList().ForEach(entry2 => context.Entry(entry2).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 ActionResult Index(User admin) { if (ModelState.IsValid) { string AdminID = new SmsMisDB().performLogin(admin, ""); if (!string.IsNullOrEmpty(AdminID)) { // Added by Shah: 2014-09-08 Session["isAdmin"] = true; Session["User"] = AdminID; hdlCommon HD = new hdlCommon(); Session["Links"] = HD.getLinks(AdminID.ToString()); return(RedirectToAction("Home")); } else { ViewBag.errorMsg = "Invalid username or password"; } } return(Index()); }