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"));
        }
示例#2
0
        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');
            }
        }