示例#1
0
 public ActionResult Details(SuperShopSaleViewModel salevm)
 {
     try
     {
         Sale sale = Mapper.Map <Sale>(salevm);
         List <SaleDetail> saleItems = Mapper.Map <List <SaleDetail> >(salevm.SaleDetails);
         sale.SaleDetails = new List <SaleDetail>();
         foreach (var item in saleItems)
         {
             sale.SaleDetails.Add(item);
         }
         if (!string.IsNullOrEmpty(salevm.ActionType) && salevm.ActionType == "Invoice")
         {
             return(Redirect("/SuperShopSale/ReportSaleMasterDetail/" + sale.Id));
         }
         else if (!string.IsNullOrEmpty(salevm.ActionType) && salevm.ActionType == "Label")
         {
             return(Redirect("/SuperShopSale/ReportLevelPrint/" + sale.Id));
         }
         return(Redirect("/SuperShopSale/"));
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }
示例#2
0
 public ActionResult Create(SuperShopSaleViewModel salevm)
 {
     try
     {
         //var ids = _saleService.Add(Mapper.Map<Sale>(salevm));
         var id = _rawSqlService.AddSaleItems(salevm);
         if (!string.IsNullOrEmpty(salevm.ActionType) && salevm.ActionType == "Invoice")
         {
             return(Redirect("/SuperShopSale/ReportSaleMasterDetail/" + id));
         }
         if (!string.IsNullOrEmpty(salevm.ActionType) && salevm.ActionType == "Label")
         {
             return(Redirect("/SuperShopSale/ReportLevelPrint/" + id));
         }
         if (!string.IsNullOrEmpty(salevm.ActionType) && salevm.ActionType == "Html")
         {
             return(Redirect("/SuperShopSale/HtmlReportPrint/" + id));
         }
         //return JavaScript($"ShowResult('{"Data save successfully."}','{"success"}','{"redirect"}','{"/SuperShopSale/Create"}')");
         if (!string.IsNullOrEmpty(salevm.ActionType) && salevm.ActionType == "Print")
         {
             return(Redirect("/SuperShopSale?id=" + id));
         }
         return(Redirect("/SuperShopSale"));
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }
        public ActionResult Create(string saleId)
        {
            try
            {
                SaleReturnViewModel saleReturnVm = new SaleReturnViewModel();
                List <SaleReturnDetailViewModel>    saleReturnDetails = new List <SaleReturnDetailViewModel>();
                SuperShopSaleViewModel              saleVm            = Mapper.Map <SuperShopSaleViewModel>(_saleService.GetById(saleId));
                List <SuperShopSaleDetailViewModel> saleDetails       = Mapper.Map <List <SuperShopSaleDetailViewModel> >(_saleService.GetAllSaleDetailbyMasterId(saleId).ToList());
                if (saleDetails.Any())
                {
                    foreach (var saleDetail in saleDetails)
                    {
                        SaleReturnDetailViewModel saleReturnDetail = new SaleReturnDetailViewModel
                        {
                            Select            = true,
                            SaleId            = saleDetail.SaleId,
                            SaleDetailId      = saleDetail.Id,
                            ProductId         = saleDetail.ProductId,
                            ProductCode       = saleDetail.ProductCode,
                            ProductName       = saleDetail.ProductName,
                            SoldQuantity      = saleDetail.Quantity,
                            SoldAmount        = saleDetail.TotalAmount,
                            UOMId             = saleDetail.UOMId,
                            UOMName           = saleDetail.UOMName,
                            RemainingQuantity = saleDetail.Quantity - _saleReturnService.GetSumOfAlreadyReturnQty(saleDetail.SaleId, saleDetail.ProductId),
                            SalePrice         = saleDetail.SalePrice,
                            ReturnUnitPrice   = saleDetail.SalePrice,
                            CompanyId         = saleDetail.CompanyId,
                            BranchId          = saleDetail.BranchId,
                            SupplierId        = saleDetail.SupplierId,
                        };

                        saleReturnDetail.ReturnQuantity = saleReturnDetail.RemainingQuantity;
                        saleReturnDetail.ReturnAmount   = saleDetail.SalePrice * saleReturnDetail.ReturnQuantity;
                        saleReturnDetails.Add(saleReturnDetail);
                    }
                }
                saleReturnVm.SelectAll         = true;
                saleReturnVm.SaleId            = saleVm.Id;
                saleReturnVm.SaleDate          = saleVm.SaleDate;
                saleReturnVm.CustomerId        = saleVm.CustomerId;
                saleReturnVm.CustomerName      = saleVm.CustomerName;
                saleReturnVm.CompanyId         = saleVm.CompanyId;
                saleReturnVm.BranchId          = saleVm.BranchId;
                saleReturnVm.SalesReturnDate   = DateTime.Now;
                saleReturnVm.SaleReturnDetails = new List <SaleReturnDetailViewModel>();
                saleReturnVm.SaleReturnDetails.AddRange(saleReturnDetails);
                return(View(saleReturnVm));
            }
            catch (Exception ex)
            {
                return(JavaScript($"ShowResult('{ex.Message}','failure')"));
            }
        }
示例#4
0
        public ActionResult Details(string id)
        {
            try
            {
                var identity = (LoginIdentity)Thread.CurrentPrincipal.Identity;
                SuperShopSaleViewModel salevm = Mapper.Map <SuperShopSaleViewModel>(_saleService.GetById(id));
                List <SuperShopSaleDetailViewModel> saleItems = Mapper.Map <List <SuperShopSaleDetailViewModel> >(_saleService.GetAllSaleDetailbyMasterId(id).ToList());

                salevm.SaleDetails = new List <SuperShopSaleDetailViewModel>();
                salevm.SaleDetails.AddRange(saleItems);
                return(View(salevm));
            }
            catch (Exception ex)
            {
                return(JavaScript($"ShowResult('{ex.Message}','failure')"));
            }
        }
示例#5
0
 public ActionResult Create(string id)
 {
     try
     {
         var identity   = (LoginIdentity)Thread.CurrentPrincipal.Identity;
         var serializer = new JavaScriptSerializer()
         {
             MaxJsonLength = int.MaxValue
         };
         ViewBag.ProductList             = serializer.Serialize(_rawSqlService.GetBranchwiseProductStockGreaterThanZero(identity.CompanyId, identity.BranchId));
         ViewBag.PromotionalDiscountList = serializer.Serialize(_rawSqlService.GetPromotionalPointAndDiscount(DateTime.Today));
         ViewBag.ItemList     = serializer.Serialize(_rawSqlService.GetBranchwiseProductStockAll(identity.CompanyId, identity.BranchId));
         ViewData["SaleDate"] = DateTime.Now.ToString("MM/dd/yyyy hh:mm tt");
         ViewData["open"]     = 0;
         var dataSet   = new DataSet();
         var customers = Mapper.Map <IEnumerable <CustomerViewModel> >(_customerService.GetAll());
         var customer  = new CustomerViewModel {
             ACustomers = customers.ToList()
         };
         if (!string.IsNullOrEmpty(id))
         {
             ViewData["open"] = 1;
             dataSet          = _rawSqlService.ReportLevelPrint(id);
         }
         SuperShopSaleViewModel vm = new SuperShopSaleViewModel
         {
             Id          = _saleService.GenerateAutoId(identity.CompanyId, identity.BranchId, "Sale"),
             SaleDate    = DateTime.Now,
             PaymentType = PaymentType.Cash.ToString(),
             Customer    = customer,
             Sales       = dataSet
         };
         return(View(vm));
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }
示例#6
0
 public ActionResult Edit(string id)
 {
     try
     {
         var identity   = (LoginIdentity)Thread.CurrentPrincipal.Identity;
         var serializer = new JavaScriptSerializer()
         {
             MaxJsonLength = int.MaxValue
         };
         ViewBag.ProductList             = serializer.Serialize(_rawSqlService.GetBranchwiseProductStockGreaterThanZero(identity.CompanyId, identity.BranchId));
         ViewBag.PromotionalDiscountList = serializer.Serialize(_rawSqlService.GetPromotionalPointAndDiscount(DateTime.Today));
         SuperShopSaleViewModel salevm = Mapper.Map <SuperShopSaleViewModel>(_saleService.GetById(id));
         List <SuperShopSaleDetailViewModel> saleItems = Mapper.Map <List <SuperShopSaleDetailViewModel> >(_saleService.GetAllSaleDetailbyMasterId(id).ToList());
         ViewBag.NetAmount  = salevm.NetAmount;
         salevm.SaleDetails = new List <SuperShopSaleDetailViewModel>();
         salevm.SaleDetails.AddRange(saleItems);
         return(View(salevm));
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }
示例#7
0
 public ActionResult Edit(SuperShopSaleViewModel salevm)
 {
     try
     {
         var id = _saleService.Update(Mapper.Map <Sale>(salevm));
         if (!string.IsNullOrEmpty(salevm.ActionType) && salevm.ActionType == "Invoice")
         {
             return(Redirect("/SuperShopSale/ReportSaleMasterDetail/" + id));
         }
         if (!string.IsNullOrEmpty(salevm.ActionType) && salevm.ActionType == "Label")
         {
             return(Redirect("/SuperShopSale/ReportLevelPrint/" + id));
         }
         if (!string.IsNullOrEmpty(salevm.ActionType) && salevm.ActionType == "Print")
         {
             return(Redirect("/SuperShopSale?id=" + id));
         }
         return(Redirect("/SuperShopSale"));
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }