public ActionResult DeleteConfirmed(int id)
        {
            Tr_Masters tr_Masters = db.Tr_Masters.Find(id);

            db.Tr_Masters.Remove(tr_Masters);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Tr_MasterID,Tr_Date,MemoNo,DistrictID,ClientID,PackDebit,Less,Type,ReturnLessMemoNo,InvoiceNo,BindID,OrderID,Commission")] Tr_Masters tr_Masters)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tr_Masters).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClientID   = new SelectList(db.Clients, "ClientID", "ClientName", tr_Masters.ClientID);
     ViewBag.DistrictID = new SelectList(db.Districts, "DistrictID", "DistrictName", tr_Masters.DistrictID);
     return(View(tr_Masters));
 }
        public ActionResult Create([Bind(Include = "Tr_MasterID,Tr_Date,MemoNo,DistrictID,ClientID,PackDebit,Less,Type,ReturnLessMemoNo,InvoiceNo,BindID,OrderID,Commission")] Tr_Masters tr_Masters)
        {
            if (ModelState.IsValid)
            {
                db.Tr_Masters.Add(tr_Masters);
                db.SaveChanges();
                return(RedirectToAction("Nes.cshtml"));
            }

            ViewBag.ClientID   = new SelectList(db.Clients, "ClientID", "ClientName", tr_Masters.ClientID);
            ViewBag.DistrictID = new SelectList(db.Districts, "DistrictID", "DistrictName", tr_Masters.DistrictID);
            return(View(tr_Masters));
        }
        // GET: Tr_Masters/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tr_Masters tr_Masters = db.Tr_Masters.Find(id);

            if (tr_Masters == null)
            {
                return(HttpNotFound());
            }
            return(View(tr_Masters));
        }
        // GET: Tr_Masters/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tr_Masters tr_Masters = db.Tr_Masters.Find(id);

            if (tr_Masters == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ClientID   = new SelectList(db.Clients, "ClientID", "ClientName", tr_Masters.ClientID);
            ViewBag.DistrictID = new SelectList(db.Districts, "DistrictID", "DistrictName", tr_Masters.DistrictID);
            return(View(tr_Masters));
        }
        //.................


        //public ActionResult BookList()
        //{
        //    BookCreateVM book = new BookCreateVM();
        //    book.selectListOrganization = _select.SelectBook();
        //    return View(book);
        //}


        public ActionResult SaveOrder(int?invoiceNo, string memoNo, string salesType, int districtId, int clientID, int?packdebit, DateTime date, int?less, int commission2, decimal netAmount, Tr_Details[] Tr_Detail, Book[] book, BookGroup[] bookGroup, District[] district, Client[] client)
        {
            string result = "Error! Order Is Not Complete ";

            if (invoiceNo != null || memoNo != null || Tr_Detail != null || book != null || packdebit != null || bookGroup != null || district != null || client != null)
            {
                Tr_Masters model = new Tr_Masters();
                model.InvoiceNo  = invoiceNo;
                model.Less       = less;
                model.DistrictID = districtId;
                model.ClientID   = clientID;
                model.PackDebit  = packdebit;
                model.Type       = salesType;
                model.Commission = commission2;
                model.Tr_Date    = date;
                MoneyReceipt moneyReceipt = new MoneyReceipt();
                moneyReceipt.PartyCode = clientID;
                moneyReceipt.EntryDate = date;
                moneyReceipt.Amount    = netAmount;
                db.MoneyReceipts.Add(moneyReceipt);
                db.Tr_Masters.Add(model);
                foreach (var item in Tr_Detail)
                {
                    Tr_Details o = new Tr_Details();
                    o.BookID      = item.BookID;
                    o.BookGroupID = item.BookGroupID;
                    o.Qty         = item.Qty;
                    o.Rate        = item.Rate;
                    o.Commission  = item.Commission;
                    o.Amount      = item.Amount;
                    db.Tr_Details.Add(o);
                }

                db.SaveChanges();
                result = "Success Order Is Complete ";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }