Exemple #1
0
        /// <summary>
        /// 提交新增益损数据
        /// </summary>
        /// <param name="model">益损数据</param>
        /// <returns>返回执行结果</returns>
        public ActionResult Add(ProfitLossAddModel model)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckObjectArgument <ProfitLossAddModel>("model", model);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                model.PostValidate(ref validate);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                this.profitLossService.Add(model.RecordId.Trim(), model.TargetType, model.Category, model.Quantity, model.Remark, this.Session["Mobile"].ToString());
                result.Result = true;
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
                return(Json(result));
            }
        }
        public ActionResult Delete(string id)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckStringArgument(WebResource.Field_Id, id, true);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                }
                else
                {
                    this.customerAddressService.Delete(id);
                    result.Result = true;
                }
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
                return(Json(result));
            }
        }
        public ActionResult PostAdd(CustomerAddressAddModel model)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckObjectArgument <CustomerAddressAddModel>("model", model);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                model.PostValidate(validate);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                this.customerAddressService.Add(model.CustomerId, model.Linkman, model.Mobile, model.Address, model.IsDefault ? Constant.COMMON_Y : Constant.COMMON_N, this.Session["Mobile"].ToString());
                result.Result = true;
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
                return(Json(result));
            }
        }
Exemple #4
0
        public ActionResult Save(DetailModel model)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckObjectArgument <DetailModel>("model", model);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                model.PostValidate(ref validate);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                this.saleOrderService.Update(model.Id, model.Status, model.ActualAmount, this.Session["Mobile"].ToString());
                result.Result = true;
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }
        public ActionResult PostAdd(PurchaseAddModel model)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckObjectArgument <PurchaseAddModel>("model", model);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                model.PostValidate(ref validate);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                this.purchaseService.Add(model.Date, model.Category, model.Item.Trim(), model.Quantity, model.Unit.Trim(), model.Supplier, model.Remark, model.CostData, this.Session["Mobile"].ToString());
                result.Result = true;
                result.Data   = "/Purchase/Index/" + model.Category;
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
                return(Json(result));
            }
        }
Exemple #6
0
        public ActionResult AddOrder(AddModel model)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckObjectArgument <AddModel>("model", model);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                model.PostValidate(ref validate);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                this.saleOrderService.Insert(model.Date, model.Item, model.Unit, model.Price, model.Quantity, model.ActualAmount, model.NeedExpress ? Constant.COMMON_Y : Constant.COMMON_N, model.Remark, model.AddressId, this.Session["Mobile"].ToString());
                result.Data   = "/SaleOrder/Index";
                result.Result = true;
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }
Exemple #7
0
        public ActionResult Add(CustomerGroupAddModel model)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckObjectArgument <CustomerGroupAddModel>("model", model);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                model.PostValidate(ref validate);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                this.customerGroupService.Add(model.Name, model.Remark, this.Session["Mobile"].ToString());
                result.Result = true;
            }
            catch (EasySoftException ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }
        public ActionResult PostAdd(string id, DeliveryFourthModel model)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckStringArgument(WebResource.Field_Id, id, true);
                validate.CheckObjectArgument <DeliveryFourthModel>("model", model);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                if (this.Session[id] == null)
                {
                    result.BuilderErrorMessage(WebResource.Message_DeliverySessionOut);
                    result.Data = "/Delivery/First";
                    return(Json(result));
                }

                model.PostValidate(ref validate);

                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                DeliveryAddDTO dto = (DeliveryAddDTO)this.Session[id];

                dto.Date           = model.Date;
                dto.ExpressCompany = model.ExpressCompany;
                dto.ExpressBill    = model.ExpressBill;
                dto.Remark         = model.Remark;
                dto.Creator        = this.Session["Mobile"].ToString();
                dto.Costs          = new List <CostAddDTO>();
                foreach (CostAddModel cost in model.Costs)
                {
                    dto.Costs.Add(new CostAddDTO {
                        Item = cost.Item, Money = cost.Money
                    });
                }
                this.deliveryService.Add(dto);

                result.Result = true;
                result.Data   = "/Delivery/Index";
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
                return(Json(result));
            }
        }
        public ActionResult PostSecond(string id, List <DeliveryDetailAddModel> packs)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckStringArgument(WebResource.Field_Id, id, true);
                validate.CheckList <DeliveryDetailAddModel>(WebResource.PurchaseItemCategory_Pack, packs);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                if (this.Session[id] == null)
                {
                    result.BuilderErrorMessage(WebResource.Message_DeliverySessionOut);
                    result.Data = "/Delivery/First";
                    return(Json(result));
                }
                DeliveryAddDTO dto = (DeliveryAddDTO)this.Session[id];
                Dictionary <string, DeliveryDetailAddDTO>   packDict      = new Dictionary <string, DeliveryDetailAddDTO>();
                Dictionary <string, PurchaseItemCacheModel> purchaseItems = ParameterHelper.GetPurchaseItem(PurchaseItemCategory.Pack, false);
                foreach (DeliveryDetailAddModel pack in packs)
                {
                    pack.PostValidate(ref validate);
                    dto.DeliveryDetails.Add(new DeliveryDetailAddDTO
                    {
                        PurchaseId       = pack.PurchaseId,
                        Item             = pack.Item,
                        ItemCategory     = pack.ItemCategory,
                        ItemName         = pack.ItemName,
                        DeliveryQuantity = pack.DeliveryQuantity
                    });
                }

                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                this.Session[id] = dto;
                result.Data      = "/Delivery/Third?id=" + id;
                result.Result    = true;
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }
Exemple #10
0
        public ActionResult Selected(string id, SaleOrderDetailAddModel model)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckStringArgument(WebResource.Field_Id, id, true);
                validate.CheckObjectArgument <SaleOrderDetailAddModel>("model", model);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                if (this.Session[id] == null)
                {
                    result.BuilderErrorMessage(WebResource.Message_DeliverySessionOut);
                    result.Data = "/SaleOrder/First";
                    return(Json(result));
                }
                model.PostValidate(ref validate);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                SaleOrderAddDTO       dto       = (SaleOrderAddDTO)this.Session[id];
                SaleOrderDetailAddDTO saleOrder = dto.SaleOrderDetails.Find(x => x.CustomerId == model.CustomerId);
                if (saleOrder != null)
                {
                    dto.SaleOrderDetails.RemoveAll(x => x.Id == model.Id);
                }
                if (model.Selected == Constant.COMMON_Y)
                {
                    dto.SaleOrderDetails.Add(new SaleOrderDetailAddDTO {
                        CustomerId = model.CustomerId, Linkman = model.Linkman, Mobile = model.Mobile, Address = model.Address, NeedExpress = model.NeedExpress, Selected = model.Selected, Id = model.Id
                    });
                }
                this.Session[id] = dto;
                result.Result    = true;
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }
Exemple #11
0
        public ActionResult PostFirst(string id, SaleOrderFirstModel saleOrder, string linkMan)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckStringArgument(WebResource.Field_Id, id, true);
                validate.CheckObjectArgument <SaleOrderFirstModel>("saleOrder", saleOrder);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                if (this.Session[id] == null)
                {
                    result.BuilderErrorMessage(WebResource.Message_DeliverySessionOut);
                    result.Data = "/SaleOrder/First";
                    return(Json(result));
                }
                saleOrder.PostValidate(ref validate);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                SaleOrderAddDTO dto = (SaleOrderAddDTO)this.Session[id];
                dto.Date         = saleOrder.Date;
                dto.Item         = saleOrder.Item;
                dto.Quantity     = saleOrder.Quantity;
                dto.Unit         = saleOrder.Unit;
                dto.Price        = saleOrder.Price;
                this.Session[id] = dto;
                result.Data      = "/SaleOrder/Second?id=" + id + "&linkMan=" + linkMan;
                result.Result    = true;
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }
Exemple #12
0
        public ActionResult PostSecond(string id, string linkMan)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckStringArgument(WebResource.Field_Id, id, true);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                if (this.Session[id] == null)
                {
                    result.BuilderErrorMessage(WebResource.Message_DeliverySessionOut);
                    result.Data = "/SaleOrder/First";
                    return(Json(result));
                }
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                SaleOrderAddDTO dto = (SaleOrderAddDTO)this.Session[id];
                validate.CheckList <SaleOrderDetailAddDTO>(WebResource.Field_Id, dto.SaleOrderDetails);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                result.Data   = "/SaleOrder/Third?id=" + id + "&linkMan=" + linkMan;
                result.Result = true;
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }
        public ActionResult Select(string id)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckStringArgument("id", id, true);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                CustomerAddress entity = this.customerAddressService.Select(id);
                result.Result = true;
                result.Data   = new CustomerAddressEditModel(entity).ToString();
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
                return(Json(result));
            }
        }
Exemple #14
0
        public ActionResult Login(LoginModel model)
        {
            JsonResultModel result   = new JsonResultModel();
            Validate        validate = new Validate();

            validate.CheckObjectArgument <LoginModel>("model", model);
            if (validate.IsFailed)
            {
                result.BuilderErrorMessage(validate.ErrorMessages);
                return(Json(result));
            }
            model.PostValidate(ref validate);
            if (validate.IsFailed)
            {
                result.BuilderErrorMessage(validate.ErrorMessages);
                return(Json(result));
            }

            User user = this.userService.Login(model.Mobile.Trim(), model.Password.Trim());

            if (user == null)
            {
                result.Message = WebResource.Message_LoginError;
            }
            else
            {
                this.Session["Mobile"] = model.Mobile;
                this.Session["Roles"]  = user.Roles;
                this.Session["Name"]   = user.Name;
                FormsAuthentication.SetAuthCookie(model.Mobile, false);

                result.Result = true;
                result.Data   = string.IsNullOrWhiteSpace(model.ReturnUrl) ? "/" : model.ReturnUrl;
            }
            return(Json(result));
        }
        public ActionResult PostThird(string id, List <SaleOrderExpressModel> orders)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckStringArgument(WebResource.Field_Id, id, true);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }
                if (this.Session[id] == null)
                {
                    result.BuilderErrorMessage(WebResource.Message_DeliverySessionOut);
                    result.Data = "/Delivery/First";
                    return(Json(result));
                }

                if (orders != null && orders.Count > 0)
                {
                    DeliveryAddDTO dto = (DeliveryAddDTO)this.Session[id];
                    dto.IncludeOrder = Constant.COMMON_Y;

                    Dictionary <string, SaleOrderExpressModel> orderDict = new Dictionary <string, SaleOrderExpressModel>();
                    foreach (SaleOrderExpressModel order in orders)
                    {
                        order.PostValidate(ref validate);
                        dto.SaleOrders.Add(new SaleOrderExpressDTO {
                            Id = order.Id, Item = order.Item, ItemName = order.ItemName, Quantity = order.Quantity, Unit = order.Unit
                        });
                        if (orderDict.ContainsKey(order.Item))
                        {
                            orderDict[order.Item].Quantity += order.Quantity;
                        }
                        else
                        {
                            orderDict.Add(order.Item, order);
                        }
                    }

                    List <string> summary = new List <string>();
                    foreach (KeyValuePair <string, SaleOrderExpressModel> saleAdd in orderDict)
                    {
                        summary.Add(string.Format("{0}{1}{2}", saleAdd.Value.ItemName, saleAdd.Value.Quantity, saleAdd.Value.Unit));
                        SaleAddDTO saleDto = dto.Sales.Find(x => x.Item == saleAdd.Value.Item);
                        if (saleDto == null)
                        {
                            throw new EasySoftException(string.Format("出库产品中没有包含{0}", saleAdd.Value.ItemName));
                        }
                        else
                        {
                            dto.Sales.RemoveAll(x => x.Item == saleAdd.Value.Item);
                            saleDto.Quantity -= saleAdd.Value.Quantity;
                            if (saleDto.Quantity < 0)
                            {
                                throw new EasySoftException(string.Format("{0}的出库量少于订单数量", saleAdd.Value.ItemName));
                            }
                            dto.Sales.Add(saleDto);
                        }
                    }
                    dto.Summary      = string.Format("{0}, 其中包含快递{1}", dto.Summary, string.Join(", ", summary.ToArray()));
                    this.Session[id] = dto;
                }

                result.Data   = "/Delivery/Fourth?id=" + id;
                result.Result = true;
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }
        public ActionResult PostFirst(string id, List <DeliveryDetailAddModel> products)
        {
            JsonResultModel result = new JsonResultModel();

            try
            {
                Validate validate = new Validate();
                validate.CheckStringArgument(WebResource.Field_Id, id, true);
                validate.CheckList <DeliveryDetailAddModel>(WebResource.PurchaseItemCategory_Product, products);
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                if (this.Session[id] == null)
                {
                    result.BuilderErrorMessage(WebResource.Message_DeliverySessionOut);
                    result.Data = "/Delivery/First";
                    return(Json(result));
                }
                DeliveryAddDTO dto = (DeliveryAddDTO)this.Session[id];
                Dictionary <string, SaleAddDTO> saleAddDict = new Dictionary <string, SaleAddDTO>();
                foreach (DeliveryDetailAddModel product in products)
                {
                    product.PostValidate(ref validate);
                    dto.DeliveryDetails.Add(new DeliveryDetailAddDTO
                    {
                        PurchaseId       = product.PurchaseId,
                        Item             = product.Item,
                        ItemCategory     = product.ItemCategory,
                        ItemName         = product.ItemName,
                        DeliveryQuantity = product.DeliveryQuantity,
                        PackQuantity     = product.PackQuantity,
                        PackUnit         = product.PackUnit
                    });
                    if (saleAddDict.ContainsKey(product.Item))
                    {
                        saleAddDict[product.Item].Quantity += product.PackQuantity;
                    }
                    else
                    {
                        saleAddDict.Add(product.Item, new SaleAddDTO {
                            Item = product.Item, ItemName = product.ItemName, Quantity = product.PackQuantity, Unit = product.PackUnit
                        });
                    }
                }
                List <string> summary = new List <string>();
                foreach (KeyValuePair <string, SaleAddDTO> saleAdd in saleAddDict)
                {
                    summary.Add(string.Format("{0}{1}{2}", saleAdd.Value.ItemName, saleAdd.Value.Quantity, saleAdd.Value.Unit));
                    dto.Sales.Add(saleAdd.Value);
                }
                dto.Summary = string.Join(",", summary.ToArray());
                if (validate.IsFailed)
                {
                    result.BuilderErrorMessage(validate.ErrorMessages);
                    return(Json(result));
                }

                this.Session[id] = dto;
                result.Data      = "/Delivery/Second?id=" + id;
                result.Result    = true;
            }
            catch (Exception ex)
            {
                result.BuilderErrorMessage(ex.Message);
            }
            return(Json(result));
        }