public void ModifyQuoteMainStatus()
 {
     try
     {
         if (string.IsNullOrEmpty(Request["Status"]) && string.IsNullOrEmpty(Request["QuoteID"]))
         {
             throw new Exception("方案明细:调用参数无效。");
         }
         Guid QuoteID = Guid.Parse(Request["QuoteID"].ToString());
         using (ProxyBE p = new ProxyBE())
         {
             var quoteMain = p.Client.GetQuoteMain(SenderUser, QuoteID);
             if (quoteMain != null)
             {
                 if (quoteMain.Status.Equals(Request["Status"].ToString(), StringComparison.CurrentCultureIgnoreCase))
                 {
                     throw new Exception("方案明细:状态重复,不可修改.");
                 }
                 quoteMain.Status = Convert.ToString(Request["Status"]);
                 SaveQuoteMainArgs args = new SaveQuoteMainArgs();
                 args.QuoteMain = quoteMain;
                 p.Client.SaveQuote(SenderUser, args);
                 WriteSuccess();
             }
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         WriteError(ex.Message);
     }
 }
Beispiel #2
0
 public void SaveQuote(Sender sender, SaveQuoteMainArgs args)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy(true))
         {
             QuoteMain obj = new QuoteMain();
             obj.QuoteID = args.QuoteMain.QuoteID;
             if (op.LoadQuoteMainByQuoteID(obj) == 0)
             {
                 args.QuoteMain.Created    = DateTime.Now;
                 args.QuoteMain.CreatedBy  = sender.UserCode + "." + sender.UserName;
                 args.QuoteMain.Modified   = DateTime.Now;
                 args.QuoteMain.ModifiedBy = sender.UserCode + "." + sender.UserName;
                 op.InsertQuoteMain(args.QuoteMain);
             }
             else
             {
                 args.QuoteMain.Modified   = DateTime.Now;
                 args.QuoteMain.ModifiedBy = sender.UserCode + "." + sender.UserName;
                 op.UpdateQuoteMainByQuoteID(args.QuoteMain);
             }
             if (args.QuoteDetails != null)
             {
                 op.DeleteQuoteDetailsByQuoteID(args.QuoteMain.QuoteID);
                 foreach (QuoteDetail item in args.QuoteDetails)
                 {
                     op.InsertQuoteDetail(item);
                 }
             }
             op.CommitTransaction();
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Beispiel #3
0
        public void SaveQuote()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    #region  报价单

                    if (string.IsNullOrEmpty(Request["ReferenceID"]))
                    {
                        throw new Exception("ReferenceID:参数无效!");
                    }
                    Solution solution = p.Client.GetSolutionByDesignerID(SenderUser, Guid.Parse(Request["ReferenceID"]));
                    if (solution == null)
                    {
                        throw new Exception("对象无效!");
                    }
                    if (string.IsNullOrEmpty(Request["TaskID"]))
                    {
                        throw new Exception("TaskID:参数无效!");
                    }
                    QuoteMain quotemain = p.Client.GetQuoteMain(SenderUser, parm.QuoteID);
                    if (quotemain == null)
                    {
                        quotemain            = new QuoteMain();
                        quotemain.QuoteID    = Guid.NewGuid();
                        quotemain.SolutionID = solution.SolutionID;
                        quotemain.Status     = "N"; //报价单状态,N:确认中,F:已确认,C:已取消
                    }
                    quotemain.PartnerID       = CurrentUser.PartnerID;
                    quotemain.CustomerID      = solution.CustomerID;
                    quotemain.QuoteNo         = GetNumber("YS");
                    quotemain.DiscountPercent = parm.DiscountPercent;
                    quotemain.ExpiryDate      = parm.ExpiryDate;
                    quotemain.Status          = "N";
                    quotemain.Remark          = parm.Remark;
                    SaveQuoteMainArgs args = new SaveQuoteMainArgs();

                    #endregion

                    #region 报价单详情
                    List <QuoteDetail> QuoteDetails    = new List <QuoteDetail>();
                    string             details         = Request["QuoteDetails"];
                    decimal            DiscountPercent = 1;
                    JsonData           sj          = JsonMapper.ToObject(details);
                    decimal            totalamount = 0;
                    if (sj.Count > 0)
                    {
                        //遍历对象元素,保存
                        int i = 1;
                        foreach (JsonData item in sj)
                        {
                            try
                            {
                                QuoteDetail detail = new QuoteDetail();
                                detail.DetailID = Guid.NewGuid();
                                detail.QuoteID  = quotemain.QuoteID;

                                detail.ItemGroup = item["ItemGroup"].ToString();
                                detail.ItemName  = item["ItemName"].ToString();
                                detail.ItemStyle = item["ItemStyle"].ToString();
                                try
                                {
                                    detail.Qty = Decimal.Parse(item["Qty"].ToString());
                                }
                                catch
                                {
                                    throw new PException("第{0}行的数量有误。", i);
                                }
                                try
                                {
                                    detail.Price = Decimal.Parse(item["Price"].ToString());
                                }
                                catch
                                {
                                    throw new PException("第{0}行的价格有误。", i);
                                }
                                detail.ItemRemark = item["ItemRemark"].ToString();
                                QuoteDetails.Add(detail);
                                totalamount += detail.Price * detail.Qty;
                                i++;
                            }
                            catch
                            {
                                throw new PException("第{0}行的数据有误。", i);
                            }
                        }
                    }
                    quotemain.TotalAmount    = totalamount;
                    quotemain.DiscountAmount = (DiscountPercent - quotemain.DiscountPercent) * quotemain.TotalAmount;
                    args.QuoteMain           = quotemain;
                    args.QuoteDetails        = QuoteDetails;
                    p.Client.SaveQuote(SenderUser, args);
                    #endregion

                    #region 修改方案状态
                    solution.Status = "F";//方案状态:N,待上传方案文件;P,待生成报价明细;Q,已报价;F,方案成交;C,已取消;

                    SaveSolutionArgs arg = new SaveSolutionArgs();
                    arg.Solution = solution;

                    p.Client.SaveSolution(SenderUser, arg);
                    #endregion

                    #region 任务流程
                    Database dbCheck = new Database("BE_PartnerTask_Proc", "UPSTEPNO4", 5, 0, Request["TaskID"], "待提交订单", "P");
                    int      rst     = dbCheck.ExecuteNoQuery();
                    if (rst == 0)
                    {
                        WriteError("失败!");
                    }

                    //PartnerTask task = p.Client.GetPartnerTask(SenderUser, Guid.Parse(Request["TaskID"]));
                    //if (task != null)
                    //{
                    //    SavePartnerTaskArgs taskArgs = new SavePartnerTaskArgs();
                    //    taskArgs.PartnerTask = task;
                    //    taskArgs.NextStep = "待提交订单";
                    //    taskArgs.Resource = "报价确认组";//当前处理组
                    //    taskArgs.NextResource = "报价确认组";//下一个组
                    //    taskArgs.ActionRemarksType = "";
                    //    taskArgs.ActionRemarks = "";
                    //    taskArgs.Action = "已出报价合同,待确认";
                    //    p.Client.SavePartnerTask(SenderUser, taskArgs);
                    //}
                    #endregion
                }
                WriteSuccess();
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }