public ActionResult Create([Bind(Include = "id,customerid,itemid,returnDate,ammount,description")] ReturnItem returnItem) { if (ModelState.IsValid) { db.ReturnItems.Add(returnItem); db.SaveChanges(); var itm = (from item in db.item where item.id == returnItem.itemid select item).FirstOrDefault(); Global.Money = Global.Money - returnItem.ammount; Customer customer = db.Customers.Where(cus => cus.id == returnItem.customerid).FirstOrDefault(); customer.ammount = customer.ammount - returnItem.ammount; db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); Transaction transaction = new Transaction(); transaction.Ammount = returnItem.ammount; transaction.Balance = customer.ammount; transaction.Date = returnItem.returnDate; transaction.Description = "Returned"; transaction.Customer = customer; transaction.Customerid = customer.id; transaction.type = TransactionType.Debit; db.Transactions.Add(transaction); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.customerid = new SelectList(db.Customers, "id", "name", returnItem.customerid); ViewBag.itemid = new SelectList(db.item, "id", "name", returnItem.itemid); return(View(returnItem)); }
public ActionResult Create([Bind(Include = "id,customerid,Date,description,Ammount")] Payment payment) { if (ModelState.IsValid) { db.Payments.Add(payment); db.SaveChanges(); var customer = (from cust in db.Customers where cust.id == payment.customerid select cust).FirstOrDefault(); customer.ammount = customer.ammount - payment.Ammount; db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); Global.Money = Global.Money + payment.Ammount; Transaction transaction = new Transaction(); transaction.Ammount = payment.Ammount; transaction.Balance = customer.ammount; transaction.Date = payment.Date; transaction.Description = ""; transaction.Payment = payment; transaction.Paymentid = payment.id; transaction.Customer = customer; transaction.Customerid = customer.id; transaction.type = TransactionType.Debit; db.Transactions.Add(transaction); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.customerid = new SelectList(db.Customers, "id", "name", payment.customerid); return(View(payment)); }
public void AddFeedback(Feedback feedback) { using (_db) { _db.Entry(feedback.Tour).State = EntityState.Unchanged; _db.Feedbacks.Add(feedback); _db.SaveChanges(); } }
public void AddTour(Tour tour) { using (_db) { _db.Entry(tour.Company).State = EntityState.Unchanged; _db.Tours.Add(tour); _db.SaveChanges(); } }
public void AddCompany(Company company) { using (_db) { _db.Entry(company.City).State = EntityState.Unchanged; _db.Companies.Add(company); _db.SaveChanges(); } }
public void Adduser(User user) { using (_db) { _db.Entry(user.Role).State = EntityState.Unchanged; _db.Entry(user.City).State = EntityState.Unchanged; _db.Users.Add(user); _db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "Id,Title,Description,ImageUrl")] History history, FormCollection fdata) { User u = (User)Session[WebUtil.CURRENT_USER]; if (!(u != null && u.IsInRole(WebUtil.ADMIN_ROLE))) { return(RedirectToAction("Login", "User", new { ctl = "Admin", act = "AdminPanel" })); } foreach (string fname in Request.Files) { HttpPostedFileBase file = Request.Files[fname]; if (!string.IsNullOrEmpty(file?.FileName)) { if (history.ImageUrl != null) { string oldpth = Request.MapPath(history.ImageUrl); if (System.IO.File.Exists(oldpth)) { System.IO.File.Delete(oldpth); } } string url = history.ImageUrl; string path = Request.MapPath(url); file.SaveAs(path); } } db.Entry(history).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "id,orderid,supplyDate,location,description")] SupplyOrder supplyOrder) { if (ModelState.IsValid) { db.SupplyOrders.Add(supplyOrder); db.SaveChanges(); var items = (from SalesLineItems in db.salesLineItem where SalesLineItems.orderid == supplyOrder.orderid select SalesLineItems.item).Include(a => a.product).ToList(); List <SalesLineItem> sitems = (from SalesLineItems in db.salesLineItem where SalesLineItems.orderid == supplyOrder.orderid select SalesLineItems).ToList(); int quantitycheck = 0; var itemShellsSupply = Switch.idsToSwitch; foreach (var itm in items) { if (itemShellsSupply.Count == 0) { itm.quantity = itm.quantity - sitems.First().quantity; } else { Util.SellShell(itm, sitems.First().quantity, db); } if (itm.quantity < 0) { quantitycheck++; } db.Entry(itm).State = EntityState.Modified; db.SaveChanges(); sitems.RemoveAt(0); } if (quantitycheck > 0) { return(new JavaScriptResult { Script = "alert('Successfully registered');" }); //var script = "alert('Some Items Quantity goes negative');"; //return JavaScript(script); } return(RedirectToAction("Index")); } ViewBag.orderid = new SelectList(db.order, "id", "description", supplyOrder.orderid); return(View(supplyOrder)); }
public static Boolean updateShellQuantity(Product product, int quantity, DbContextClass db) { product.shell_quantity = product.shell_quantity - quantity; db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(true); }
public ActionResult Edit(int id, Manager b1) { Manager b = context.Managers.Where(x => x.ManagerId == b1.ManagerId).SingleOrDefault(); context.Entry(b).CurrentValues.SetValues(b1); context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int id, Customer c1) { Customer c = context.Customers.Where(x => x.CustomerId == c1.CustomerId).SingleOrDefault(); context.Entry(c).CurrentValues.SetValues(c1); context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int id, Product p1) { Product p = context.Products.Where(x => x.ProductId == p1.ProductId).SingleOrDefault(); context.Entry(p).CurrentValues.SetValues(p1); context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { User u = (User)Session[WebUtil.CURRENT_USER]; if (!(u != null && u.IsInRole(WebUtil.ADMIN_ROLE))) { return(RedirectToAction("Login", "User", new { ctl = "Admin", act = "AdminPanel" })); } Booking booking = new BookingHandler().GetBookingById(id); db.Entry(booking.Tour).State = EntityState.Unchanged; db.Entry(booking.User).State = EntityState.Unchanged; db.Entry(booking).State = EntityState.Deleted; db.Bookings.Remove(booking); db.SaveChanges(); return(RedirectToAction("BookingList")); }
public void UpdateBanner(MainBanner banner) { using (_db) { _db.Entry(banner).State = EntityState.Modified; _db.SaveChanges(); } }
public ActionResult Edit(int id, Brand b1) { Brand b = context.Brands.Where(x => x.BrandId == b1.BrandId).SingleOrDefault(); context.Entry(b).CurrentValues.SetValues(b1); context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int id, Vendor v1) { Vendor v = context.Vendors.Where(x => x.VendorId == v1.VendorId).SingleOrDefault(); context.Entry(v).CurrentValues.SetValues(v1); context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,name,price,Emp_Charges,description,borderframe,BorderFrame_quantity,Acrylic,shell_quantity,raison,Mat300,Mat450,cobalt,Mekb,Titanium,bursh,JelCoat,Aerosel,BrushCleaner,plastic,colour,Plasticparis,nut,bolts,plastic_nut_Bolts,khrpaichy,Polish,Kapra,bowl,cuttingcream,dori,cement")] Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }
public ActionResult Edit([Bind(Include = "id,name,description")] Entity entity) { if (ModelState.IsValid) { db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(entity)); }
public void AddBooking(Booking booking) { using (_db) { _db.Entry(booking.Tour).State = EntityState.Unchanged; //_db.Entry(booking.User).State = EntityState.Unchanged; _db.Bookings.Add(booking); _db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "id,name,Location,Email,mobile,company,ammount")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
// GET: SalesLineItems public ActionResult Index(int?id) { if (Session["orderid"] == null) { var salesLineItem = db.salesLineItem.Include(s => s.item).Include(s => s.order); return(View(salesLineItem.ToList())); } else if (Session["orderid"] != null) { int orderid = Convert.ToInt32(Session["orderid"].ToString()); List <SalesLineItem> salelineitems = (from sli in db.salesLineItem where sli.order.id == orderid select sli).Include(s => s.order).Include(s => s.item).ToList(); int total = 0; foreach (var sli in salelineitems) { total = sli.price + total; } var order1 = (from order in db.order where order.id == orderid select order).FirstOrDefault(); order1.total = total; db.Entry(order1).State = EntityState.Modified; db.SaveChanges(); if (salelineitems.Count < 1) { ViewBag.CustomerName = ""; ViewBag.OrderDate = ""; ViewBag.Total = ""; } else { ViewBag.CustomerName = salelineitems[0].order.customer.name; ViewBag.OrderDate = salelineitems[0].order.orderDate; ViewBag.Total = total; } return(View(salelineitems)); } return(View()); }
public void DeleteCountry(Country country) { DbContextClass db = new DbContextClass(); using (db) { db.Entry(country).State = EntityState.Deleted; db.Countries.Remove(country); db.SaveChanges(); } }
public void AddCity(City city) { DbContextClass db = new DbContextClass(); using (db) { db.Entry(city.Country).State = EntityState.Unchanged; db.Cities.Add(city); db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "id,name,productid,description,colourid,quantity")] Item item) { if (ModelState.IsValid) { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.colourid = new SelectList(db.colour, "id", "name", item.colourid); ViewBag.productid = new SelectList(db.product, "id", "name", item.productid); return(View(item)); }
public ActionResult Edit([Bind(Include = "id,typeId,entityId,Date,description,Ammount")] Expense expense) { if (ModelState.IsValid) { db.Entry(expense).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.entityId = new SelectList(db.entity, "id", "name", expense.entityId); ViewBag.typeId = new SelectList(db.expenseType, "id", "name", expense.typeId); return(View(expense)); }
public ActionResult Edit([Bind(Include = "id,Customerid,Orderid,Paymentid,Ammount,type,Balance,Description,Date")] Transaction transaction) { if (ModelState.IsValid) { db.Entry(transaction).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Customerid = new SelectList(db.Customers, "id", "name", transaction.Customerid); ViewBag.Orderid = new SelectList(db.order, "id", "description", transaction.Orderid); ViewBag.Paymentid = new SelectList(db.Payments, "id", "description", transaction.Paymentid); return(View(transaction)); }
// GET: Employees public ActionResult Payment(string Ammount, string name) { Expense expense = new Expense(); expense.Ammount = Convert.ToInt32(Ammount); expense.Date = DateTime.Now; expense.entityId = getEntityId(name).id; expense.typeId = getTypeId("Employee").id; db.expense.Add(expense); db.SaveChanges(); var emp = (from employe in db.Employees where employe.name.Equals(name) select employe).FirstOrDefault(); int amunt = Convert.ToInt32(Ammount); emp.Ammount = emp.Ammount - amunt; db.Entry(emp).State = EntityState.Modified; db.SaveChanges(); Global.Money = Global.Money - expense.Ammount; return(RedirectToAction("Index")); }
public ActionResult Finish() { int orderid = int.Parse(Session["orderid"].ToString()); var customer = (from orders in db.order where orders.id == orderid select orders.customer).FirstOrDefault(); var order = (from orders in db.order where orders.id == orderid select orders).FirstOrDefault(); customer.ammount = customer.ammount + order.total; db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); //Order Transaction Added Transaction transaction = new Transaction(); transaction.Ammount = order.total; transaction.Balance = customer.ammount; transaction.Date = order.orderDate; transaction.Description = ""; transaction.order = order; transaction.Orderid = order.id; transaction.Customer = customer; transaction.Customerid = customer.id; transaction.type = TransactionType.Credit; db.Transactions.Add(transaction); db.SaveChanges(); if (order.paid.Equals(true)) { SupplyOrder supply = new SupplyOrder(); supply.description = order.description; supply.location = "Shop"; supply.orderid = order.id; supply.supplyDate = order.orderDate; SupplyOrdersController s = new SupplyOrdersController(); s.Create(supply); Payment payment = new Payment(); payment.customerid = order.customerid; payment.Date = order.orderDate; payment.Ammount = order.total; payment.description = order.description; PaymentsController pay = new PaymentsController(); pay.Create(payment); } else { if (Session["Supply"].ToString() == "on") { SupplyOrder supply = new SupplyOrder(); supply.description = order.description; supply.location = "Shop"; supply.orderid = order.id; supply.supplyDate = order.orderDate; SupplyOrdersController s = new SupplyOrdersController(); s.Create(supply); } if (Session["Payment"].ToString() == "on") { Payment payment = new Payment(); payment.customerid = order.customerid; payment.Date = order.orderDate; payment.Ammount = order.total; payment.description = order.description; PaymentsController pay = new PaymentsController(); pay.Create(payment); } } ///Transaction return(RedirectToAction("Index", "Customers")); }
public void Update(Dept dept) { _dbcontext.Entry(dept).State = EntityState.Modified; }
public ActionResult CreateFrame([Bind(Include = "id,itemid,description,Date,employeeid,quantity,paid")] MakeItem makeItem) { if (ModelState.IsValid) { db.makeItem.Add(makeItem); db.SaveChanges(); if (makeItem.item.product.borderframe == true) { var item = (from itm in db.item where itm.id == makeItem.itemid select itm).FirstOrDefault(); var productmake = (from prdt in db.product where prdt.id == item.productid select prdt).FirstOrDefault(); var shellitem = makeItem.item.product; { shellitem.BorderFrame_quantity = shellitem.BorderFrame_quantity + makeItem.quantity; db.Entry(shellitem).State = EntityState.Modified; db.SaveChanges(); } if (makeItem.item.product.description.Contains("bno:")) { string bdno = makeItem.item.product.description.Remove(0, makeItem.item.product.description.IndexOf("bno:")); var prdts = (from pro in db.product where pro.description.Contains(bdno) && pro.id != productmake.id select pro).ToList(); foreach (var p in prdts) { p.BorderFrame_quantity = p.BorderFrame_quantity + makeItem.quantity; db.Entry(p).State = EntityState.Modified; db.SaveChanges(); } } } } return(RedirectToAction("Index")); }