// ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_VIEW"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["client_id"] == null) || ((string)Request.QueryString["project_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in pr_navigator2.aspx");
                }

                // Tag Page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfCurrentProjectId.Value = Request.QueryString["project_id"].ToString();
                hdfCurrentClientId.Value = Request.QueryString["client_id"].ToString();
                hdfWorkType.Value = "Point Repairs";

                // Prepare initial data
                // ... For sortByList
                odsSortByList.DataBind();
                ddlSortBy.DataSourceID = "odsSortByList";
                ddlSortBy.DataValueField = "SortID";
                ddlSortBy.DataTextField = "Name";
                ddlSortBy.DataBind();

                // ... For
                odsViewForDisplayList.DataBind();
                ddlCondition1.DataSourceID = "odsViewForDisplayList";
                ddlCondition1.DataValueField = "ConditionID";
                ddlCondition1.DataTextField = "Name";
                ddlCondition1.DataBind();

                // ... For view ddl
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                string workType = hdfWorkType.Value;
                int loginId = Convert.ToInt32(Session["loginID"]);
                string viewTypeGlobal = "";
                string viewTypePersonal = "Personal";

                // Global Views check
                if (Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_VIEW"]))
                {
                    viewTypeGlobal = "Global";
                }

                WorkViewList workViewList = new WorkViewList();
                workViewList.LoadAndAddItem(workType, viewTypeGlobal, viewTypePersonal, loginId, companyId);
                ddlView.DataSource = workViewList.Table;
                ddlView.DataValueField = "ViewID";
                ddlView.DataTextField = "Name";
                ddlView.DataBind();
                ddlView.SelectedIndex = 1;

                WorkTypeViewSubAreaList workTypeViewSubAreaList = new WorkTypeViewSubAreaList();
                workTypeViewSubAreaList.LoadAndAddItem("Point Repairs", Int32.Parse(hdfCompanyId.Value), int.Parse(hdfCurrentProjectId.Value), "(All)");
                ddlSubArea.DataSource = workTypeViewSubAreaList.Table;
                ddlSubArea.DataValueField = "SubArea";
                ddlSubArea.DataTextField = "SubArea";
                ddlSubArea.DataBind();

                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());

                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // ... for project
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")";

                // If coming from
                // ... pr_navigator.aspx or pr_navigator2.aspx
                if ((Request.QueryString["source_page"] == "pr_navigator.aspx") || (Request.QueryString["source_page"] == "pr_navigator2.aspx"))
                {
                    RestoreNavigatorState();

                    prNavigatorTDS = (PrNavigatorTDS)Session["prNavigatorTDS"];
                }

                // ... pr_edit.aspx, pr_summary.aspx or pr_delete.aspx
                if ((Request.QueryString["source_page"] == "pr_edit.aspx") || (Request.QueryString["source_page"] == "pr_summary.aspx") || (Request.QueryString["source_page"] == "pr_delete.aspx"))
                {
                    RestoreNavigatorState();

                    if (Request.QueryString["update"] == "no")
                    {
                        prNavigatorTDS = (PrNavigatorTDS)Session["prNavigatorTDS"];
                    }
                    else
                    {
                        // ... Delete store data
                        Session.Contents.Remove("prNavigatorTDS");

                        // ... Search data with updates
                        if (hdfBtnOrigin.Value == "Search")
                        {
                            prNavigatorTDS = SubmitSearch();
                        }
                        else
                        {
                            if (hdfBtnOrigin.Value == "Go")
                            {
                                prNavigatorTDS = SubmitSearchForViews();
                            }
                        }

                        // ... store datasets
                        Session["prNavigatorTDS"] = prNavigatorTDS;
                    }
                }

                // ... pr_delete.aspx, pr_summary.aspx or pr_edit.aspx
                if ((Request.QueryString["source_page"] == "pr_delete.aspx") || (Request.QueryString["source_page"] == "pr_summary.aspx") || (Request.QueryString["source_page"] == "pr_edit.aspx"))
                {
                    if (prNavigatorTDS.PrNavigator.Rows.Count == 0)
                    {
                        string url = "./pr_navigator.aspx?source_page=pr_navigator2.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + "&work_type=" + hdfWorkType.Value + GetNavigatorState() + "&no_results=yes";
                        Response.Redirect(url);
                    }
                }

                // For the grid
                grdPrNavigator.DataSource = prNavigatorTDS.PrNavigator;
                grdPrNavigator.DataBind();

                //... for the total rows
                if (prNavigatorTDS.PrNavigator.Rows.Count > 0)
                {
                    lblTotalRows.Text = "Total Rows: " + prNavigatorTDS.PrNavigator.Rows.Count;
                    lblTotalRows.Visible = true;
                }
                else
                {
                    lblTotalRows.Visible = false;
                }
            }
            else
            {
                // Restore TDS
                prNavigatorTDS = (PrNavigatorTDS)Session["prNavigatorTDS"];

                // ... for the total rows
                if (prNavigatorTDS.PrNavigator.Rows.Count > 0)
                {
                    lblTotalRows.Text = "Total Rows: " + prNavigatorTDS.PrNavigator.Rows.Count;
                    lblTotalRows.Visible = true;
                }
                else
                {
                    lblTotalRows.Visible = false;
                }
            }
        }
        protected void btnViewDelete_Click(object sender, EventArgs e)
        {
            int viewId = Int32.Parse(ddlView.SelectedValue.Trim());
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            if (!Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_DELETE"]))
            {
                WorkViewGateway workViewGateway = new WorkViewGateway();
                workViewGateway.LoadByViewId(viewId, companyId);
                string viewType = workViewGateway.GetType(viewId);

                if (viewType == "Global")
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }
            }

            UpdateDatabaseForViews();

            // ... For view ddl
            string workType = hdfWorkType.Value;
            int loginId = Convert.ToInt32(Session["loginID"]);
            string viewTypeGlobal = "";
            string viewTypePersonal = "Personal";

            // Global Views check
            if (Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_VIEW"]))
            {
                viewTypeGlobal = "Global";
            }

            WorkViewList workViewList = new WorkViewList();
            workViewList.LoadAndAddItem(workType, viewTypeGlobal, viewTypePersonal, loginId, companyId);
            ddlView.DataSource = workViewList.Table;
            ddlView.DataValueField = "ViewID";
            ddlView.DataTextField = "Name";
            ddlView.DataBind();
            ddlView.SelectedIndex = 1;

            WorkTypeViewSubAreaList workTypeViewSubAreaList = new WorkTypeViewSubAreaList();
            workTypeViewSubAreaList.LoadAndAddItem("Point Repairs", Int32.Parse(hdfCompanyId.Value), int.Parse(hdfCurrentProjectId.Value), "(All)");
            ddlSubArea.DataSource = workTypeViewSubAreaList.Table;
            ddlSubArea.DataValueField = "SubArea";
            ddlSubArea.DataTextField = "SubArea";
            ddlSubArea.DataBind();
        }
Esempio n. 3
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;
                            }
                        }
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_JUNCTIONLINING_VIEW"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["client_id"] == null) || ((string)Request.QueryString["project_id"] == null) || ((string)Request.QueryString["work_type"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in jl_navigator.aspx");
                }

                // Tag Page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfCurrentProjectId.Value = Request.QueryString["project_id"].ToString();
                hdfCurrentClientId.Value = Request.QueryString["client_id"].ToString();
                hdfWorkType.Value = Request.QueryString["work_type"].ToString();

                // Prepare initial data
                // ... For sortByList
                odsSortByList.DataBind();
                ddlSortBy.DataSourceID = "odsSortByList";
                ddlSortBy.DataValueField = "SortID";
                ddlSortBy.DataTextField = "Name";
                ddlSortBy.DataBind();

                // ... For
                odsViewForDisplayList.DataBind();
                odsViewForDisplayList2.DataBind();

                // ... For view ddl
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                string workType = hdfWorkType.Value;
                int loginId = Convert.ToInt32(Session["loginID"]);
                string viewTypeGlobal = "";
                string viewTypePersonal = "Personal";

                // Global Views check
                if (Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_VIEW"]))
                {
                    viewTypeGlobal = "Global";
                }

                WorkViewList workViewList = new WorkViewList();
                workViewList.LoadAndAddItem(workType, viewTypeGlobal, viewTypePersonal, loginId, companyId);
                ddlView.DataSource = workViewList.Table;
                ddlView.DataValueField = "ViewID";
                ddlView.DataTextField = "Name";
                ddlView.DataBind();
                ddlView.SelectedIndex = 1;

                WorkTypeViewSubAreaList workTypeViewSubAreaList = new WorkTypeViewSubAreaList();
                workTypeViewSubAreaList.LoadAndAddItem("Junction Lining", Int32.Parse(hdfCompanyId.Value), int.Parse(hdfCurrentProjectId.Value), "(All)");
                ddlSubArea.DataSource = workTypeViewSubAreaList.Table;
                ddlSubArea.DataValueField = "SubArea";
                ddlSubArea.DataTextField = "SubArea";
                ddlSubArea.DataBind();

                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());

                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // ... for project
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")";

                // If coming from

                // ... Left Menu, select_project.aspx or Projects2.aspx
                if ((Request.QueryString["source_page"] == "lm") || (Request.QueryString["source_page"] == "select_project.aspx") || (Request.QueryString["source_page"] == "Projects2.aspx"))
                {
                    tdNoResults.Visible = false;
                }

                // ... jl_navigator2.aspx
                if (Request.QueryString["source_page"] == "jl_navigator2.aspx")
                {
                    RestoreNavigatorState();
                    if ((string)Request.QueryString["no_results"] == "yes")
                    {
                        tdNoResults.Visible = true;
                    }
                    else
                    {
                        tdNoResults.Visible = true;
                    }
                }
            }
        }
