Esempio n. 1
0
        public ActionResult Create([Bind(Include = "BookGroupID,MainBookName,Class")] BookGroup bookGroup)
        {
            if (ModelState.IsValid)
            {
                db.BookGroups.Add(bookGroup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bookGroup));
        }
        public ActionResult Create([Bind(Include = "DivisionID,DivisionName")] Division division)
        {
            if (ModelState.IsValid)
            {
                db.Divisions.Add(division);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(division));
        }
        public ActionResult Create([Bind(Include = "BookID,BookGroupID,BookName,Price,Commission,BookOpnBalance,AuthorName,Status,ReturnRate,BookForma")] Book book)
        {
            if (ModelState.IsValid)
            {
                db.Books.Add(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BookGroupID = new SelectList(db.BookGroups, "BookGroupID", "MainBookName", book.BookGroupID);
            return(View(book));
        }
        public ActionResult Create([Bind(Include = "DistrictID,DistrictName,DivisionID")] District district)
        {
            if (ModelState.IsValid)
            {
                db.Districts.Add(district);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DivisionID = new SelectList(db.Divisions, "DivisionID", "DivisionName", district.DivisionID);
            return(View(district));
        }
        public ActionResult Create([Bind(Include = "ClientID,ClientName,Address,DistrictID,ContactNo,Email,ClientOpnBalance,ClientType,TrDate")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DistrictID = new SelectList(db.Districts, "DistrictID", "DistrictName", client.DistrictID);
            return(View(client));
        }
        public ActionResult Create([Bind(Include = "Tr_DetailID,Tr_MasterID,BookGroupID,BookID,Qty,Rate,Commission")] Tr_Details tr_details)
        {
            if (ModelState.IsValid)
            {
                //tr_details.Tr_DetailID = Guid.NewGuid();
                db.Tr_Details.Add(tr_details);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Tr_MasterID = new SelectList(db.Tr_Masters, "Tr_MasterID", "MemoNo", tr_details.Tr_MasterID);
            return(View(tr_details));
        }
        //.................


        //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));
        }