예제 #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
        protected void grdConditions_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                int conditionId = 0; conditionId = int.Parse(((DropDownList)e.Row.FindControl("ddlName")).SelectedValue);
                DropDownList ddlOperator = ((DropDownList)e.Row.FindControl("ddlOperator"));

                if (conditionId > 0)
                {
                    DropDownList ddlConditionNumber = ((DropDownList)e.Row.FindControl("ddlConditionNumber"));

                    WorkViewTDS dataSet = new WorkViewTDS();
                    dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true);
                    WorkViewConditionNew model = new WorkViewConditionNew(dataSet);
                    int conditionNumber = model.GetNewConditionNumber();

                    ddlConditionNumber.SelectedValue = conditionNumber.ToString();

                    WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway();
                    workTypeViewConditionGateway.LoadByWorkTypeConditionId(hdfWorkType.Value, conditionId, int.Parse(hdfCompanyId.Value));
                    string type = workTypeViewConditionGateway.GetType(hdfWorkType.Value, int.Parse(hdfCompanyId.Value), conditionId);

                    if (ddlOperator.SelectedItem == null)
                    {
                        WorkTypeViewOperatorList workTypeViewOperatorList = new WorkTypeViewOperatorList(new DataSet());
                        workTypeViewOperatorList.LoadAndAddItem(type, Int32.Parse(hdfCompanyId.Value));
                        ddlOperator.DataSource = workTypeViewOperatorList.Table;
                        ddlOperator.DataValueField = "Sign";
                        ddlOperator.DataTextField = "Operator";
                        ddlOperator.DataBind();
                        ddlOperator.SelectedIndex = 0;
                    }

                    if ((type == "String") || (type == "Date") || (type == "Int") || (type == "Decimal") || (type == "Distance"))
                    {
                        ddlOperator.Enabled = true;

                        TextBox tbxValue = ((TextBox)e.Row.FindControl("tbxValue"));
                        tbxValue.Visible = true;

                        DropDownList ddlValue = ((DropDownList)e.Row.FindControl("ddlValue"));
                        ddlValue.Visible = false;

                        RadioButton rbtnYes = ((RadioButton)e.Row.FindControl("rbtnYes"));
                        rbtnYes.Visible = false;

                        RadioButton rbtnNo = ((RadioButton)e.Row.FindControl("rbtnNo"));
                        rbtnNo.Visible = false;
                    }

                    if ((type == "FixedItems") || (type == "DynamicItems") || (type == "Boolean"))
                    {
                        ddlOperator.Enabled = false;

                        if (type == "FixedItems")
                        {
                            DropDownList ddlValue = ((DropDownList)e.Row.FindControl("ddlValue"));
                            ddlValue.Visible = true;

                            TextBox tbxValue = ((TextBox)e.Row.FindControl("tbxValue"));
                            tbxValue.Visible = false;

                            RadioButton rbtnYes = ((RadioButton)e.Row.FindControl("rbtnYes"));
                            rbtnYes.Visible = false;

                            RadioButton rbtnNo = ((RadioButton)e.Row.FindControl("rbtnNo"));
                            rbtnNo.Visible = false;
                        }

                        if (type == "DynamicItems")
                        {
                            DropDownList ddlValue = ((DropDownList)e.Row.FindControl("ddlValue"));
                            ddlValue.Visible = true;

                            TextBox tbxValue = ((TextBox)e.Row.FindControl("tbxValue"));
                            tbxValue.Visible = false;

                            RadioButton rbtnYes = ((RadioButton)e.Row.FindControl("rbtnYes"));
                            rbtnYes.Visible = false;

                            RadioButton rbtnNo = ((RadioButton)e.Row.FindControl("rbtnNo"));
                            rbtnNo.Visible = false;
                        }

                        if (type == "Boolean")
                        {
                            DropDownList ddlValue = ((DropDownList)e.Row.FindControl("ddlValue"));
                            ddlValue.Visible = false;

                            TextBox tbxValue = ((TextBox)e.Row.FindControl("tbxValue"));
                            tbxValue.Visible = false;

                            RadioButton rbtnYes = ((RadioButton)e.Row.FindControl("rbtnYes"));
                            rbtnYes.Visible = true;

                            RadioButton rbtnNo = ((RadioButton)e.Row.FindControl("rbtnNo"));
                            rbtnNo.Visible = true;
                        }
                    }
                }
            }

            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                WorkViewTDS dataSet = new WorkViewTDS();
                dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true);
                WorkViewConditionNewGateway gateway = new WorkViewConditionNewGateway(dataSet);
                int id = int.Parse(((Label)e.Row.FindControl("lblId")).Text);

                int conditionId = gateway.GetConditionId(id);
                DropDownList ddlName = ((DropDownList)e.Row.FindControl("ddlName"));
                DropDownList ddlOperator = ((DropDownList)e.Row.FindControl("ddlOperator"));

                if (conditionId > 0)
                {
                    WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway();
                    workTypeViewConditionGateway.LoadByWorkTypeConditionId(hdfWorkType.Value, conditionId, int.Parse(hdfCompanyId.Value));
                    string type = workTypeViewConditionGateway.GetType(hdfWorkType.Value, int.Parse(hdfCompanyId.Value), conditionId);

                    ddlName.DataBind();
                    ddlName.SelectedValue = conditionId.ToString();

                    WorkTypeViewOperatorList workTypeViewOperatorList = new WorkTypeViewOperatorList(new DataSet());
                    workTypeViewOperatorList.LoadAndAddItem(type, Int32.Parse(hdfCompanyId.Value));
                    ddlOperator.DataSource = workTypeViewOperatorList.Table;
                    ddlOperator.DataValueField = "Sign";
                    ddlOperator.DataTextField = "Operator";
                    ddlOperator.DataBind();
                    ddlOperator.SelectedValue = gateway.GetSign(id);

                    if ((type == "String") || (type == "Date") || (type == "Int") || (type == "Decimal") || (type == "Distance"))
                    {
                        ddlOperator.Enabled = true;

                        TextBox tbxValue = ((TextBox)e.Row.FindControl("tbxValue"));
                        tbxValue.Visible = true;
                        tbxValue.Text = gateway.GetValue_(id);

                        DropDownList ddlValue = ((DropDownList)e.Row.FindControl("ddlValue"));
                        ddlValue.Visible = false;

                        RadioButton rbtnYes = ((RadioButton)e.Row.FindControl("rbtnYes"));
                        rbtnYes.Visible = false;

                        RadioButton rbtnNo = ((RadioButton)e.Row.FindControl("rbtnNo"));
                        rbtnNo.Visible = false;
                    }

                    if ((type == "FixedItems") || (type == "DynamicItems") || (type == "Boolean"))
                    {
                        ddlOperator.Enabled = false;

                        if (type == "FixedItems")
                        {
                            DropDownList ddlValue = ((DropDownList)e.Row.FindControl("ddlValue"));
                            ddlValue.Visible = true;

                            // Prepare initial data
                            // ... For view type
                            WorkTypeViewConditionItemList workTypeViewConditionItemList = new WorkTypeViewConditionItemList(new DataSet());
                            workTypeViewConditionItemList.LoadAndAddItemInView(hdfWorkType.Value, Int32.Parse(hdfCompanyId.Value), conditionId);
                            ddlValue.DataSource = workTypeViewConditionItemList.Table;
                            ddlValue.DataValueField = "Name";
                            ddlValue.DataTextField = "Name";
                            ddlValue.DataBind();
                            ddlValue.SelectedValue = gateway.GetValue_(id);

                            TextBox tbxValue = ((TextBox)e.Row.FindControl("tbxValue"));
                            tbxValue.Visible = false;

                            RadioButton rbtnYes = ((RadioButton)e.Row.FindControl("rbtnYes"));
                            rbtnYes.Visible = false;

                            RadioButton rbtnNo = ((RadioButton)e.Row.FindControl("rbtnNo"));
                            rbtnNo.Visible = false;
                        }

                        if (type == "DynamicItems")
                        {
                            DropDownList ddlValue = ((DropDownList)e.Row.FindControl("ddlValue"));
                            ddlValue.Visible = true;

                            // Prepare initial data
                            // ... For view type
                            WorkTypeViewSubAreaList workTypeViewSubAreaList = new WorkTypeViewSubAreaList(new DataSet());
                            workTypeViewSubAreaList.LoadAndAddItem(hdfWorkType.Value, Int32.Parse(hdfCompanyId.Value), int.Parse(hdfProjectId.Value));
                            if (workTypeViewSubAreaList.Table.Rows.Count > 0)
                            {
                                ddlValue.DataSource = workTypeViewSubAreaList.Table;
                                ddlValue.DataValueField = "SubArea";
                                ddlValue.DataTextField = "SubArea";
                                ddlValue.DataBind();
                                ddlValue.SelectedValue = gateway.GetValue_(id);
                            }
                            else
                            {
                                ddlValue.Visible = false;
                            }

                            TextBox tbxValue = ((TextBox)e.Row.FindControl("tbxValue"));
                            tbxValue.Visible = false;

                            RadioButton rbtnYes = ((RadioButton)e.Row.FindControl("rbtnYes"));
                            rbtnYes.Visible = false;

                            RadioButton rbtnNo = ((RadioButton)e.Row.FindControl("rbtnNo"));
                            rbtnNo.Visible = false;
                        }

                        if (type == "Boolean")
                        {
                            DropDownList ddlValue = ((DropDownList)e.Row.FindControl("ddlValue"));
                            ddlValue.Visible = false;

                            TextBox tbxValue = ((TextBox)e.Row.FindControl("tbxValue"));
                            tbxValue.Visible = false;

                            RadioButton rbtnYes = ((RadioButton)e.Row.FindControl("rbtnYes"));
                            rbtnYes.Visible = true;

                            RadioButton rbtnNo = ((RadioButton)e.Row.FindControl("rbtnNo"));
                            rbtnNo.Visible = true;

                            if (gateway.GetValue_(id) == "Yes")
                            {
                                rbtnYes.Checked = true;
                            }
                            else
                            {
                                rbtnNo.Checked = true;
                            }
                        }
                    }
                }
            }
        }
