//Delete users public JsonResult DelUsers(int id, int?pageNumber) { tbl_Account tbl_Account = db.tbl_Account.Find(id); db.tbl_Account.Remove(tbl_Account); db.SaveChanges(); //list all users var showlst = db.tbl_Account. Join(db.Branches, a => a.Branch, b => b.Id, (a, b) => new UserProfileView { AID = a.AID, Username = a.Username, Password = a.Password, FName = a.FName, LName = a.LName, CDate = a.CDate, Branch = b.Id, Role = a.Role }).ToList(); return(Json(showlst, JsonRequestBehavior.AllowGet)); }
//TODO: Add new Bill---------------------------------------------------------------- public void AddNewBill(AddNewBill bdv) { //hear we are going to get the max no form YearMaxBillNo., why we do that because that no will be used to form the finall bill no. int maxNo = 0; using (LundryDbContext db = new LundryDbContext()) { if (checkDates()) //if the current date is less than the end date which is the last day in the year e.g (31/12/2016) { //TODO: if result is true...get max from the current year; var getCYear = DateTime.Now.Year.ToString(); maxNo = getMaxBillNo(getCYear); //get the max bill no depending on the year from table yearmaxbillnoes AddBill(maxNo); //calling the method AddBill to add the new bill to the database //update the YearMaxBillNoes by adding the new max bill no to the year int getCount = db.yearmaxbillno.Where(x => x.year.Equals(getCYear)).Count(); if (getCount > 0) // check to see if we are not at the begining of the year { YearMaxBillNo yrbl = db.yearmaxbillno.Where(x => x.year.Equals(getCYear)).FirstOrDefault(); yrbl.maxbillno = (maxNo + 1); db.SaveChanges(); } else { YearMaxBillNo yrbl = new YearMaxBillNo(); yrbl.year = getCYear; yrbl.maxbillno = 1; db.yearmaxbillno.Add(yrbl); db.SaveChanges(); } } else { //TODO: if result is true...get max from the current year; var getCYear = DateTime.Now.Year.ToString(); maxNo = getMaxBillNo(getCYear); //get the max bill no depending on the year from table yearmaxbillnoes AddBill(maxNo); //calling the method AddBill to add the new bill to the database //update the YearMaxBillNoes by adding the new max bill no to the year YearMaxBillNo yrbl = db.yearmaxbillno.Where(x => x.year.Equals(getCYear)).FirstOrDefault(); if (string.IsNullOrEmpty(yrbl.year)) { yrbl.maxbillno = maxNo + 1; db.SaveChanges(); } else { yrbl.year = getCYear; yrbl.maxbillno = 1; db.SaveChanges(); } } } }
public ActionResult Edit([Bind(Include = "Id,catName")] ItemMainCategory category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult addBillNo(BillViewData blno) { paidbill pbl = new paidbill(); pbl = db.paidbills.Where(x => x.BillNo.Equals(blno.BillNo)).FirstOrDefault(); pbl.IsPaid = blno.IsPaid; db.SaveChanges(); ViewBag.Status = "Bill Added Successfully"; return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "UserId,Name,UserName,Password")] User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create([Bind(Include = "Id,Name,Desc")] Branch branch) { if (ModelState.IsValid) { db.Branches.Add(branch); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(branch)); }
public ActionResult Create([Bind(Include = "CustId,CustName,Tel,Type")] Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "Id,catName,MId")] ItemSubCategory itemSubCategory) { if (ModelState.IsValid) { db.ItemSubCategories.Add(itemSubCategory); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MId = new SelectList(db.ItemMainCategories, "Id", "catName", itemSubCategory.MId); return(View(itemSubCategory)); }
public ActionResult Create([Bind(Include = "ItemId,MId,SId,ItemName,itemImg,Price,Description")] Item item) { if (ModelState.IsValid) { db.Items.Add(item); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MId = new SelectList(db.ItemMainCategories, "Id", "catName", item.MId); ViewBag.SId = new SelectList(db.ItemSubCategories, "Id", "catName", item.SId); return(View(item)); }
public ActionResult Create([Bind(Include = "Id,AID,RID")] tbl_Account_role tbl_Account_role) { if (ModelState.IsValid) { db.tbl_Account_role.Add(tbl_Account_role); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AID = new SelectList(db.tbl_Account, "AID", "Username", tbl_Account_role.AID); ViewBag.RID = new SelectList(db.tbl_Role, "RID", "RoleName", tbl_Account_role.RID); return(View(tbl_Account_role)); }
public void AddBill(int maxBillNo) { using (LundryDbContext db = new LundryDbContext()) { var getCYear = DateTime.Now.Year.ToString();//get current year getCYear = getCYear.Substring(2); Bill bl = new Bill(); paidbill pbl = new paidbill(); //here am searching inside the temp table to get all the items qyt and price, which were perviouslly added before saving the whole bill details var orr = (from s in db.tempBills select s).ToList(); foreach (var itm in orr) { bl.ItemId = itm.ItemId; bl.CustId = itm.CustId; bl.Qyt = itm.Qyt; bl.Cost = itm.Cost; String format = "dd/MM/yyyy"; var currentDate = DateTime.Today.ToString("dd/MM/yyyy"); DateTime dt = DateTime.ParseExact(currentDate.ToString(), format, System.Globalization.CultureInfo.InvariantCulture); // DateTime dte = DateTime.ParseExact(dd, format, CultureInfo.InvariantCulture); bl.Date = dt; bl.BillNo = maxBillNo + 1; bl.printedBill = "(0" + SessionPersister.BranchID + ")" + (getCYear + (maxBillNo + 1)).ToString().PadLeft(5, '0'); // this is the bill no which will be printed db.Bills.Add(bl); db.SaveChanges(); } //Here we are going to remove all the items from the tempBills table foreach (var itm in orr) { db.tempBills.Remove(itm); } // now we are going to add the new entered bill inot the paidbill tables, and makred it unpaid pbl.BillNo = maxBillNo + 1; pbl.printedBill = "(0" + SessionPersister.BranchID + ")" + (getCYear + (maxBillNo + 1)).ToString().PadLeft(5, '0'); // this is the bill no which will be printed pbl.IsPaid = false; db.paidbills.Add(pbl); db.SaveChanges(); SessionPersister.printBillNo = "(0" + SessionPersister.BranchID + ")" + (getCYear + (maxBillNo + 1)).ToString().PadLeft(5, '0'); } }
//TODO: Add New MainCategory public void AddNewMainCat(AddNewMainCategory itMaCa) { using (LundryDbContext db = new LundryDbContext()) { ItemMainCategory mainCat = new ItemMainCategory(); mainCat.catName = itMaCa.catName; db.ItemMainCategories.Add(mainCat); db.SaveChanges(); } }
//Add Temprory Bills public ActionResult AddTemp(int custId, int itemId, int qyt, decimal cost, int MId, int SId) { try { ////TODO:Save the data to Bills //int maxBillNo = db.Bills.Max(x => x.BillNo); // Get the Maximum BillNo // Bill bill=new Bill(); // bill.CustId = custId; // bill.ItemId = itemId; // bill.Date = DateTime.Now; // bill.Qyt = qyt; // bill.Cost = cost; ////bill.BillNo = maxBillNo + 1; // Increasing the BillNo by 1 // db.Bills.Add(bill); // db.SaveChanges(); // TODO: Save Data to tempBill tempBill tb = new tempBill(); tb.CustId = custId; tb.ItemId = itemId; tb.Date = DateTime.Now; tb.Qyt = qyt; tb.Cost = cost; tb.MId = MId; tb.SId = SId; db.tempBills.Add(tb); db.SaveChanges(); var itmlst = (from itm in db.Items join bls in db.tempBills on itm.ItemId equals bls.ItemId join cst in db.Customers on bls.CustId equals cst.CustId select new TempBillsDetails { Id = bls.Id, CustId = bls.CustId, CustName = cst.CustName, ItemId = bls.ItemId, ItemName = itm.ItemName, Qyt = bls.Qyt, Cost = bls.Cost, Date = bls.Date }).ToList(); return(Json(itmlst, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(RedirectToAction("Create")); } }
//TODO: Disable all the Discount.This may used in case we choosed discount fro All Branche, and we need to make all other discound in active public void DisableAll() { using (var db = new LundryDbContext()) { db.Discs .Where(x => x.status == true) .ToList() .ForEach(a => a.status = false); db.SaveChanges(); } //var disall = db.Discs.Where(x => x.status == true).ToList().ForEach(x=>x.status= false); }
public ActionResult BatchUpload() { bool isSavedSuccessfully = true; int count = 0; string msg = ""; string fileName = ""; string fileExtension = ""; string filePath = ""; string fileNewName = ""; // here is obtain strong //int albumId = string.IsNullOrEmpty(Request.Params["hidAlbumId"]) // 0 : int.Parse(Request.Params["hidAlbumId"]); tbl_images ItmImg = new tbl_images(); try { string directoryPath = Server.MapPath("~/uploads/images"); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } foreach (string f in Request.Files) { HttpPostedFileBase file = Request.Files[f]; if (file != null && file.ContentLength > 0) { fileName = file.FileName; fileExtension = Path.GetExtension(fileName); fileNewName = Guid.NewGuid().ToString() + fileExtension; filePath = Path.Combine(directoryPath, fileNewName); file.SaveAs(filePath); Stream strm = file.InputStream; string path_Thumb = System.IO.Path.Combine(Server.MapPath("~/uploads/Thumbs"), fileNewName); ItmImg.imgL = "/uploads/Images/" + fileNewName; //path to large images ItmImg.imgS = "/uploads/Thumbs/" + fileNewName; // path to thumbnail images GenerateThumbnails(0.5, strm, path_Thumb); //here reducing the image by 50% db.tbl_images.Add(ItmImg); db.SaveChanges(); count++; } } } catch (Exception ex) { msg = ex.Message; isSavedSuccessfully = false; } return(Json(new { Result = isSavedSuccessfully, Count = count, Message = msg })); }