コード例 #1
0
        public void GetAndEvaluateQuoteExpression()
        {
            QuoteExpression expression = QuoteExpression.Instance;

            Assert.IsNotNull(expression);

            Machine machine = new Machine();

            machine.Push(2);

            expression.Evaluate(machine);

            Assert.AreEqual(1, machine.StackCount);
            Assert.IsInstanceOfType(machine.Top(), typeof(Expression));
            ((Expression)machine.Pop()).Evaluate(machine);

            Assert.AreEqual(1, machine.StackCount);
            Assert.AreEqual(2, machine.Pop());
        }
コード例 #2
0
ファイル: FrmQuoteMainEdit.cs プロジェクト: hjqcan/LDL
        /// <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;
            }
        }
コード例 #3
0
ファイル: FrmQuoteMainEdit.cs プロジェクト: hjqcan/LDL
 private void controlNavigator_ButtonClick(object sender, NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == NavigatorButtonType.Append)
     {
         QuoteExpression expression = new QuoteExpression();
         int maxSortID = lstQuoteExpression.Max(obj => obj.SortID);
         expression.SortID = maxSortID + 1;
         lstQuoteExpression.Add(expression);
         e.Handled = true;
     }
 }