protected void btnViewDelete_Click(object sender, EventArgs e)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
            int viewId = Int32.Parse(ddlView.SelectedValue.Trim());

            if (!(Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_DELETE"])))
            {
                FmViewGateway fmViewGateway = new FmViewGateway();
                fmViewGateway.LoadByViewId(viewId, companyId);
                string viewType = fmViewGateway.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 fmType = hdfFmType.Value;
            int loginId = Convert.ToInt32(Session["loginID"]);
            string viewTypeGlobal = "";
            string viewTypePersonal = "Personal";

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

            FmViewList fmViewList = new FmViewList();
            fmViewList.LoadAndAddItem(fmType, viewTypeGlobal, viewTypePersonal, loginId, companyId);
            ddlView.DataSource = fmViewList.Table;
            ddlView.DataValueField = "ViewID";
            ddlView.DataTextField = "Name";
            ddlView.DataBind();
            ddlView.SelectedIndex = 1;
        }
예제 #2
0
        /// <summary>
        /// SaveForEdit
        /// </summary>
        /// <param name="viewId">viewId</param>
        /// <param name="loginId">loginId</param>
        /// <param name="name">name</param>
        /// <param name="type">type</param>
        /// <param name="logic">logic</param>
        /// <param name="sqlCommand">sqlCommand</param>
        /// <param name="fmType">fmType</param>
        /// <param name="companyId">companyId</param>
        public void SaveForEdit(int viewId, int loginId, string name, string type, string logic, string sqlCommand, string fmType, int companyId, string newName, string newType)
        {
            FmViewGateway fmViewGateway = new FmViewGateway();
            fmViewGateway.LoadByViewId(viewId, companyId);

            int originalViewId = viewId;
            int originalLoginId = fmViewGateway.GetLoginId(viewId);
            string originalName = fmViewGateway.GetName(viewId);
            string originalType = fmViewGateway.GetType(viewId);
            string originalLogic = fmViewGateway.GetLogic(viewId);
            string originalSqlCommand = fmViewGateway.GetSqlCommand(viewId);
            string originalFmType = fmViewGateway.GetFmType(viewId);
            bool originalDeleted = fmViewGateway.GetDeleted(viewId);
            int originalCompanyId = fmViewGateway.GetCompanyId(viewId);

            UpdateDirect(originalViewId, originalLoginId, originalName, originalType, originalLogic, originalSqlCommand, originalFmType, originalDeleted, originalCompanyId, viewId, loginId, newName, newType, logic, sqlCommand, fmType, false, companyId);
        }
예제 #3
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_edit.aspx");
                }

                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_VIEWS_EDIT"])))
                {
                    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();
                hdfViewId.Value = (string)Request.QueryString["view_id"];
                hdfProjectId.Value = (string)Request.QueryString["project_id"];
                hdfUpdate.Value = "no";

                // Security check for global views
                if (!(Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_EDIT"])))
                {
                    if ((string)Request.QueryString["fm_type"] == "Services")
                    {
                        if (Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_VIEW"]))
                        {
                            FmViewGateway fmViewGateway = new FmViewGateway();
                            fmViewGateway.LoadByViewId(Int32.Parse(hdfViewId.Value), Int32.Parse(hdfCompanyId.Value));
                            string viewType = fmViewGateway.GetType(Int32.Parse(hdfViewId.Value));

                            if (viewType == "Global")
                            {
                                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"]))
                        {
                            FmViewGateway fmViewGateway = new FmViewGateway();
                            fmViewGateway.LoadByViewId(Int32.Parse(hdfViewId.Value), Int32.Parse(hdfCompanyId.Value));
                            string viewType = fmViewGateway.GetType(Int32.Parse(hdfViewId.Value));

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

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

                Session.Remove("fmTypeViewDisplay");
                Session.Remove("fmTypeViewDisplayDummy");
                Session.Remove("fmViewDisplayTemp");
                Session.Remove("fmViewDisplay");
                Session.Remove("fmViewConditionNew");
                Session.Remove("fmViewConditionTemp");
                Session.Remove("fmViewConditionNewDummy");
                Session.Remove("fmViewConditionTempDummy");
                Session.Remove("categoriesTDSForEditView");

                // Prepare initial data
                // ... For view type
                int viewId = Int32.Parse(hdfViewId.Value);
                int companyId = Int32.Parse(hdfCompanyId.Value);

                FmViewTypeList fmViewTypeList = new FmViewTypeList(new DataSet());
                fmViewTypeList.LoadAndAddItem("(Select a type)", companyId);
                ddlType.DataSource = fmViewTypeList.Table;
                ddlType.DataValueField = "Type";
                ddlType.DataTextField = "Type";
                ddlType.DataBind();
                ddlType.SelectedIndex = 0;

                // ... Global Views check
                if (!Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_VIEW"]))
                {
                    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();
                    fmViewConditionTemp = new FmViewTDS.FmViewConditionTempDataTable();

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

                    // Initiaize view data
                    // ... Loading views and data
                    FmViewGateway fmViewGateway = new FmViewGateway(fmViewTDS);
                    fmViewGateway.LoadByViewId(viewId, companyId);
                    tbxName.Text = fmViewGateway.GetName(viewId);
                    ddlType.SelectedValue = fmViewGateway.GetType(viewId);

                    // ... Store datasets
                    Session["fmTypeViewDisplay"] = fmTypeViewDisplay;
                    Session["fmTypeViewSort"] = fmTypeViewSort;
                    Session["fmViewDisplayTemp"] = fmViewDisplayTemp;
                    Session["fmViewSortTemp"] = fmViewSortTemp;
                    Session["fmViewConditionNew"] = fmViewConditionNew;
                    Session["fmViewConditionTemp"] = fmViewConditionTemp;

                    Session["categoriesTDSForEditView"] = categoriesTDS;
                }

                // StepSection In
                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"];
                fmViewConditionTemp = (FmViewTDS.FmViewConditionTempDataTable)Session["fmViewConditionTemp"];

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

            // Control for postback
            hdfTag.Value = DateTime.Now.ToLongTimeString();
        }