Example #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            EvaluateExpressionHelper eval = new EvaluateExpressionHelper();

            Dictionary<string, string> vals = new Dictionary<string, string>();


           

            if (!string.IsNullOrEmpty( this.tbxKey1.Text) )
                vals.Add(this.tbxKey1.Text, tbxValue1.Text);

            if (!string.IsNullOrEmpty(this.tbxKey2.Text))
                vals.Add(this.tbxKey2.Text, tbxValue2.Text);
            if (!string.IsNullOrEmpty(this.tbxKey3.Text))
                vals.Add(this.tbxKey3.Text, tbxValue3.Text);
            if (!string.IsNullOrEmpty(this.tbxKey4.Text))
                vals.Add(this.tbxKey4.Text, tbxValue4.Text);
            try
            {
                this.tbxResult.Text = eval.EvalExpression(this.tbxExpr.Text, vals).ToString();
                this.lbError.Text = string.Empty;
            }
            catch(Exception ex)
            {
                this.lbError.Text = ex.Message;
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.DieFormulaSave, false))
            {
                return;
            }

            if (ddlNumberCavities.SelectedValue == Constants.INVALID_ID_STRING)
            {
                AddErrorMessage(this.lbResultContext, BaseHelper.GetCaptionString("Please_add_NumberCavities"));
                return;
            }
            if (ddlProfileCategory.SelectedValue == Constants.INVALID_ID_STRING)
            {
                AddErrorMessage(this.lbResultContext, BaseHelper.GetCaptionString("Please_add_ProfileCategory"));
                return;
            }
            if (ddlProfileType.SelectedValue == Constants.INVALID_ID_STRING)
            {
                AddErrorMessage(this.lbResultContext, BaseHelper.GetCaptionString("Please_add_ProfileType"));
                return;
            }

            this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;

            DieFormula dieFormula = new DieFormula();

            //редакция
            if (this.CurrentEntityMasterID != Constants.INVALID_ID_STRING && !string.IsNullOrEmpty(this.CurrentEntityMasterID))
            {
                dieFormula = this.ownerPage.CostCalculationRef.GetDieFormulaById(this.CurrentEntityMasterID);

                dieFormula.idModifyUser     = Convert.ToInt32(this.ownerPage.UserProps.IdUser);
                dieFormula.dModify          = DateTime.Now;
            }
            //нов документ
            else
            {
                dieFormula.idCreateUser     = Convert.ToInt32(this.ownerPage.UserProps.IdUser);
                dieFormula.dCreate          = DateTime.Now;
            }

            dieFormula.idNumberOfCavities   = this.ddlNumberCavities.SelectedValueINT;
            dieFormula.idProfileType        = this.ddlProfileType.SelectedValueINT;
            dieFormula.idProfileCategory    = this.ddlProfileCategory.SelectedValueINT;
            dieFormula.DieFormulaText       = this.tbxDieFormulaText.Text;
            
            this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.DieFormulaSave(dieFormula, this.ownerPage.CallContext);

            if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {
                this.CurrentEntityMasterID = dieFormula.EntityID.ToString();

                UserControlLoad();

                RefreshParent();

                EvaluateExpressionHelper eval   = new EvaluateExpressionHelper();
                Dictionary<string, string> vals = new Dictionary<string, string>();

                vals.Add("A", "100");
                vals.Add("B", "100");
                vals.Add("C", "100");
                vals.Add("D", "100");
                vals.Add("s", "4");
                vals.Add("Ø", "4");

                try
                {
                    eval.EvalExpression(this.tbxDieFormulaText.Text, vals).ToString();

                }
                catch (Exception ex)
                {
                    this.ownerPage.ShowMSG(ex.Message.Replace("'", "\""));
                }
            }

            CheckIfResultIsSuccess(this.lbResultContext);
            lbResultContext.Text = this.ownerPage.CallContext.Message;
        }