Esempio n. 5
0
        protected void ddlName_SelectedIndexChanged(object sender, EventArgs e)
        {
            Label lblValidateValue = ((Label)grdConditions.Rows[grdConditions.EditIndex].FindControl("lblValidateValue"));
            lblValidateValue.Visible = false;

            ImageButton ibtnAdd = ((ImageButton)grdConditions.Rows[grdConditions.EditIndex].FindControl("ibtnAccept"));
            ibtnAdd.Visible = true;

            DropDownList ddlName = ((DropDownList)grdConditions.Rows[grdConditions.EditIndex].FindControl("ddlName"));
            DropDownList ddlOperator = ((DropDownList)grdConditions.Rows[grdConditions.EditIndex].FindControl("ddlOperator"));

            WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway();
            workTypeViewConditionGateway.LoadByWorkTypeConditionId(hdfWorkType.Value, int.Parse(ddlName.SelectedValue), int.Parse(hdfCompanyId.Value));
            string type = workTypeViewConditionGateway.GetType(hdfWorkType.Value, int.Parse(hdfCompanyId.Value), int.Parse(ddlName.SelectedValue));
            int index = grdConditions.SelectedIndex;

            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)grdConditions.Rows[grdConditions.EditIndex].FindControl("tbxValue"));
                tbxValue.Visible = true;

                DropDownList ddlValue = ((DropDownList)grdConditions.Rows[grdConditions.EditIndex].FindControl("ddlValue"));
                ddlValue.Visible = false;

                RadioButton rbtnYes = ((RadioButton)grdConditions.Rows[grdConditions.EditIndex].FindControl("rbtnYes"));
                rbtnYes.Visible = false;

                RadioButton rbtnNo = ((RadioButton)grdConditions.Rows[grdConditions.EditIndex].FindControl("rbtnNo"));
                rbtnNo.Visible = false;
            }

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

                if (type == "FixedItems")
                {
                    DropDownList ddlValue = ((DropDownList)grdConditions.Rows[grdConditions.EditIndex].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), int.Parse(ddlName.SelectedValue));
                    ddlValue.DataSource = workTypeViewConditionItemList.Table;
                    ddlValue.DataValueField = "Name";
                    ddlValue.DataTextField = "Name";
                    ddlValue.DataBind();
                    ddlValue.SelectedIndex = 0;

                    TextBox tbxValue = ((TextBox)grdConditions.Rows[grdConditions.EditIndex].FindControl("tbxValue"));
                    tbxValue.Visible = false;

                    RadioButton rbtnYes = ((RadioButton)grdConditions.Rows[grdConditions.EditIndex].FindControl("rbtnYes"));
                    rbtnYes.Visible = false;

                    RadioButton rbtnNo = ((RadioButton)grdConditions.Rows[grdConditions.EditIndex].FindControl("rbtnNo"));
                    rbtnNo.Visible = false;
                }

                if (type == "DynamicItems")
                {
                    DropDownList ddlValue = ((DropDownList)grdConditions.Rows[grdConditions.EditIndex].FindControl("ddlValue"));

                    // Prepare initial data
                    // ... For view type
                    WorkTypeViewSubAreaList workTypeViewSubAreaList = new WorkTypeViewSubAreaList(new DataSet());
                    workTypeViewSubAreaList.LoadAndAddItem(hdfWorkType.Value, int.Parse(hdfCompanyId.Value), int.Parse(hdfProjectId.Value));
                    if (workTypeViewSubAreaList.Table.Rows.Count > 0)
                    {
                        ddlValue.Visible = true;
                        ddlValue.DataSource = workTypeViewSubAreaList.Table;
                        ddlValue.DataValueField = "SubArea";
                        ddlValue.DataTextField = "SubArea";
                        ddlValue.DataBind();
                        ddlValue.SelectedIndex = 0;

                        ibtnAdd.Visible = true;
                    }
                    else
                    {
                        ddlValue.Visible = false;
                        ibtnAdd.Visible = false;

                        lblValidateValue.Visible = true;
                    }

                    TextBox tbxValue = ((TextBox)grdConditions.Rows[grdConditions.EditIndex].FindControl("tbxValue"));
                    tbxValue.Visible = false;

                    RadioButton rbtnYes = ((RadioButton)grdConditions.Rows[grdConditions.EditIndex].FindControl("rbtnYes"));
                    rbtnYes.Visible = false;

                    RadioButton rbtnNo = ((RadioButton)grdConditions.Rows[grdConditions.EditIndex].FindControl("rbtnNo"));
                    rbtnNo.Visible = false;
                }

                if (type == "Boolean")
                {
                    DropDownList ddlValue = ((DropDownList)grdConditions.Rows[grdConditions.EditIndex].FindControl("ddlValue"));
                    ddlValue.Visible = false;

                    TextBox tbxValue = ((TextBox)grdConditions.Rows[grdConditions.EditIndex].FindControl("tbxValue"));
                    tbxValue.Visible = false;

                    RadioButton rbtnYes = ((RadioButton)grdConditions.Rows[grdConditions.EditIndex].FindControl("rbtnYes"));
                    rbtnYes.Visible = true;

                    RadioButton rbtnNo = ((RadioButton)grdConditions.Rows[grdConditions.EditIndex].FindControl("rbtnNo"));
                    rbtnNo.Visible = true;
                }
            }
        }