public async Task <ActionResult> DeleteConfirmed(int id) { OpenDay openDay = await db.OpenDays.FindAsync(id); db.OpenDays.Remove(openDay); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "OpenDayId,OpenDate,CompanyId,UserName")] OpenDay openDay) { if (ModelState.IsValid) { db.Entry(openDay).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CompanyId = new SelectList(db.Companies, "CompanyId", "Name", openDay.CompanyId); return(View(openDay)); }
public ActionResult Create(OpenDay view) { var response = MovementsHelper.NewCollectionTmp(view, User.Identity.Name); if (ModelState.IsValid) { //db.OpenDays.Add(openDay); //await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CompanyId = new SelectList(db.Companies, "CompanyId", "Name", view.CompanyId); return(View(view)); }
// GET: OpenDays/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OpenDay openDay = await db.OpenDays.FindAsync(id); if (openDay == null) { return(HttpNotFound()); } return(View(openDay)); }
// GET: OpenDays/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OpenDay openDay = await db.OpenDays.FindAsync(id); if (openDay == null) { return(HttpNotFound()); } ViewBag.CompanyId = new SelectList(db.Companies, "CompanyId", "Name", openDay.CompanyId); return(View(openDay)); }
// GET: OpenDays/Create public ActionResult Create() { var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); ViewBag.CompanyId = new SelectList(CombosHelper.GetCompanies(), "CompanyId", "Name", user.CompanyId); var view = new OpenDay { CompanyId = user.CompanyId, OpenDate = DateTime.Today, UserName = user.UserName, OnOff = true, }; return(View(view)); }
public static Response NewCollectionTmp(OpenDay view, string userName) { using (var transacction = db.Database.BeginTransaction()) { try { var user = db.Users.Where(u => u.UserName == userName).FirstOrDefault(); var mainWareHouses = db.MainWarehouses.Where(w => w.CompanyId == user.CompanyId).ToList(); var wareHouses = db.Warehouses.Where(w => w.CompanyId == view.CompanyId).ToList(); var disbursedLoans = db.DisbursedLoans.Where(wH => wH.CompanyId == view.CompanyId).Where(cA => cA.StateId == 2).ToList(); //var lastOpenDay = db.OpenDays.Where(od => od.CompanyId == view.CompanyId).Where(of => of.OnOff == true).FirstOrDefault(); //lastOpenDay.OnOff = false; //db.Entry(lastOpenDay).State = EntityState.Modified; var openDay = new OpenDay { OpenDate = DateTime.Today, CompanyId = user.CompanyId, UserName = user.UserName, OnOff = true, }; db.OpenDays.Add(openDay); db.SaveChanges(); foreach (MainWarehouse mainWarehouse in mainWareHouses) { var mainInventory = new MainInventory { MainWarehouseId = mainWarehouse.MainWarehouseId, CompanyId = view.CompanyId, Date = openDay.OpenDate, Collection = 0, Pettycash = 0, Administrativeexpense = 0, Subtotal = 0, Renewedcredit = 0, Total = 0, WareHouseInitialLoan = 0, WareHouseTotalLoan = 0, WareHouseTotalBalance = 0, }; db.MainInventories.Add(mainInventory); } foreach (Warehouse warehouse in wareHouses) { var inventory = new Inventory { WarehouseId = warehouse.WarehouseId, CompanyId = view.CompanyId, Date = openDay.OpenDate, Collection = 0, Pettycash = 0, Administrativeexpense = 0, Subtotal = 0, Renewedcredit = 0, Total = 0, InitialLoan = 0, TotalLoan = 0, TotalBalance = 0, }; db.Inventories.Add(inventory); } foreach (DisbursedLoan detailDL in disbursedLoans) { var collectionTmp = new CollectionTmp { CompanyId = detailDL.CompanyId, WarehouseId = detailDL.WarehouseId, DisbursedLoanId = detailDL.DisbursedLoanId, UserName = userName, LoanState = detailDL.LoanState, CollectionDate = openDay.OpenDate, Payment = 0, CurrentBalance = detailDL.Balance, }; db.CollectionTmps.Add(collectionTmp); } db.SaveChanges(); transacction.Commit(); return(new Response { Succeeded = true, }); } catch (Exception ex) { transacction.Rollback(); return(new Response { Message = ex.Message, Succeeded = false, }); } } }
public OpenDayCombo(string pDisp, string pValue, OpenDay pOd) { _disp = pDisp; _value = pValue; _OD = pOd; }