Пример #1
0
        public PartialViewResult _EditPartial(int id)
        {
            try
            {
                SalesQuotationViewModels model = new SalesQuotationViewModels();
                model.SalesQuotation         = salesquotationRepository.FindOneQuotationById(id);
                model.SalesQuotationItemList = salesquotationRepository.FindOneQuotationItemById(id);

                //Bind Branch
                var BranchList = salesquotationRepository.GetAddressList().ToList();
                model.BranchList = BranchList;

                //Bind VAT
                var VATList = salesquotationRepository.GetVATList().ToList();
                model.VATList = VATList;

                //Bind Product
                var ProductList = salesquotationRepository.GetProductList().ToList();
                model.ProductList = ProductList;

                //Bind Businesspartner
                var BusinessParterList = salesquotationRepository.GetVendorList().ToList();
                model.BussinessList = BusinessParterList;


                return(PartialView(model));
            }
            catch (Exception ex)
            {
                ExceptionHandler.LogException(ex);
                ViewBag.AppErrorMessage = ex.Message;
                return(PartialView("Error"));
            }
        }
Пример #2
0
        public ActionResult Index(string submitButton, SalesQuotationViewModels model, HttpPostedFileBase file)
        {
            try
            {
                //ApplicationUser currentUser = ApplicationUserManager.GetApplicationUser(User.Identity.Name, HttpContext.GetOwinContext());

                if (submitButton == "Save")
                {
                    model.SalesQuotation.Document_Date    = DateTime.Now;
                    model.SalesQuotation.Doc_Status       = "Open";
                    model.SalesQuotation.Created_Branc_Id = CurrentBranchId;
                    model.SalesQuotation.Created_Date     = DateTime.Now;
                    model.SalesQuotation.Created_User_Id  = CurrentUser.Id; //GetUserId()
                    //model.SalesQuotation.Modified_User_Id = CurrentUser.Id;
                    //model.SalesQuotation.Modified_Date = DateTime.Now;
                    //model.SalesQuotation.Modified_Branch_Id = CurrentBranchId;

                    var QuotationList = model.SalesQuotationItemList.Where(x => x.IsDummy == 0);
                    model.SalesQuotationItemList = QuotationList.ToList();

                    if (salesquotationRepository.AddNewQuotation(model.SalesQuotation, model.SalesQuotationItemList, ref ErrorMessage))
                    {
                        //XMLGenerate_SAPInsert(model);
                        //for (int i = 0; i < model.PurchaseQuotationItemList.Count; i++)
                        //{
                        //    XMLGenerate_Quotation_SAPInsert(model.PurchaseQuotationItemList[i]);
                        //}
                        return(RedirectToAction("Index", "SalesQuotations"));
                    }
                    else
                    {
                        ViewBag.AppErrorMessage = ErrorMessage;
                        return(View("Error"));
                    }
                }
                else if (submitButton == "Update")
                {
                    model.SalesQuotation.Document_Date = DateTime.Now;
                    model.SalesQuotation.Doc_Status    = "Open";
                    //model.SalesQuotation.Created_Branc_Id = CurrentBranchId;
                    //model.SalesQuotation.Created_Date = DateTime.Now;
                    //model.SalesQuotation.Created_User_Id = CurrentUser.Id;  //GetUserId()
                    model.SalesQuotation.Modified_User_Id   = CurrentUser.Id;
                    model.SalesQuotation.Modified_Date      = DateTime.Now;
                    model.SalesQuotation.Modified_Branch_Id = CurrentBranchId;

                    //var QuotationList = model.PurchaseQuotationItemList.Where(x => x.IsDummy == 0);
                    //model.PurchaseQuotationItemList = QuotationList.ToList();

                    //for (int i = 0; i < model.PurchaseQuotationItemList.Count; i++)
                    //{
                    //    model.PurchaseQuotationItemList[i].Quoted_qty = 10; //GetQuantity()
                    //    model.PurchaseQuotationItemList[i].Quoted_date = DateTime.Now;
                    //}

                    if (salesquotationRepository.UpdateQuotation(model.SalesQuotation, model.SalesQuotationItemList, ref ErrorMessage))
                    {
                        //XMLGenerate_SAPUpdate(model);

                        return(RedirectToAction("Index", "SalesQuotations"));
                    }
                    else
                    {
                        ViewBag.AppErrorMessage = ErrorMessage;
                        return(View("Error"));
                    }
                }



                return(RedirectToAction("Index", "SalesQuotations"));
            }
            catch (Exception ex)
            {
                ExceptionHandler.LogException(ex);
                ViewBag.AppErrorMessage = ex.Message;
                return(View("Error"));
            }
        }