Пример #1
0
        // ////////////////////////////////////////////////////////////////////////
        // STEP3 - CONDITIONS - METHODS
        //
        public FmViewTDS.FmViewConditionNewDataTable GetConditionsNew()
        {
            fmViewConditionNew = (FmViewTDS.FmViewConditionNewDataTable)Session["fmViewConditionNewDummy"];
            if (fmViewConditionNew == null)
            {
                fmViewConditionNew = (FmViewTDS.FmViewConditionNewDataTable)Session["fmViewConditionNew"];
            }

            return fmViewConditionNew;
        }
Пример #2
0
        protected void AddConditionsNewEmptyFix(GridView grdView)
        {
            if (grdView.Rows.Count == 0)
            {
                FmViewTDS.FmViewConditionNewDataTable dt = new FmViewTDS.FmViewConditionNewDataTable();
                dt.AddFmViewConditionNewRow(-1, -1, "", -1, "", "", -1, "", false, false);
                Session["fmViewConditionNewDummy"] = dt;

                grdView.DataBind();
            }

            // Normally executes at all postbacks
            if (grdView.Rows.Count == 1)
            {
                FmViewTDS.FmViewConditionNewDataTable dt = (FmViewTDS.FmViewConditionNewDataTable)Session["fmViewConditionNewDummy"];
                if (dt != null)
                {
                    grdView.Rows[0].Visible = false;
                    grdView.Rows[0].Controls.Clear();
                }
            }
        }
Пример #3
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);

                    FmTypeViewConditionGateway fmTypeViewConditionGateway = new FmTypeViewConditionGateway();
                    fmTypeViewConditionGateway.LoadByFmTypeConditionId(hdfFmType.Value, int.Parse(hdfCompanyId.Value), conditionId);
                    string type = fmTypeViewConditionGateway.GetType(hdfFmType.Value, int.Parse(hdfCompanyId.Value), conditionId);
                    string value = "";

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

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

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

                    FmViewTDS dataSet = new FmViewTDS();
                    dataSet.FmViewConditionNew.Merge(fmViewConditionNew, true);
                    FmViewConditionNew model = new FmViewConditionNew(dataSet);

                    model.Insert(conditionId, name, operator_, sign, conditionNumber, value, false, false);

                    Session.Remove("fmViewConditionNewDummy");
                    fmViewConditionNew = dataSet.FmViewConditionNew;
                    Session["fmViewConditionNew"] = dataSet.FmViewConditionNew;

                    grdConditions.DataBind();
                    grdConditions.PageIndex = grdConditions.PageCount - 1;
                }
            }
        }
Пример #4
0
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

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

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

                    if ((string)Request.QueryString["fm_type"] == "Units")
                    {
                        if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_UNITS_VIEW"])))
                        {
                            Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                        }
                    }
                }

                // Tag page
                hdfFmType.Value = (string)Request.QueryString["fm_type"];
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfUpdate.Value = "no";

                ViewState["columnsToDisplayPageIndex"] = 0;
                ViewState["sortPageIndex"] = 0;

                Session.Remove("fmTypeViewDisplay");
                Session.Remove("fmTypeViewDisplayDummy");
                Session.Remove("fmTypeViewSort");
                Session.Remove("fmTypeViewSortDummy");
                Session.Remove("fmViewDisplayTemp");
                Session.Remove("fmViewSortTemp");
                Session.Remove("fmViewConditionNew");
                Session.Remove("fmViewConditionNewDummy");
                Session.Remove("categoriesTDSForAddView");

                FmViewGateway fmViewGateway = new FmViewGateway();
                hdfViewId.Value = (fmViewGateway.GetLastViewId() + 1).ToString().Trim();

                // Prepare initial data
                // ... For view type
                FmViewTypeList fmViewTypeList = new FmViewTypeList(new DataSet());
                fmViewTypeList.LoadAndAddItem("(Select a type)", Int32.Parse(hdfCompanyId.Value));
                ddlType.DataSource = fmViewTypeList.Table;
                ddlType.DataValueField = "Type";
                ddlType.DataTextField = "Type";
                ddlType.DataBind();
                ddlType.SelectedIndex = 0;

                // ... Global Views check
                if (!Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_ADD"]))
                {
                    ddlType.Items.Remove("Global");
                }

                // If coming from
                // ... services_navigator.aspx, services_navigator2.aspx, units_navigator.aspx or units_navigator2.aspx
                if ((Request.QueryString["source_page"] == "services_navigator.aspx") || (Request.QueryString["source_page"] == "services_navigator2.aspx") || (Request.QueryString["source_page"] == "units_navigator.aspx") || (Request.QueryString["source_page"] == "unit_navigator2.aspx"))
                {
                    // ... For Grids
                    fmViewTDS = new FmViewTDS();

                    fmTypeViewDisplay = new FmViewTDS.LFS_FM_TYPE_VIEW_DISPLAYDataTable();
                    fmTypeViewSort = new FmViewTDS.LFS_FM_TYPE_VIEW_SORTDataTable();
                    fmViewDisplayTemp = new FmViewTDS.FmViewDisplayTempDataTable();
                    fmViewSortTemp = new FmViewTDS.FmViewSortTempDataTable();
                    fmViewConditionNew = new FmViewTDS.FmViewConditionNewDataTable();

                    // ... for Categories
                    categoriesTDS = new CategoriesTDS();

                    // ... Store datasets
                    Session["fmViewTDS"] = fmViewTDS;

                    Session["fmTypeViewDisplay"] = fmTypeViewDisplay;
                    Session["fmTypeViewSort"] = fmTypeViewSort;
                    Session["fmViewDisplayTemp"] = fmViewDisplayTemp;
                    Session["fmViewSortTemp"] = fmViewSortTemp;
                    Session["fmViewConditionNew"] = fmViewConditionNew;

                    Session["categoriesTDSForAddView"] = categoriesTDS;
                }

                // StepSection1In
                wzViews.ActiveStepIndex = 0;
                StepBeginIn();
            }
            else
            {
                // Restore datasets
                fmViewTDS = (FmViewTDS)Session["fmViewTDS"];

                fmTypeViewDisplay = (FmViewTDS.LFS_FM_TYPE_VIEW_DISPLAYDataTable)Session["fmTypeViewDisplay"];
                fmTypeViewSort = (FmViewTDS.LFS_FM_TYPE_VIEW_SORTDataTable)Session["fmTypeViewSort"];
                fmViewDisplayTemp = (FmViewTDS.FmViewDisplayTempDataTable)Session["fmViewDisplayTemp"];
                fmViewSortTemp = (FmViewTDS.FmViewSortTempDataTable)Session["fmViewSortTemp"];
                fmViewConditionNew = (FmViewTDS.FmViewConditionNewDataTable)Session["fmViewConditionNew"];

                categoriesTDS = (CategoriesTDS)Session["categoriesTDSForAddView"];
            }

            // Control for postback
            hdfTag.Value = DateTime.Now.ToLongTimeString();
        }
Пример #5
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);

                FmTypeViewConditionGateway fmTypeViewConditionGateway = new FmTypeViewConditionGateway();
                fmTypeViewConditionGateway.LoadByFmTypeConditionId(hdfFmType.Value, int.Parse(hdfCompanyId.Value), conditionId);
                string type = fmTypeViewConditionGateway.GetType(hdfFmType.Value, int.Parse(hdfCompanyId.Value), conditionId);
                string value = "";

                if ((type == "String") || (type == "Date") || (type == "Int") || (type == "Decimal") )
                {
                    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.Replace("-", "");
                    value = value.Trim();
                }

                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";
                }

                FmViewTDS dataSet = new FmViewTDS();
                dataSet.FmViewConditionNew.Merge(fmViewConditionNew, true);
                FmViewConditionNew model = new FmViewConditionNew(dataSet);

                model.Update(id, conditionId, name, operator_, sign, conditionNumber, value, false, false);
                Session["fmViewConditionNew"] = dataSet.FmViewConditionNew;
                fmViewConditionNew = dataSet.FmViewConditionNew;
            }
            else
            {
                e.Cancel = true;
            }
        }
Пример #6
0
        private bool StepColumnsToDisplayNext()
        {
            ViewState["columnsToDisplayPageIndex"] = grdColumnsToDisplay.PageIndex;

            Page.Validate("ColumsToDisplay");

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

                // Create dataset
                FmViewTDS dataSet = new FmViewTDS();
                dataSet.LFS_FM_TYPE_VIEW_DISPLAY.Merge(fmTypeViewDisplay, true);
                dataSet.FmViewDisplayTemp.Merge(fmViewDisplayTemp, true);

                // Process
                int companyId = Int32.Parse(hdfCompanyId.Value);
                string fmType = hdfFmType.Value;
                int viewId = Int32.Parse(hdfViewId.Value);

                FmViewDisplayTemp model = new FmViewDisplayTemp(dataSet);
                model.ProcessForEdit(viewId, fmType, companyId);

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

                // Store tables
                Session.Remove("fmTypeViewDisplayDummy");
                Session["fmTypeViewDisplay"] = fmTypeViewDisplay;
                Session["fmViewDisplayTemp"] = fmViewDisplayTemp;

                // Load conditions for next step
                dataSet.FmViewConditionNew.Merge(fmViewConditionNew, true);
                dataSet.FmViewConditionTemp.Merge(fmViewConditionTemp, true);

                FmViewConditionNew modelConditionNew = new FmViewConditionNew(dataSet);
                modelConditionNew.LoadByViewIdCompanyIdFmType(viewId, companyId, fmType);

                // Store tables
                fmViewConditionNew = (FmViewTDS.FmViewConditionNewDataTable)modelConditionNew.Table;
                Session["fmViewConditionNew"] = fmViewConditionNew;

                return true;
            }
            else
            {
                return false;
            }
        }