예제 #3
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();
                }

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

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

                tbxLogic.Text = model.GetConditionsByDefault();

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

                // store tables
                Session.Remove("workViewConditionNewDummy");
                Session["workViewConditionNew"] = workViewConditionNew;
                hdfStep.Value = "StepConditions";

                return true;
            }
            else
            {
                return false;
            }
        }
예제 #4
0
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP6 - SUMMARY
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP6 - SUMMARY - METHODS
        //
        private void StepSummaryIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Summary";

            // Tag Page
            hdfStep.Value = "StepSummary";
            hdfUpdate.Value = "yes";

            // Initialize summary
            WorkView workView = new WorkView(workViewTDS);

            // process view
            WorkViewTDS dataset = new WorkViewTDS();
            dataset.WorkViewDisplayTemp.Merge(workViewDisplayTemp, true);
            dataset.WorkViewConditionNew.Merge(workViewConditionNew, true);
            dataset.WorkViewSortTemp.Merge(workViewSortTemp, true);

            WorkViewDisplayTemp modelWorkViewDisplayTemp = new WorkViewDisplayTemp(dataset);
            WorkViewConditionNew modelWorkViewConditionNew = new WorkViewConditionNew(dataset);
            WorkViewSortTemp modelWorkViewSortTemp = new WorkViewSortTemp(dataset);

            string summary = "";
            summary = summary + "Name: " + tbxName.Text + "\n\n";
            summary = summary + "Columns To Display; " + modelWorkViewDisplayTemp.GetColumnsToDisplay() + "\n\n";
            summary = summary + "Conditions: " + modelWorkViewConditionNew.GetConditionsForSummary(hdfWorkType.Value, int.Parse(hdfCompanyId.Value)) + "\n\n";
            summary = summary + "Logical Expression: " + tbxLogic.Text + "\n\n";
            summary = summary + "Order by: " + modelWorkViewSortTemp.GetSortForSummary() + "\n\n";

            tbxSummary.Text = summary;
        }
