Exemplo n.º 1
0
        public ActionResult GenerateBill(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var BagsDetail = db.AspNetBillDetails.Where(x => x.BillID == id).ToList();

            ViewBag.BagsDetail = BagsDetail;
            AspNetBill aspNetBill = db.AspNetBills.Find(id);

            aspNetBill.Amount            = db.AspNetBillDetails.Where(x => x.BillID == id).Sum(x => x.Amount);
            aspNetBill.Freight_Charges   = aspNetBill.Freight_Charges;
            aspNetBill.Commission        = (aspNetBill.Amount * 5) / 100;
            aspNetBill.Labour            = (aspNetBill.Amount * 10) / 100;
            aspNetBill.Market_Fees       = BagsDetail.Sum(x => x.Bags) * 2;
            aspNetBill.Telephone_Charges = 5;
            aspNetBill.Accountant        = BagsDetail.Sum(x => x.Bags);
            aspNetBill.Total_Expenses    = aspNetBill.Freight_Charges + aspNetBill.Commission + aspNetBill.Labour + aspNetBill.Market_Fees + aspNetBill.Telephone_Charges + aspNetBill.Accountant;
            aspNetBill.Expenses          = aspNetBill.Total_Expenses;
            aspNetBill.Total_Amount      = aspNetBill.Amount - aspNetBill.Expenses;
            if (aspNetBill == null)
            {
                return(HttpNotFound());
            }
            return(View(aspNetBill));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            AspNetBill aspNetBill = db.AspNetBills.Find(id);

            db.AspNetBills.Remove(aspNetBill);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,FarmerID,Date,Truck_No,Bags_Qty,Freight_Charges,Commission,Labour,Market_Fees,Telephone_Charges,Accountant,Total_Expenses,Amount,Expenses,Total_Amount")] AspNetBill aspNetBill)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aspNetBill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FarmerID = new SelectList(db.AspNetFarmers, "Id", "Name", aspNetBill.FarmerID);
     return(View(aspNetBill));
 }
Exemplo n.º 4
0
        // GET: AspNetBills/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AspNetBill aspNetBill = db.AspNetBills.Find(id);

            if (aspNetBill == null)
            {
                return(HttpNotFound());
            }
            return(View(aspNetBill));
        }
Exemplo n.º 5
0
        // GET: AspNetBills/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AspNetBill aspNetBill = db.AspNetBills.Find(id);

            if (aspNetBill == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FarmerID = new SelectList(db.AspNetFarmers, "Id", "Name", aspNetBill.FarmerID);
            return(View(aspNetBill));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "Id,FarmerID,Date,Truck_No,Bags_Qty,Freight_Charges,Commission,Labour,Market_Fees,Telephone_Charges,Accountant,Total_Expenses,Amount,Expenses,Total_Amount")] AspNetBill aspNetBill)
        {
            if (ModelState.IsValid)
            {
                aspNetBill.FarmerName      = db.AspNetFarmers.Where(x => x.Id == aspNetBill.FarmerID).Select(x => x.Name).First();
                aspNetBill.Bill_Status     = "Not Generated";
                aspNetBill.Freight_Charges = 0;
                db.AspNetBills.Add(aspNetBill);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FarmerID = new SelectList(db.AspNetFarmers, "Id", "Name", aspNetBill.FarmerID);
            return(View(aspNetBill));
        }
Exemplo n.º 7
0
        public ActionResult GenerateBill(AspNetBill aspNetBill)
        {
            if (ModelState.IsValid)
            {
                AspNetBill aspNetBills = db.AspNetBills.Find(aspNetBill.Id);
                aspNetBill.FarmerID           = aspNetBill.FarmerID;
                aspNetBills.Accountant        = aspNetBill.Accountant;
                aspNetBills.Amount            = aspNetBill.Amount;
                aspNetBills.Commission        = aspNetBill.Commission;
                aspNetBills.Expenses          = aspNetBill.Expenses;
                aspNetBills.Freight_Charges   = aspNetBill.Freight_Charges;
                aspNetBills.Labour            = aspNetBill.Labour;
                aspNetBills.Market_Fees       = aspNetBill.Market_Fees;
                aspNetBills.Telephone_Charges = aspNetBill.Telephone_Charges;
                aspNetBills.Total_Amount      = aspNetBill.Total_Amount;
                aspNetBills.Total_Expenses    = aspNetBill.Total_Expenses;
                aspNetBills.Bill_Status       = "Generated";
                db.SaveChanges();
                var BagsDetails = db.AspNetBillDetails.Where(x => x.BillID == aspNetBill.Id).ToList();
                ViewBag.BagsDetail = BagsDetails;
                return(View(aspNetBills));
            }
            var BagsDetail = db.AspNetBillDetails.Where(x => x.BillID == aspNetBill.Id).ToList();

            ViewBag.BagsDetail           = BagsDetail;
            aspNetBill.Bill_Status       = "Not Generated";
            aspNetBill.Amount            = db.AspNetBillDetails.Where(x => x.BillID == aspNetBill.Id).Sum(x => x.Amount);
            aspNetBill.Freight_Charges   = aspNetBill.Freight_Charges;
            aspNetBill.Commission        = (aspNetBill.Amount * 5) / 100;
            aspNetBill.Labour            = (aspNetBill.Amount * 10) / 100;
            aspNetBill.Market_Fees       = BagsDetail.Sum(x => x.Bags) * 2;
            aspNetBill.Telephone_Charges = 5;
            aspNetBill.Accountant        = BagsDetail.Sum(x => x.Bags);
            aspNetBill.Total_Expenses    = aspNetBill.Freight_Charges + aspNetBill.Commission + aspNetBill.Labour + aspNetBill.Market_Fees + aspNetBill.Telephone_Charges + aspNetBill.Accountant;
            aspNetBill.Expenses          = aspNetBill.Total_Expenses;
            aspNetBill.Total_Amount      = aspNetBill.Amount - aspNetBill.Expenses;
            return(View(aspNetBill));
        }