Пример #1
0
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP4 - LOGIC
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP4 - LOGIC -  AUXILIAR EVENTS
        //
        protected void cvLogic_ServerValidate(object source, ServerValidateEventArgs args)
        {
            LogicValidator logicValidator = new LogicValidator();
            string message;

            ArrayList conditions = new ArrayList();

            // create dataset
            WorkViewTDS dataSet = new WorkViewTDS();
            dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true);

            // process new conditions
            WorkViewConditionNew model = new WorkViewConditionNew(dataSet);
            conditions = model.GetConditions();

            // get changes
            workViewConditionNew.Rows.Clear();
            workViewConditionNew.Merge(model.Table);

            // store tables
            Session["workViewConditionNew"] = workViewConditionNew;
            if (conditions.Count > 0)
            {
                bool bOk = logicValidator.Validate(tbxLogic.Text, conditions, out message);

                if (bOk)
                {
                    args.IsValid = true;
                }
                else
                {
                    args.IsValid = false;
                    cvLogic.ErrorMessage = message;
                }
            }
            else
            {
                if (tbxLogic.Text == "")
                {
                    args.IsValid = true;
                }
                else
                {
                    args.IsValid = false;
                    cvLogic.ErrorMessage = "There are no conditions, The logical expression must be empty";
                }
            }
        }
Пример #2
0
        private bool StepConditionsNext()
        {
            // Validate data
            bool validData = true;

            // Edit if there is data to save
            Page.Validate("ConditionsUpdate");
            if (!Page.IsValid) validData = false;

            if (validData)
            {
                // Conditions Gridview, if the gridview is edition mode
                if (grdConditions.EditIndex >= 0)
                {
                    grdConditions.UpdateRow(grdConditions.EditIndex, true);
                    grdConditions.DataBind();
                }
            }

            Page.Validate("ConditionsNext");
            if (!Page.IsValid) validData = false;

            if (validData)
            {
                // Add conditions if exists at footer
                if (ValidateFooterNext())
                {
                    GrdConditionsAdd();
                }

                WorkViewGateway workViewGateway = new WorkViewGateway();
                workViewGateway.LoadByViewId(int.Parse(hdfViewId.Value), int.Parse(hdfCompanyId.Value));

                workViewConditionTemp.Rows.Clear();

                // create dataset
                WorkViewTDS dataSet = new WorkViewTDS();
                dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true);
                dataSet.WorkViewConditionTemp.Merge(workViewConditionTemp, true);

                // process conditions
                WorkViewConditionTemp model = new WorkViewConditionTemp(dataSet);
                WorkViewConditionNew modelLogic = new WorkViewConditionNew(dataSet);

                string originalLogic = workViewGateway.GetLogic(int.Parse(hdfViewId.Value));
                string newLogic = modelLogic.GetConditionsByDefault();

                ArrayList aConditions = new ArrayList();
                aConditions = modelLogic.GetConditions();

                bool isConditionsUpdate = false;

                if (originalLogic.Trim() != newLogic.Trim())
                {
                    foreach (string conditionNumber in aConditions)
                    {
                        if (!originalLogic.Contains(conditionNumber))
                        {
                            isConditionsUpdate = true;
                        }
                    }

                    if (!isConditionsUpdate)
                    {

                        if (Session["conditionsUpdate"] != null)
                        {
                            if (Session["conditionsUpdate"].ToString() == "true")
                            {
                                isConditionsUpdate = true;
                            }
                        }
                    }
                }
                else
                {
                    tbxLogic.Text = originalLogic.Trim();
                }

                if (isConditionsUpdate)
                {
                    tbxLogic.Text = newLogic.Trim();
                }
                else
                {
                    tbxLogic.Text = originalLogic.Trim();
                }

                // get changes
                workViewConditionNew.Rows.Clear();
                workViewConditionNew.Merge(modelLogic.Table);
                workViewConditionTemp.Rows.Clear();
                workViewConditionTemp.Merge(model.Table);

                //// store tables
                Session.Remove("workViewConditionNewDummy");
                Session.Remove("workViewConditionTempDummy");
                Session["workViewConditionNew"] = workViewConditionNew;
                Session["workViewConditionTemp"] = workViewConditionTemp;

                Session["conditionsUpdate"] = null;

                return true;
            }
            else
            {
                return false;
            }
        }