예제 #5
0
        private void GrdConditionsAdd()
        {
            if (ValidateFooterAdd())
            {
                Page.Validate("Conditions");
                if (Page.IsValid)
                {
                    int conditionId = int.Parse(((DropDownList)grdConditions.FooterRow.FindControl("ddlName")).SelectedValue);
                    string name = ((DropDownList)grdConditions.FooterRow.FindControl("ddlName")).SelectedItem.Text;
                    string operator_ = ((DropDownList)grdConditions.FooterRow.FindControl("ddlOperator")).SelectedItem.Text;
                    string sign = ((DropDownList)grdConditions.FooterRow.FindControl("ddlOperator")).SelectedValue;
                    int conditionNumber = int.Parse(((DropDownList)grdConditions.FooterRow.FindControl("ddlConditionNumber")).SelectedValue);

                    WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway();
                    workTypeViewConditionGateway.LoadByWorkTypeConditionId(hdfWorkType.Value, conditionId, int.Parse(hdfCompanyId.Value));
                    string type = workTypeViewConditionGateway.GetType(hdfWorkType.Value, int.Parse(hdfCompanyId.Value), conditionId);
                    string value = "";

                    if ((type == "String") || (type == "Date") || (type == "Int") || (type == "Decimal") || (type == "Distance"))
                    {
                        value = ((TextBox)grdConditions.FooterRow.FindControl("tbxValue")).Text;
                    }

                    if ((type == "FixedItems") || (type == "DynamicItems"))
                    {
                        value = ((DropDownList)grdConditions.FooterRow.FindControl("ddlValue")).SelectedItem.Text;
                    }

                    if (type == "Boolean")
                    {
                        if (((RadioButton)grdConditions.FooterRow.FindControl("rbtnYes")).Checked)
                            value = "Yes";
                        if (((RadioButton)grdConditions.FooterRow.FindControl("rbtnNo")).Checked)
                            value = "No";
                    }

                    WorkViewTDS dataSet = new WorkViewTDS();
                    dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true);
                    WorkViewConditionNew model = new WorkViewConditionNew(dataSet);
                    model.Insert(conditionId, name, operator_, sign, conditionNumber, value, false, false);

                    Session.Remove("workViewConditionNewDummy");
                    workViewConditionNew = dataSet.WorkViewConditionNew;
                    Session["workViewConditionNew"] = dataSet.WorkViewConditionNew;

                    grdConditions.DataBind();
                    grdConditions.PageIndex = grdConditions.PageCount - 1;
                }
            }
        }
