public ActionResult Create(string id)
 {
     ViewBag.Title = "购买详情";
     int currentUserId = Convert.ToInt32(Session["CurrentUserId"].ToString());
     var companySvc = new CompanyService();
     ViewBag.AllCompanyList = companySvc.GetCompanyByRelUserId(currentUserId);//初始化购买订单页面
     var tradeManagementEditVM = TradeManagementSvc.GetSalesOrderByStockId(Convert.ToInt32(id), currentUserId);
     ViewBag.PricingType = tradeManagementEditVM.PricingType;
     return View("Edit", tradeManagementEditVM);
 }
 public ActionResult CancelAction(string stockId, string companyId, string qty)
 {
     ViewBag.Title = "购买详情";
     int currentUserId = Convert.ToInt32(Session["CurrentUserId"].ToString());
     var companySvc = new CompanyService();
     ViewBag.AllCompanyList = companySvc.GetCompanyByRelUserId(currentUserId);//初始化购买订单页面
     var tradeManagementEditVM = TradeManagementSvc.GetSalesOrderByStockId(Convert.ToInt32(stockId), currentUserId);
     ViewBag.PricingType = tradeManagementEditVM.PricingType;
     tradeManagementEditVM.CompanyId = Convert.ToInt32(companyId);
     tradeManagementEditVM.Quantity = Convert.ToDecimal(qty);
     return View("Edit", tradeManagementEditVM);
 }
        //根据库存ID生成新增的SaleOrder
        public TradeManagementEditVM GetSalesOrderByStockId(int stockId, int currentUserId)
        {
            var stockDal = new StockDAL();
            var stock = stockDal.GetById(stockId, new List<string> { "Commodity","CommodityType","Brand","Warehouse","Company"});
            var tradeManagementEditVM = new TradeManagementEditVM {
              Premium = string.Format("{0:#,##0}", stock.Premium),
              Price = string.Format("{0:#,##0.00}", stock.Price),
              CommodityName = stock.Commodity == null ? "" : stock.Commodity.Name,
              CommodityTypeName = stock.CommodityType == null ? "" : stock.CommodityType.Name,
              BrandName = stock.Brand == null ? "" : stock.Brand.Name,
              Warehouse = stock.Warehouse == null ? "" : stock.Warehouse.Name,
              BuyUnit = stock.BuyUnit,
              PricingType = stock.PricingType,
              SalerName = stock.Company.Name,
              CommodityId = stock.CommodityId,
              CommodityCode = stock.Commodity.Code,
              CommodityUnit = stock.Commodity.CommodityUnit,
              StockId = stock.Id
            };
            var companySvc = new CompanyService();
            List<CompanyVM> companyList = companySvc.GetCompanyByRelUserId(currentUserId);
            if(companyList != null && companyList.Count > 0)
            {
                tradeManagementEditVM.CompanyId = companyList.FirstOrDefault().Id;
            }
            var sysSettingSvc = new SysSettingService();
            var sysSettingVM = sysSettingSvc.GetSysSetting();
            tradeManagementEditVM.CountDown = sysSettingVM.CountDown;

            return tradeManagementEditVM;
        }
 public JsonResult GetAllCompanyList()
 {
     int currentUserId = Convert.ToInt32(Session["CurrentUserId"].ToString());
     var companySvc = new CompanyService();
     var companyList = companySvc.GetCompanyByRelUserId(currentUserId);//初始化购买订单页面
     var result = companyList.Select(o => new Dictionary<string, object>
                                            {
                                                {"id", o.Id},
                                                {"text", o.Name}
                                            }).ToList();
     return Json(result);
 }