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;
            }
        }
Example #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.ProfilesSave, false))
            {
                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;
            }
            if (ddlProfileComplexity.SelectedValue == Constants.INVALID_ID_STRING)
            {
                AddErrorMessage(this.lbResultContext, BaseHelper.GetCaptionString("Please_add_ProfileComplexity"));
                return;
            }

            this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            ProfileSetting profileSetting = new ProfileSetting();

            //редакция
            if (this.CurrentEntityMasterID != Constants.INVALID_ID_STRING && !string.IsNullOrEmpty(this.CurrentEntityMasterID))
            {
                profileSetting = this.ownerPage.CostCalculationRef.GetProfileSettingById(this.CurrentEntityMasterID);
                profileSetting.idModifyUser = Convert.ToInt32(this.ownerPage.UserProps.IdUser);
                profileSetting.dModify      = DateTime.Now;
            }
            //нов документ
            else
            {
                profileSetting.idCreateUser = Convert.ToInt32(this.ownerPage.UserProps.IdUser);
                profileSetting.dCreate      = DateTime.Now;
            }

            profileSetting.ProfileName         = this.tbxProfile.Text;
            profileSetting.ProfileNameSAP      = this.tbxProfileSAP.Text;
            profileSetting.idProfileType       = this.ddlProfileType.SelectedValueINT;
            profileSetting.idProfileCategory   = this.ddlProfileCategory.SelectedValueINT;
            profileSetting.idProfileComplexity = this.ddlProfileComplexity.SelectedValueINT;
            profileSetting.DiameterFormula     = this.tbxDiameterFormula.Text;

            foreach (ListItem listItem in chBxValue.Items)
            {
                if (listItem.Text.StartsWith("A"))
                {
                    profileSetting.hasA = listItem.Selected;
                }
                else if (listItem.Text.StartsWith("B"))
                {
                    profileSetting.hasB = listItem.Selected;
                }
                else if (listItem.Text.StartsWith("C"))
                {
                    profileSetting.hasC = listItem.Selected;
                }
                else if (listItem.Text.StartsWith("D"))
                {
                    profileSetting.hasD = listItem.Selected;
                }
                else if (listItem.Text.StartsWith("s"))
                {
                    profileSetting.hasS = listItem.Selected;
                }
            }

            this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.ProfileSettingSave(profileSetting, this.ownerPage.CallContext);

            if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {
                this.CurrentEntityMasterID = profileSetting.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");

                try
                {
                    eval.EvalExpression(this.tbxDiameterFormula.Text, vals).ToString();
                }
                catch (Exception ex)
                {
                    this.ownerPage.ShowMSG(ex.Message.Replace("'", "\""));
                }
            }



            CheckIfResultIsSuccess(this.lbResultContext);
            lbResultContext.Text = this.ownerPage.CallContext.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;
        }