예제 #6
0
        private void Save()
        {
            // process view
            WorkViewTDS dataset = new WorkViewTDS();
            dataset.WorkViewDisplayTemp.Merge(workViewDisplayTemp, true);
            dataset.WorkViewConditionNew.Merge(workViewConditionNew, true);
            dataset.WorkViewSortTemp.Merge(workViewSortTemp, true);

            WorkViewDisplayTemp modelWorkViewDisplayTemp = new WorkViewDisplayTemp(dataset);
            WorkViewConditionNew modelWorkViewConditionNew = new WorkViewConditionNew(dataset);
            WorkViewSortTemp modelWorkViewSortTemp = new WorkViewSortTemp(dataset);

            // get parameters
            int viewId = int.Parse(hdfViewId.Value);
            int companyId = int.Parse(hdfCompanyId.Value);
            int loginId = Convert.ToInt32(Session["loginID"]);
            string name = tbxName.Text;
            string type = ddlType.SelectedValue;
            string logic = tbxLogic.Text;
            string sqlCommand = GetSqlCommand();
            string workType = hdfWorkType.Value;

            if (!(Convert.ToBoolean(Session["sgLFS_VIEWS_ADD"])))
            {
                if ((string)Request.QueryString["fm_type"] == "Rehab Assessment")
                {
                    if (Convert.ToBoolean(Session["sgLFS_CWP_REHABASSESSMENT_VIEW"]))
                    {
                        type = "Personal";
                    }
                }

                if ((string)Request.QueryString["fm_type"] == "Full Length Lining")
                {
                    if (Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_VIEW"]))
                    {
                        type = "Personal";
                    }
                }

                if ((string)Request.QueryString["fm_type"] == "Junction Lining")
                {
                    if (Convert.ToBoolean(Session["sgLFS_CWP_JUNCTIONLINING_VIEW"]))
                    {
                        type = "Personal";
                    }
                }

                if ((string)Request.QueryString["fm_type"] == "Point Repairs")
                {
                    if (Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_VIEW"]))
                    {
                        type = "Personal";
                    }
                }

                if ((string)Request.QueryString["fm_type"] == "Manhole Repairs")
                {
                    if (Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_VIEW"]))
                    {
                        type = "Personal";
                    }
                }
            }

            // save to database
            DB.Open();
            DB.BeginTransaction();
            try
            {
                WorkView workView = new WorkView(null);
                workView.InsertDirect(viewId, loginId, name, type, logic, sqlCommand, workType, false, companyId);

                modelWorkViewDisplayTemp.Save();
                modelWorkViewConditionNew.Save(viewId, companyId, workType);
                modelWorkViewSortTemp.Save(viewId, workType, companyId);

                DB.CommitTransaction();
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }
예제 #7
0
        private string GetWhere()
        {
            // process view
            WorkViewTDS dataset = new WorkViewTDS();
            dataset.WorkViewConditionNew.Merge(workViewConditionNew, true);

            WorkViewConditionNew modelWorkViewConditionNew = new WorkViewConditionNew(dataset);

            string whereClause = "";
            whereClause = modelWorkViewConditionNew.ParserLogic(tbxLogic.Text, hdfWorkType.Value, int.Parse(hdfCompanyId.Value));

            return whereClause;
        }
예제 #8
0
        protected void grdConditions_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Page.Validate("ConditionsUpdate");
            if (Page.IsValid)
            {
                int id = (int)e.Keys["ID"];

                int conditionId = int.Parse(((DropDownList)grdConditions.Rows[e.RowIndex].Cells[3].FindControl("ddlName")).SelectedValue);
                string name = ((DropDownList)grdConditions.Rows[e.RowIndex].Cells[3].FindControl("ddlName")).SelectedItem.Text;
                DropDownList ddlOperator = ((DropDownList)grdConditions.Rows[grdConditions.EditIndex].FindControl("ddlOperator"));
                string operator_ = ddlOperator.SelectedItem.Text;
                string sign = ddlOperator.SelectedValue;
                int conditionNumber = int.Parse(((DropDownList)grdConditions.Rows[e.RowIndex].Cells[2].FindControl("ddlConditionNumber")).SelectedValue);

                WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway();
                workTypeViewConditionGateway.LoadByWorkTypeConditionId(hdfWorkType.Value, conditionId, int.Parse(hdfCompanyId.Value));
                string type = workTypeViewConditionGateway.GetType(hdfWorkType.Value, int.Parse(hdfCompanyId.Value), conditionId);
                string value = "";

                if ((type == "String") || (type == "Date") || (type == "Int") || (type == "Decimal") || (type == "Distance"))
                {
                    value = ((TextBox)grdConditions.Rows[e.RowIndex].Cells[5].FindControl("tbxValue")).Text;
                }

                if ((type == "FixedItems") || (type == "DynamicItems"))
                {
                    value = ((DropDownList)grdConditions.Rows[e.RowIndex].Cells[5].FindControl("ddlValue")).SelectedItem.Text;
                }

                if (type == "Boolean")
                {
                    if (((RadioButton)grdConditions.Rows[e.RowIndex].Cells[5].FindControl("rbtnYes")).Checked)
                        value = "Yes";
                    if (((RadioButton)grdConditions.Rows[e.RowIndex].Cells[5].FindControl("rbtnNo")).Checked)
                        value = "No";
                }

                WorkViewTDS dataSet = new WorkViewTDS();
                dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true);
                WorkViewConditionNew model = new WorkViewConditionNew(dataSet);

                model.Update(id, conditionId, name, operator_, sign, conditionNumber, value, false, false);
                Session["workViewConditionNew"] = dataSet.WorkViewConditionNew;
                workViewConditionNew = dataSet.WorkViewConditionNew;
            }
            else
            {
                e.Cancel = true;
            }
        }
예제 #9
0
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP3 - CONDITIONS
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP3 - CONDITIONS - EVENTS
        //
        protected void grdConditions_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // Conditions Gridview, if the gridview is edition mode
            if (grdConditions.EditIndex >= 0)
            {
                grdConditions.UpdateRow(grdConditions.EditIndex, true);
            }

            // Delete conditions
            int id = (int)e.Keys["ID"];

            WorkViewTDS dataSet = new WorkViewTDS();
            dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true);
            WorkViewConditionNew model = new WorkViewConditionNew(dataSet);

            model.Delete(id);
            Session["workViewConditionNew"] = dataSet.WorkViewConditionNew;
        }
예제 #10
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;
            }
        }
예제 #11
0
        private bool StepColumnsToDisplayNext()
        {
            ViewState["columnsToDisplayPageIndex"] = grdColumnsToDisplay.PageIndex;

            Page.Validate("ColumsToDisplay");

            if (Page.IsValid)
            {
                hdfStep.Value = "StepColumnsToDisplay";
                StepColumnsToDisplayProcessGrid();
                workViewDisplayTemp.Rows.Clear();

                // create dataset
                WorkViewTDS dataSet = new WorkViewTDS();
                dataSet.LFS_WORK_TYPE_VIEW_DISPLAY.Merge(workTypeViewDisplay, true);
                dataSet.WorkViewDisplayTemp.Merge(workViewDisplayTemp, true);

                // process
                WorkViewDisplayTemp model = new WorkViewDisplayTemp(dataSet);
                model.ProcessForEdit(int.Parse(hdfViewId.Value), hdfWorkType.Value, int.Parse(hdfCompanyId.Value));

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

                // store tables
                Session.Remove("workTypeViewDisplayDummy");
                Session["workTypeViewDisplay"] = workTypeViewDisplay;
                Session["workViewDisplayTemp"] = workViewDisplayTemp;

                // load conditions for next step
                dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true);
                dataSet.WorkViewConditionTemp.Merge(workViewConditionTemp, true);

                WorkViewConditionNew modelConditionNew = new WorkViewConditionNew(dataSet);
                modelConditionNew.LoadByViewIdCompanyIdWorkType(int.Parse(hdfViewId.Value), int.Parse(hdfCompanyId.Value), hdfWorkType.Value);

                // Store tables
                workViewConditionNew = (WorkViewTDS.WorkViewConditionNewDataTable)modelConditionNew.Table;
                Session["workViewConditionNew"] = workViewConditionNew;

                return true;
            }
            else
            {
                return false;
            }
        }