コード例 #1
0
        public ActionResult Create(//[Bind(Include = "SettingsId,CompanyId,BankInterest,BankCharges")] 
            sdtoSettings Settings)
        {
            if (ModelState.IsValid)
            {
                Settings.CreatedOn = DateTime.Now;

                db.GeneralSettings.Add(Settings);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(Settings);
        }
コード例 #2
0
 // GET: Settings/Edit/5
 public ActionResult EditOnCreate(sdtoSettings sdtoSettings)
 {
     if (sdtoSettings == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     if (sdtoSettings == null)
     {
         return HttpNotFound();
     }
     return View(sdtoSettings);
 }
コード例 #3
0
        public ActionResult Edit(//[Bind(Include = "SettingsId,CompanyId,BankInterest,BankCharges,CreatedBy,CreatedOn,ModifiedBy,ModifiedOn")] 
            sdtoSettings Settings)
        {
            if (ModelState.IsValid)
            {
                Settings.CreatedOn = DateTime.Now;
                Settings.ModifiedOn = DateTime.Now;
                if (Settings.InterestAccountId == 0)
                    Settings.InterestAccountId = null;

                db.Entry(Settings).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index", "Home");
            }

            ViewBag.CompanyList = new SelectList(db.Companies, "CompanyId", "CompanyName");

            var assetSchedule = db.Schedules.Where(x => x.ShortName == "AS").FirstOrDefault();
            var SelectListAsset = db.Schedules.Where(x => x.BaseScheduleId == assetSchedule.ScheduleId || x.ScheduleId == assetSchedule.ScheduleId).ToList();
            ViewBag.AssetScheduleList = new SelectList(SelectListAsset, "ScheduleId", "ScheduleName", 0);

            var liabilitySchedule = db.Schedules.Where(x => x.ShortName == "LY").FirstOrDefault();
            var SelectListLiability = db.Schedules.Where(x => x.BaseScheduleId == liabilitySchedule.ScheduleId || x.ScheduleId == liabilitySchedule.ScheduleId).ToList();
            ViewBag.LiabilityScheduleList = new SelectList(SelectListLiability, "ScheduleId", "ScheduleName", 0);

            var expenditureSchedule = db.Schedules.Where(x => x.ShortName == "EX").FirstOrDefault();
            var SelectListExpenditure = db.Schedules.Where(x => x.BaseScheduleId == expenditureSchedule.ScheduleId || x.ScheduleId == expenditureSchedule.ScheduleId).ToList();
            ViewBag.ExpenditureScheduleList = new SelectList(SelectListExpenditure, "ScheduleId", "ScheduleName", 0);

            var incomeSchedule = db.Schedules.Where(x => x.ShortName == "IC").FirstOrDefault();
            var SelectListIncome = db.Schedules.Where(x => x.BaseScheduleId == incomeSchedule.ScheduleId || x.ScheduleId == incomeSchedule.ScheduleId).ToList();
            ViewBag.IncomeScheduleList = new SelectList(SelectListIncome, "ScheduleId", "ScheduleName", 0);

            var AccountList = db.AccountBooks.Where(x => x.IsDeleted == false).ToList();
            AccountList.Insert(0, new sdtoAccountBook() { AccountBookId = 0, BookName = "Select an Account" });
            ViewBag.AccountList = new SelectList(AccountList, "AccountBookId", "BookName", 0);

            var scheduleList = db.Schedules.ToList();
            scheduleList.Insert(0, new Data.Models.Accounts.Schedules.sdtoSchedule() { ScheduleId = 0, ScheduleName = "Select a Schedule" });
            ViewBag.ScheduleList = new SelectList(scheduleList, "ScheduleId", "ScheduleName", 0);

            var bookList = db.AccountBooks.ToList();
            bookList.Insert(0, new Data.Models.Accounts.sdtoAccountBook { AccountBookId = 0, BookName = "Select a Book" });
            ViewBag.BookList = new SelectList(bookList, "AccountBookId", "BookName", 0);

            var cashBookType = db.AccountBookTypes.Where(x => x.UniqueName.Equals("CASH", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
            var cashBookList = db.AccountBooks.Where(x => x.AccountBookTypeId == cashBookType.AccountBookTypeId).ToList();
            cashBookList.Insert(0, new Data.Models.Accounts.sdtoAccountBook { AccountBookId = 0, BookName = "Select a Book" });
            ViewBag.CashBookList = new SelectList(cashBookList, "AccountBookId", "BookName", 0);

            var bankBookType = db.AccountBookTypes.Where(x => x.UniqueName.Equals("BANK", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
            var bankBookList = db.AccountBooks.Where(x => x.AccountBookTypeId == bankBookType.AccountBookTypeId).ToList();
            bankBookList.Insert(0, new Data.Models.Accounts.sdtoAccountBook { AccountBookId = 0, BookName = "Select a Book" });
            ViewBag.BankBookList = new SelectList(bankBookList, "AccountBookId", "BookName", 0);

            var journalBookType = db.AccountBookTypes.Where(x => x.UniqueName.Equals("journal", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
            var journalBookList = db.AccountBooks.Where(x => x.AccountBookTypeId == journalBookType.AccountBookTypeId).ToList();
            journalBookList.Insert(0, new Data.Models.Accounts.sdtoAccountBook { AccountBookId = 0, BookName = "Select a Book" });
            ViewBag.JournalBookList = new SelectList(journalBookList, "AccountBookId", "BookName", 0);

            var otherAccType = db.AccountTypes.Where(x => x.UniqueName.Equals("Other", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
            var otherAccountHeads = db.AccountHeads.Where(x => x.AccountTypeId == otherAccType.AccountTypeId).ToList();
            otherAccountHeads.Insert(0, new Data.Models.Accounts.sdtoAccountHead { AccountHeadId = 0, AccountName = "Select a Acount" });
            ViewBag.OtherAccountHeads = new SelectList(otherAccountHeads, "AccountHeadId", "AccountName", 0);

            return View(Settings);
        }