public ActionResult PostAddOneSale(ProductSold prodsold) { if (prodsold != null) // checking the fields are completed { // get all ID var idcustomer = db.Customers.Where(user => user.Id == prodsold.CustomerId).Select(col => col.Id).Single(); var idproduct = db.Products.Where(prod => prod.Id == prodsold.ProductId).Select(col => col.Id).Single(); var idstore = db.Stores.Where(sto => sto.Id == prodsold.StoreId).Select(col => col.Id).Single(); string text_date = Request.Form["date"]; // initial date DateTime date = Convert.ToDateTime(text_date); // convert to Datetime if (idcustomer > 0 && idproduct > 0 && idstore > 0) // check if the ID exist for each table { var query = db.ProductSolds.Add(new ProductSold() { CustomerId = Convert.ToInt32(idcustomer), ProductId = Convert.ToInt32(idproduct), StoreId = Convert.ToInt32(idstore), DateSold = date, }); db.SaveChanges(); return(Json("SUCCESS", JsonRequestBehavior.AllowGet)); } } return(Json("FAILED", JsonRequestBehavior.DenyGet)); }
public ActionResult Create([Bind(Include = "ClassID,Class_Name,Class_Day,Class_Time,Class_Level")] ClassTiming classTiming) { if (ModelState.IsValid) { db.ClassTimings.Add(classTiming); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(classTiming)); }
public ActionResult Create([Bind(Include = "InventoryID,Product_Name,Product_Desc,Product_Cost,Product_SellPrice")] Inventory inventory) { if (ModelState.IsValid) { db.Inventories.Add(inventory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(inventory)); }
public ActionResult Create([Bind(Include = "MembershipID,Membership_Name,Membership_Fee")] MembershipType membershipType) { if (ModelState.IsValid) { db.MembershipTypes.Add(membershipType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(membershipType)); }
public ActionResult Create([Bind(Include = "RankID,Rank_Name")] Rank rank) { if (ModelState.IsValid) { db.Ranks.Add(rank); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rank)); }
public ActionResult Create([Bind(Include = "ParentID,StudentID,Mother_Name,Father_Name,Parent_Email,isStudent")] Parent parent) { if (ModelState.IsValid) { db.Parents.Add(parent); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StudentID = new SelectList(db.Students, "StudentID", "StudentName", parent.StudentID); return(View(parent)); }
public ActionResult Create([Bind(Include = "TestID,TestFees,RankID")] TestFee testFee) { if (ModelState.IsValid) { db.TestFees.Add(testFee); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RankID = new SelectList(db.Ranks, "RankID", "Rank_Name", testFee.RankID); return(View(testFee)); }
public ActionResult Create([Bind(Include = "StudentRankDetialID,StudentID,RankID")] StudentRankDetail studentRankDetail) { if (ModelState.IsValid) { db.StudentRankDetails.Add(studentRankDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RankID = new SelectList(db.Ranks, "RankID", "Rank_Name", studentRankDetail.RankID); ViewBag.StudentID = new SelectList(db.Students, "StudentID", "StudentName", studentRankDetail.StudentID); return(View(studentRankDetail)); }
public ActionResult Create([Bind(Include = "Attendence_ID,StudentID,Student_datetime,ClassID")] StudentAttendence studentAttendence) { if (ModelState.IsValid) { db.StudentAttendences.Add(studentAttendence); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassID = new SelectList(db.ClassTimings, "ClassID", "Class_Name", studentAttendence.ClassID); ViewBag.StudentID = new SelectList(db.Students, "StudentID", "StudentName", studentAttendence.StudentID); return(View(studentAttendence)); }
public JsonResult PostAddOneCustomer(Customer customer) { if (ModelState.IsValid) // checking the fields are completed { var query = db.Customers.Add(new Customer() { Name = customer.Name, Address = customer.Address }); db.SaveChanges(); return(Json(db.Customers.ToList(), JsonRequestBehavior.AllowGet)); } return(Json(db.Customers.ToList(), JsonRequestBehavior.DenyGet)); }
public JsonResult PostAddOneProduct(Product product) { if (ModelState.IsValid) // checking the fields are completed { var query = db.Products.Add(new Product() { Name = product.Name, Price = product.Price }); db.SaveChanges(); return(Json(db.Products.ToList(), JsonRequestBehavior.AllowGet)); } return(Json(db.Products.ToList(), JsonRequestBehavior.DenyGet)); }
public JsonResult PostAddOneStore(Store store) { if (ModelState.IsValid) // checking the fields are completed { var query = db.Stores.Add(new Store() { Name = store.Name, Address = store.Address }); db.SaveChanges(); return(Json(db.Stores.ToList(), JsonRequestBehavior.AllowGet)); } return(Json(db.Stores.ToList(), JsonRequestBehavior.DenyGet)); }
public ActionResult Create([Bind(Include = "StudentFeeID,StudentID,TestID,MembershipID,InventoryID,StudentFee_datetime")] StudentFee studentFee) { if (ModelState.IsValid) { db.StudentFees.Add(studentFee); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.InventoryID = new SelectList(db.Inventories, "InventoryID", "Product_Name", studentFee.InventoryID); ViewBag.MembershipID = new SelectList(db.MembershipTypes, "MembershipID", "Membership_Name", studentFee.MembershipID); ViewBag.StudentID = new SelectList(db.Students, "StudentID", "StudentName", studentFee.StudentID); ViewBag.TestID = new SelectList(db.TestFees, "TestID", "TestID", studentFee.TestID); return(View(studentFee)); }
public ActionResult Create([Bind(Include = "StudentID,StudentName,DateOfBirth,DateOfJoining,Student_Phone,Student_Email,Student_Address,isActive,isAdult")] Student student) { if (ModelState.IsValid) { db.Students.Add(student); db.SaveChanges(); StudentRankDetail sr = new StudentRankDetail(); sr.StudentID = student.StudentID; sr.RankID = 2; db.StudentRankDetails.Add(sr); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }