public ActionResult DeleteConfirmed(int id)
        {
            tblInvoiceItem tblInvoiceItem = db.tblInvoiceItems.Find(id);

            db.tblInvoiceItems.Remove(tblInvoiceItem);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: InvoiceItems/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblInvoiceItem tblInvoiceItem = db.tblInvoiceItems.Find(id);

            if (tblInvoiceItem == null)
            {
                return(HttpNotFound());
            }
            return(View(tblInvoiceItem));
        }
 public ActionResult Edit([Bind(Include = "InvoiceItemID,InvoiceID,ProductID,Make,Quantity,UnitID,SizeID,RatePerUnit,TaxID,Tax,TaxAmount,Discount,DiscountAmount,TotalAmount,Remark,HSN_SAC,IsActive,SGST,CGST")] tblInvoiceItem tblInvoiceItem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblInvoiceItem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.InvoiceID     = new SelectList(db.tblInvoices, "InvoiceID", "InvoiceNo", tblInvoiceItem.InvoiceID);
     ViewBag.InvoiceItemID = new SelectList(db.tblInvoiceItems, "InvoiceItemID", "Make", tblInvoiceItem.InvoiceItemID);
     ViewBag.InvoiceItemID = new SelectList(db.tblInvoiceItems, "InvoiceItemID", "Make", tblInvoiceItem.InvoiceItemID);
     ViewBag.ProductID     = new SelectList(db.tblProducts, "ProductID", "ProductName", tblInvoiceItem.ProductID);
     ViewBag.SizeID        = new SelectList(db.tblSizes, "SizeID", "SizeName", tblInvoiceItem.SizeID);
     ViewBag.TaxID         = new SelectList(db.tblTaxes, "TaxID", "TaxName", tblInvoiceItem.TaxID);
     ViewBag.UnitID        = new SelectList(db.tblUnits, "UnitID", "Name", tblInvoiceItem.UnitID);
     return(View(tblInvoiceItem));
 }
        // GET: InvoiceItems/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblInvoiceItem tblInvoiceItem = db.tblInvoiceItems.Find(id);

            if (tblInvoiceItem == null)
            {
                return(HttpNotFound());
            }
            ViewBag.InvoiceID     = new SelectList(db.tblInvoices, "InvoiceID", "InvoiceNo", tblInvoiceItem.InvoiceID);
            ViewBag.InvoiceItemID = new SelectList(db.tblInvoiceItems, "InvoiceItemID", "Make", tblInvoiceItem.InvoiceItemID);
            ViewBag.InvoiceItemID = new SelectList(db.tblInvoiceItems, "InvoiceItemID", "Make", tblInvoiceItem.InvoiceItemID);
            ViewBag.ProductID     = new SelectList(db.tblProducts, "ProductID", "ProductName", tblInvoiceItem.ProductID);
            ViewBag.SizeID        = new SelectList(db.tblSizes, "SizeID", "SizeName", tblInvoiceItem.SizeID);
            ViewBag.TaxID         = new SelectList(db.tblTaxes, "TaxID", "TaxName", tblInvoiceItem.TaxID);
            ViewBag.UnitID        = new SelectList(db.tblUnits, "UnitID", "Name", tblInvoiceItem.UnitID);
            return(View(tblInvoiceItem));
        }
Пример #5
0
        public ActionResult Create(tblInvoice tblInvoice, List <tblInvoiceItem> invItem, string submit)
        {
            List <tblInvoiceItem> tblItem           = new List <tblInvoiceItem>();
            tblInvoiceItem        objtblInvoiceItem = new tblInvoiceItem();
            tblUser objSource = (tblUser)Session["UserDetails"];

            if (submit == "Add Row")
            {
                tblProduct objpro  = db.tblProducts.Where(p => p.ProductID == tblInvoice.ProductID).FirstOrDefault();
                tblUnit    objUnit = db.tblUnits.Where(t => t.UnitID == tblInvoice.UnitID).FirstOrDefault();
                tblSize    objSize = db.tblSizes.Where(t => t.SizeID == tblInvoice.SizeID).FirstOrDefault();
                objtblInvoiceItem.ProductID      = tblInvoice.ProductID;
                objtblInvoiceItem.ProductName    = objpro.ProductName;
                objtblInvoiceItem.SizeID         = tblInvoice.SizeID;
                objtblInvoiceItem.UnitID         = tblInvoice.UnitID;
                objtblInvoiceItem.TaxID          = tblInvoice.TaxID;
                objtblInvoiceItem.Tax            = tblInvoice.Tax;
                objtblInvoiceItem.TaxAmount      = tblInvoice.TaxAmount;
                objtblInvoiceItem.Quantity       = tblInvoice.Quantity;
                objtblInvoiceItem.RatePerUnit    = tblInvoice.RatePerUnit;
                objtblInvoiceItem.IsDeleted      = false;
                objtblInvoiceItem.UnitName       = objUnit.Name;
                objtblInvoiceItem.SizeName       = objSize.SizeName;
                objtblInvoiceItem.HSN_SAC        = tblInvoice.HSN_SAC;
                objtblInvoiceItem.Discount       = tblInvoice.Discount;
                objtblInvoiceItem.DiscountAmount = tblInvoice.DiscountAmount;
                objtblInvoiceItem.SGST           = tblInvoice.SGST;
                objtblInvoiceItem.Make           = tblInvoice.Make;
                if (invItem == null)
                {
                    tblItem.Add(objtblInvoiceItem);
                    tblInvoice.tblInvoiceItems = tblItem;
                }
                else
                {
                    invItem.Add(objtblInvoiceItem);
                    tblInvoice.tblInvoiceItems = invItem;
                }
            }
            if (submit == "Delete Row")
            {
                ModelState.Clear();
                invItem.RemoveAll(a => a.IsDeleted == true);
                tblInvoice.tblInvoiceItems = invItem;
            }
            if (submit == "Save Invoice")
            {
                GetInvoiceDetails(tblInvoice, invItem, objSource.Id);
            }
            if (submit == "Print Preview")
            {
            }
            if (submit == "Print")
            {
            }

            //if (ModelState.IsValid)
            //{
            //    db.tblInvoices.Add(tblInvoice);
            //    db.SaveChanges();
            //    return RedirectToAction("Index");
            //}

            ViewBag.PaymentModeID = new SelectList(db.tblPaymentModes, "PaymentModeID", "PaymentMode", tblInvoice.PaymentModeID);
            ViewBag.ProductID     = new SelectList(db.tblProducts, "ProductID", "ProductName");
            ViewBag.SizeID        = new SelectList(db.tblSizes.Where(a => a.UnitID == tblInvoice.UnitID), "SizeID", "SizeName", tblInvoice.SizeID);
            ViewBag.UnitID        = new SelectList(db.tblUnits, "UnitID", "Name", tblInvoice.UnitID);
            // ViewBag.CreatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblInvoice.CreatedBy);
            // ViewBag.UpdatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblInvoice.UpdatedBy);
            return(View(tblInvoice));
        }