public MainWindow(User user) { InitializeComponent(); MainWindow.user = user; userName.Text = MainWindow.user.username; if (MainWindow.user.admin) { userPermissions.Text = "Administrator"; } else { userPermissions.Text = "User"; } m_dashboard = new Dashboard(); m_invoice = new InvoiceMain(); m_receipt = new ReceiptMain(); m_creditNote = new CreditNoteMain(); m_statement = new StatementMain(this); m_product = new ProductMain(); m_customer = new CustomerMain(); m_quote = new QuoteMain(); m_expenses = new ExpensesMain(); m_settings = new SettingsMain(); m_order = new OrderMain(this); BtnDashboard_Click(null, null); }
public void GetQuoteMainBySolutionID() { try { if (string.IsNullOrEmpty(Request["SolutionID"])) { throw new Exception("无效的参数"); } using (ProxyBE p = new ProxyBE()) { QuoteMain quote = p.Client.GetQuoteMainBySolutionID(SenderUser, Guid.Parse(Request["SolutionID"])); Response.Write(JSONHelper.Object2Json(quote)); } } catch (Exception ex) { PLogger.LogError(ex); WriteError(ex.Message, ex); } }
public QuoteMain GetQuoteMainByQuoteNo(Sender sender, string QuoteNo) { try { using (ObjectProxy op = new ObjectProxy()) { QuoteMain obj = new QuoteMain(); obj.QuoteNo = QuoteNo; if (op.LoadQuoteMainByQuoteNo(obj) == 0) { return(null); } return(obj); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
public QuoteMain GetQuoteMainBySolutionID(Sender sender, Guid SolutionID) { try { using (ObjectProxy op = new ObjectProxy()) { QuoteMain obj = new QuoteMain(); obj.SolutionID = SolutionID; if (op.LoadQuoteMainBySolutionID(obj) == 0) { return(null); } return(obj); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
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; } }
public void GetQutoMain() { try { if (string.IsNullOrEmpty(Request["QuoteID"])) { throw new Exception("报价单:调用参数无效。"); } Guid QuoteID = new Guid(Request["QuoteID"].ToString()); using (ProxyBE p = new ProxyBE()) { QuoteMain quoteMain = p.Client.GetQuoteMain(SenderUser, QuoteID); if (quoteMain != null) { Response.Write(JSONHelper.Object2JSON(quoteMain)); } } } catch (Exception ex) { PLogger.LogError(ex); WriteError(ex.Message); } }
public void SavePartnerTask(Sender sender, SavePartnerTaskArgs args) { try { using (ObjectProxy op = new ObjectProxy(true)) { PartnerTask ta = new PartnerTask(); ta.TaskID = args.PartnerTask.TaskID; if (op.LoadPartnerTaskByTaskID(ta) == 0) { #region 新任务 args.PartnerTask.TaskNo = ""; //设置任务编号 PartnerTaskStep ts = new PartnerTaskStep(); ts.StepID = Guid.NewGuid(); ts.TaskID = args.PartnerTask.TaskID; ts.StepNo = 1; ts.StepName = args.CurrentStep; ts.Action = args.Action; ts.TargetStep = args.NextStep; ts.Started = DateTime.Now; ts.StartedBy = sender.UserCode + "." + sender.UserName; ts.Ended = ts.Started; ts.EndedBy = ts.StartedBy; ts.Remark = args.ActionRemarks; ts.RemarkType = args.ActionRemarksType; args.PartnerTask.StepNo = ts.StepNo + 1; args.PartnerTask.StepName = ts.TargetStep; args.PartnerTask.Created = ts.Started; args.PartnerTask.CreatedBy = ts.StartedBy; args.PartnerTask.Modified = ts.Ended; args.PartnerTask.ModifiedBy = ts.EndedBy; op.InsertPartnerTask(args.PartnerTask); op.InsertPartnerTaskStep(ts); if (!string.IsNullOrEmpty(args.NextResource)) { PartnerTaskResource newTR = new PartnerTaskResource(); newTR.TaskID = ta.TaskID; newTR.Resource = args.NextResource; newTR.Request = ""; newTR.Started = args.PartnerTask.Modified; newTR.StartedBy = args.PartnerTask.ModifiedBy; op.InsertPartnerTaskResource(newTR); } #endregion } else { #region 审批步骤任务 PartnerTaskResource tr = new PartnerTaskResource(); tr.TaskID = args.PartnerTask.TaskID; tr.Resource = args.Resource; if (op.LoadPartnerTaskResourceByTaskID(tr) == 0) { throw new Exception(string.Format("任务资源不存在.TaskID:{0}, Resource:{1}", args.PartnerTask.TaskID, args.Resource)); } PartnerTaskStep ts = new PartnerTaskStep(); ts.StepID = Guid.NewGuid(); ts.TaskID = ta.TaskID; ts.StepNo = ta.StepNo; ts.StepName = ta.StepName; ts.Action = args.Action; if (string.IsNullOrEmpty(args.NextStep)) { ts.TargetStep = ta.StepName; } else { ts.TargetStep = args.NextStep; } ts.Started = tr.Started; ts.StartedBy = tr.StartedBy; ts.Ended = DateTime.Now; ts.EndedBy = sender.UserCode + "." + sender.UserName; ts.Remark = args.ActionRemarks; ts.RemarkType = args.ActionRemarksType; args.PartnerTask.StepNo = ts.StepNo + 1; args.PartnerTask.StepName = ts.TargetStep; args.PartnerTask.Modified = ts.Ended; args.PartnerTask.ModifiedBy = ts.EndedBy; op.UpdatePartnerTaskByTaskID(args.PartnerTask); op.InsertPartnerTaskStep(ts); if (string.IsNullOrEmpty(args.NextStep)) { op.DeletePartnerTaskResourceByTaskID(tr.TaskID); } else { op.DeletePartnerTaskResourcesByTaskID(tr.TaskID); if (!string.IsNullOrEmpty(args.NextResource)) { PartnerTaskResource newTR = new PartnerTaskResource(); newTR.TaskID = ta.TaskID; newTR.Resource = args.NextResource; newTR.Request = ""; newTR.Started = ta.Modified; newTR.StartedBy = ta.ModifiedBy; op.InsertPartnerTaskResource(newTR); } } #endregion } #region 量尺 if (args.RoomDesigner != null) { RoomDesigner obj = new RoomDesigner(); obj.DesignerID = args.RoomDesigner.DesignerID; if (op.LoadRoomDesignerByDesignerID(obj) == 0) { args.RoomDesigner.Created = DateTime.Now; args.RoomDesigner.CreatedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); args.RoomDesigner.Modified = DateTime.Now; args.RoomDesigner.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); op.InsertRoomDesigner(args.RoomDesigner); } else { args.RoomDesigner.Modified = DateTime.Now; args.RoomDesigner.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); op.UpdateRoomDesignerByDesignerID(args.RoomDesigner); } } if (args.RoomDesignerFiles != null) { foreach (RoomDesignerFile file in args.RoomDesignerFiles) { RoomDesignerFile temp = new RoomDesignerFile(); temp.FileID = file.FileID; if (op.LoadRoomDesignerFileByFileID(temp) == 0) { file.Created = DateTime.Now; file.CreatedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); file.Modified = DateTime.Now; file.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); op.InsertRoomDesignerFile(file); } else { file.Modified = DateTime.Now; file.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); op.UpdateRoomDesignerFileByFileID(file); } } } #endregion #region 方案 if (args.Solution != null) { Solution obj = new Solution(); obj.SolutionID = args.Solution.SolutionID; if (op.LoadSolutionBySolutionID(obj) == 0) { args.Solution.Created = DateTime.Now; args.Solution.CreatedBy = sender.UserCode + "." + sender.UserName; args.Solution.Modified = DateTime.Now; args.Solution.ModifiedBy = sender.UserCode + "." + sender.UserName; op.InsertSolution(args.Solution); } else { args.Solution.Modified = DateTime.Now; args.Solution.ModifiedBy = sender.UserCode + "." + sender.UserName; op.UpdateSolutionBySolutionID(args.Solution); } } if (args.SolutionFiles != null) { foreach (SolutionFile file in args.SolutionFiles) { SolutionFile obj = new SolutionFile(); obj.FileID = file.FileID; if (op.LoadSolutionFileByFileID(obj) == 0) { file.Created = DateTime.Now; file.CreatedBy = sender.UserCode + "." + sender.UserName; file.Modified = DateTime.Now; file.ModifiedBy = sender.UserCode + "." + sender.UserName; op.InsertSolutionFile(file); } else { file.Modified = DateTime.Now; file.ModifiedBy = sender.UserCode + "." + sender.UserName; op.UpdateSolutionFileByFileID(file); } } } #endregion #region 方案报价 if (args.QuoteMain != null) { QuoteMain main = new QuoteMain(); main.QuoteID = args.QuoteMain.QuoteID; if (op.LoadQuoteMainByQuoteID(main) == 0) { op.InsertQuoteMain(args.QuoteMain); } else { op.UpdateQuoteMainByQuoteID(args.QuoteMain); } } if (args.QuoteDetails != null) { op.DeleteQuoteDetailsByQuoteID(args.QuoteMain.QuoteID); foreach (QuoteDetail item in args.QuoteDetails) { op.InsertQuoteDetail(item); } } #endregion op.CommitTransaction(); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
decimal quoteCompute(QuoteMain quoteMain, WaybillGoods goods) { decimal result = 0; List<QuoteExpression> lstQuoteExpression = FrequentlyUsedData.GetQuoteExpressionList(false).Where(obj => obj.SrcID == quoteMain.Guid).ToList(); if (goods.RealWeight != 0 && lstQuoteExpression.Count > 0) { result = CommonHelper.ComputeQuoteByExpression(goods.RealWeight, lstQuoteExpression); } return result; }
/// <summary> /// 保存 /// </summary> private void btnSave_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (validationProvider.Validate()) { #region 检验 if (lstSite.Count == 0) { ControlsHelper.ShowWarningMessage("保存失败", "请添加寄件站点"); return; } if (lstDestination.Count == 0) { ControlsHelper.ShowWarningMessage("保存失败", "请添加派件区域"); return; } try { decimal result = CheckExpression(88.88M); } catch (Exception ex) { ControlsHelper.ShowErrorMessage("保存失败", ex.Message); return; } #endregion //保存 if (quoteMain == null) { quoteMain = new QuoteMain(); quoteMain.CreateUser = Identity.CurrentUser.UserName; quoteMain.CreateDate = DateTime.Now; quoteMain.Guid = Guid; quoteMain.Valid = true; } quoteMain.Name = txtName.Text.Trim(); quoteMain.FeeType = cbxFeeType.Text; quoteMain.LogisticsType = cbxLogisticsType.Text; quoteMain.DispatchType = cbxDispatchType.Text; #region 寄件站点、收件站点、客户 List<QuoteMainRelation> quoteRelation = new List<QuoteMainRelation>(); foreach (CoSite site in lstSite) { QuoteMainRelation r = new QuoteMainRelation(); r.SrcID = Guid; r.Code = site.ID; r.Type = "寄件站点"; quoteRelation.Add(r); } foreach (CoDestination destination in lstDestination) { QuoteMainRelation r = new QuoteMainRelation(); r.SrcID = Guid; r.Code = destination.ID.ToString(); r.Type = "派件区域"; quoteRelation.Add(r); } foreach (CoCustomers customers in lstCustomers) { QuoteMainRelation r = new QuoteMainRelation(); r.SrcID = Guid; r.Code = customers.ID.ToString(); r.Type = "报价客户"; quoteRelation.Add(r); } #endregion #region 条件表达式 List<QuoteExpression> quoteExpressions = new List<QuoteExpression>(); foreach (QuoteExpression expression in lstQuoteExpression) { QuoteExpression obj = new QuoteExpression(); obj.Guid = System.Guid.NewGuid().ToString(); obj.SrcID = Guid; obj.SortID = expression.SortID; obj.Condition = expression.Condition; obj.Expression = expression.Expression; quoteExpressions.Add(obj); } #endregion if (EditType == "修改") WcfServiceHelper.Client.UpdateQuoteMain(quoteMain, quoteRelation.ToArray(), quoteExpressions.ToArray()); else WcfServiceHelper.Client.InsertQuoteMain(quoteMain, quoteRelation.ToArray(), quoteExpressions.ToArray()); DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } } catch (Exception ex) { ControlsHelper.ShowErrorMessage("保存失败", ex.Message); } finally { this.Cursor = Cursors.Default; } }
private void InitControls() { if (EditType == "修改") { quoteMain = WcfServiceHelper.Client.GetQuoteMain(Guid); if (quoteMain == null) { ControlsHelper.ShowErrorMessage("修改失败", "该报价不存在"); this.Close(); } txtName.Text = quoteMain.Name; cbxLogisticsType.Text = quoteMain.LogisticsType; cbxDispatchType.Text = quoteMain.DispatchType; cbxFeeType.Text = quoteMain.FeeType; List<QuoteMainRelation> quoteRelation = WcfServiceHelper.Client.GetQuoteMainRelationByID(Guid).ToList(); //客户 List<string> lstCustomersCode = quoteRelation.FindAll(obj => obj.Type == "报价客户").ConvertAll<string>(obj => obj.Code); lstCustomers = FrequentlyUsedData.GetCustomersList(false).FindAll(obj => lstCustomersCode.Contains(obj.ID.ToString())); lsbCustomers.DataSource = lstCustomers; //寄件站点 List<string> lstSiteCode = quoteRelation.FindAll(obj => obj.Type == "寄件站点").ConvertAll<string>(obj => obj.Code); lstSite = FrequentlyUsedData.GetSiteList(false).FindAll(obj => lstSiteCode.Contains(obj.ID.ToString())); lsbSite.DataSource = lstSite; //派送区域 List<string> lstDestinationCode = quoteRelation.FindAll(obj => obj.Type == "派件区域").ConvertAll<string>(obj => obj.Code); lstDestination = FrequentlyUsedData.GetDestinationList(false).FindAll(obj => lstDestinationCode.Contains(obj.ID.ToString())); lsbDestination.DataSource = lstDestination; //报价公式 lstQuoteExpression = new BindingList<QuoteExpression>(WcfServiceHelper.Client.GetQuoteExpressionByID(Guid).OrderBy(obj => obj.SortID).ToList()); gridData.DataSource = lstQuoteExpression; } }
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); } }