Пример #1
0
 public void SavePartnerOrderProduct(Sender sender, PartnerOrderProduct obj)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy(true))
         {
             if (op.LoadPartnerOrderProduct(obj) == 0)
             {
                 obj.Created   = DateTime.Now;
                 obj.CreatedBy = sender.UserCode + "." + sender.UserName;
                 op.InsertPartnerOrderProduct(obj);
             }
             else
             {
                 obj.Created   = DateTime.Now;
                 obj.CreatedBy = sender.UserCode + "." + sender.UserName;
                 op.UpdatePartnerOrderProductByProductID(obj);
             }
             op.CommitTransaction();
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Пример #2
0
 public List <PartnerOrderProduct> GetPartnerOrderProductByOrderID(Sender sender, Guid OrderID)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             PartnerOrderProduct obj = new PartnerOrderProduct();
             obj.OrderID = OrderID;
             return(op.LoadPartnerOrderProductByOrderID(obj));
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Пример #3
0
 public PartnerOrderProduct GetPartnerOrderProduct(Sender sender, Guid ProductID)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             PartnerOrderProduct obj = new PartnerOrderProduct();
             obj.ProductID = ProductID;
             if (op.LoadPartnerOrderProduct(obj) == 0)
             {
                 return(null);
             }
             return(obj);
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Пример #4
0
        public void SavePartnerOrder()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    #region Order
                    var          flag  = "false";
                    PartnerOrder order = p.Client.GetPartnerOrder(SenderUser, parm.OrderID);
                    if (parm.OrderType == "")
                    {
                        throw new Exception("请选择订单类型");
                    }
                    if (order == null)
                    {
                        order         = new PartnerOrder();
                        order.OrderID = parm.OrderID;
                    }

                    //修改订单保存
                    flag = Request["edit"];
                    if (flag == "true")
                    {
                        order.OrderNo = parm.OrderNo;
                    }
                    else
                    {
                        order.OrderNo = "";
                    }
                    order.PartnerID      = parm.PartnerID;
                    order.CustomerID     = parm.CustomerID;
                    order.OutOrderNo     = parm.OutOrderNo;
                    order.Address        = parm.Address;
                    order.CustomerName   = parm.CustomerName;
                    order.AttachmentFile = HttpUtility.UrlDecode(parm.AttachmentFile, Encoding.UTF8);
                    order.PartnerName    = parm.PartnerName;
                    order.SalesMan       = parm.SalesMan;
                    order.BookingDate    = parm.BookingDate;
                    order.Mobile         = parm.Mobile;
                    order.ShipDate       = parm.ShipDate;
                    order.OrderType      = parm.OrderType;
                    order.Remark         = parm.Remark;
                    order.Status         = OrderStatus.A.ToString();
                    order.StepNo         = p.Client.GetOrderStepByStepCode(SenderUser, StepCode.partneraddorder.ToString()).StepNo;
                    SavePartnerOrderArgs args = new SavePartnerOrderArgs();
                    args.Order = order;
                    #endregion

                    #region OrderProduct
                    List <PartnerOrderProduct> list = new List <PartnerOrderProduct>();
                    string   Cabinets = Request["Cabinets"];
                    JsonData sj       = JsonMapper.ToObject(Cabinets);
                    if (sj.Count > 0)
                    {
                        foreach (JsonData item in sj)
                        {
                            PartnerOrderProduct model = new PartnerOrderProduct();
                            model.OrderID          = order.OrderID;
                            model.ProductID        = Guid.Parse(item["ProductID"].ToString());
                            model.ProductName      = item["ProductName"].ToString();
                            model.ProductGroup     = item["ProductGroup"].ToString();
                            model.Qty              = Decimal.Parse(item["Qty"].ToString());
                            model.Price            = Decimal.Parse(item["Price"].ToString());
                            model.Size             = item["Size"].ToString();
                            model.MaterialStyle    = item["MaterialStyle"].ToString();
                            model.Color            = item["Color"].ToString();
                            model.MaterialCategory = item["MaterialCategory"].ToString();
                            model.Unit             = item["Unit"].ToString();
                            model.Remark           = item["Remark"].ToString();
                            model.SalePrice        = 0;
                            model.TotalAreal       = 0;
                            model.TotalLength      = 0;
                            model.ProductStatus    = "N";
                            //Product.ProductCode = ((char)(64 + cabinet.Sequence)).ToString();
                            if (flag == "true")
                            {
                                model.Created   = DateTime.Now;
                                model.CreatedBy = SenderUser.UserCode + "." + SenderUser.UserName;
                            }
                            list.Add(model);
                        }
                    }
                    args.PartnerOrderProducts = list;
                    #endregion

                    #region  OrderLog /OrderTask
                    if (flag != "true")
                    {
                        OrderStep    step = p.Client.GetOrderStepByStepCode(SenderUser, StepCode.partneraddorder.ToString());
                        OrderStepLog ot   = new OrderStepLog();
                        ot.StepID         = Guid.NewGuid();
                        ot.OrderID        = order.OrderID;
                        ot.StepNo         = step.StepNo;
                        ot.StepName       = step.StepName;
                        ot.Remark         = string.Empty;
                        args.OrderStepLog = ot;
                    }
                    #endregion

                    p.Client.SavePartnerOrder(SenderUser, args);
                }
                WriteSuccess();
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
Пример #5
0
        public void SavePartnerOrder(Sender sender, SavePartnerOrderArgs args)
        {
            try
            {
                using (ObjectProxy op = new ObjectProxy(true))
                {
                    PartnerOrder obj = new PartnerOrder();
                    obj.OrderID = args.Order.OrderID;

                    List <Category> Categorys = op.LoadCategorysByParentID(ORDERTYPECATEGORORYID);


                    if (op.LoadPartnerOrder(obj) == 0)
                    {
                        string ordertypeCode = Categorys.Where(t => t.CategoryName == args.Order.OrderType).FirstOrDefault().CategoryCode;
                        string key           = ordertypeCode + "P" + DateTime.Now.ToString("yy");

                        int index = this.GetIncrease(sender, key);
                        args.Order.OrderNo = key + DateTime.Now.Month.ToString("00") + index.ToString("00000");

                        args.Order.Created    = DateTime.Now;
                        args.Order.CreatedBy  = sender.UserCode + "." + sender.UserName;
                        args.Order.Modified   = DateTime.Now;
                        args.Order.ModifiedBy = sender.UserCode + "." + sender.UserName;
                        op.InsertPartnerOrder(args.Order);
                    }
                    else
                    {
                        args.Order.Modified   = DateTime.Now;
                        args.Order.ModifiedBy = sender.UserCode + "." + sender.UserName;
                        op.UpdatePartnerOrderByOrderID(args.Order);
                    }



                    #region 订单产品
                    if (args.PartnerOrderProducts != null)
                    {
                        for (int i = 0; i < args.PartnerOrderProducts.Count; i++)
                        {
                            var model = args.PartnerOrderProducts[i];
                            PartnerOrderProduct subObj = new PartnerOrderProduct();
                            subObj.ProductID = model.ProductID;
                            if (op.LoadPartnerOrderProduct(subObj) == 0)
                            {
                                if (string.IsNullOrEmpty(model.ProductCode) || model.ProductCode.Length <= 1)
                                {
                                    //subObj.CabinetCode = args.Order.OrderNo + (char)(64 + order2Cabinet.Sequence);
                                    model.ProductCode = string.Format("{0}-{1}-{2}", args.Order.OrderNo, args.PartnerOrderProducts.Count, i + 1);
                                }
                                model.Created    = DateTime.Now;
                                model.CreatedBy  = sender.UserCode + "." + sender.UserName;
                                model.Modified   = DateTime.Now;
                                model.ModifiedBy = sender.UserCode + "." + sender.UserName;
                                op.InsertPartnerOrderProduct(model);
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(model.ProductCode) || model.ProductCode.Length <= 1)
                                {
                                    //order2Cabinet.CabinetCode = args.Order.OrderNo + (char)(64 + order2Cabinet.Sequence);
                                    model.ProductCode = string.Format("{0}-{1}-{2}", args.Order.OrderNo, args.PartnerOrderProducts.Count, i + 1);
                                }
                                model.Modified   = DateTime.Now;
                                model.ModifiedBy = sender.UserCode + "." + sender.UserName;
                                op.UpdatePartnerOrderProductByProductID(model);
                            }
                        }
                    }
                    #endregion

                    #region 订单步骤
                    if (args.OrderStepLog != null)
                    {
                        args.OrderStepLog.Started   = DateTime.Now;
                        args.OrderStepLog.StartedBy = sender.UserCode + "." + sender.UserName;
                        op.InsertOrderStepLog(args.OrderStepLog);
                    }
                    #endregion

                    op.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }