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;
        }
        private ServicesNavigatorTDS SubmitSearchForViews()
        {
            int viewId = Int32.Parse(ddlView.SelectedValue.Trim());
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            // ... Load SqlCommand
            FmViewGateway fmViewGateway = new FmViewGateway();
            fmViewGateway.LoadByViewId(viewId, companyId);

            string sqlCommand = "";
            sqlCommand = fmViewGateway.GetSqlCommand(viewId);

            // ... Load data
            string fmType = hdfFmType.Value.Trim();

            ServicesNavigator servicesNavigator = new ServicesNavigator();
            servicesNavigator.LoadForViewsFmTypeCompanyId(sqlCommand, fmType, companyId);

            return (ServicesNavigatorTDS)servicesNavigator.Data;
        }
        protected void btnExportList_Click(object sender, EventArgs e)
        {
            string url = "";
            string headerValues = "";
            int totalColumnsExport = 29;
            int totalColumnsPreview = 28;
            string title = "Services Search Results";
            string columnsForReport = "";
            int j;

            // ... for title view
            if (hdfBtnOrigin.Value == "Go")
            {
                int viewId = Int32.Parse(ddlView.SelectedValue.Trim());
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

                // ... Load name view
                FmViewGateway fmViewGateway = new FmViewGateway();
                fmViewGateway.LoadByViewId(viewId, companyId);

                title = fmViewGateway.GetName(viewId);
            }

            // ... For comments option
            string comments = "None";

            headerValues = "";
            columnsForReport = "";

            // Establishing header values
            if (grdServicesNavigator.Columns[2].Visible) headerValues += "Service Number";
            if (grdServicesNavigator.Columns[3].Visible) headerValues += " * Date";
            if (grdServicesNavigator.Columns[4].Visible) headerValues += " * Fixed Date";
            if (grdServicesNavigator.Columns[5].Visible) headerValues += " * Service State";
            if (grdServicesNavigator.Columns[6].Visible) headerValues += " * Problem Description";
            if (grdServicesNavigator.Columns[7].Visible) headerValues += " * Unit Code";
            if (grdServicesNavigator.Columns[8].Visible) headerValues += " * Unit Description";
            if (grdServicesNavigator.Columns[9].Visible) headerValues += " * VIN/SN";
            if (grdServicesNavigator.Columns[10].Visible) headerValues += " * Unit State";
            if (grdServicesNavigator.Columns[11].Visible) headerValues += " * Checklist Rule";
            if (grdServicesNavigator.Columns[12].Visible) headerValues += " * Checklist State";
            if (grdServicesNavigator.Columns[13].Visible) headerValues += " * Created by";
            if (grdServicesNavigator.Columns[14].Visible) headerValues += " * Mileage";
            if (grdServicesNavigator.Columns[15].Visible) headerValues += " * Assign Date";
            if (grdServicesNavigator.Columns[16].Visible) headerValues += " * Deadline Date";
            if (grdServicesNavigator.Columns[17].Visible) headerValues += " * Assigned to";
            if (grdServicesNavigator.Columns[18].Visible) headerValues += " * Accepted Date";
            if (grdServicesNavigator.Columns[19].Visible) headerValues += " * Start Date";
            if (grdServicesNavigator.Columns[20].Visible) headerValues += " * Unit Out Of Service Date";
            if (grdServicesNavigator.Columns[21].Visible) headerValues += " * Unit Out Of Service Time";
            if (grdServicesNavigator.Columns[22].Visible) headerValues += " * Start Work Mileage";
            if (grdServicesNavigator.Columns[23].Visible) headerValues += " * Complete Date";
            if (grdServicesNavigator.Columns[24].Visible) headerValues += " * Unit Back In Service Date";
            if (grdServicesNavigator.Columns[25].Visible) headerValues += " * Unit Back In Service Time";
            if (grdServicesNavigator.Columns[26].Visible) headerValues += " * Complete Work Mileage";
            if (grdServicesNavigator.Columns[27].Visible) headerValues += " * Work Details";
            if (grdServicesNavigator.Columns[28].Visible) headerValues += " * Preventable";
            if (grdServicesNavigator.Columns[29].Visible) headerValues += " * Labour Hours";
            if (grdServicesNavigator.Columns[30].Visible) headerValues += " * Notes";

            // Establishing columns to display
            string[] columnsExcel = headerValues.Split('*');

            // ... for visible columns
            for (int i = 0; i < columnsExcel.Length; i++)
            {
                j = i + 1;
                columnsForReport += "&header" + j + "=" + columnsExcel[i].Trim();
            }

            // ... For not visible columns
            for (int i = columnsExcel.Length; i < totalColumnsExport; i++)
            {
                j = i + 1;
                columnsForReport += "&header" + j + "=None";
            }

            if (grdServicesNavigator.Columns[30].Visible) comments = "Comments";

            // Report call
            Page.Validate();
            if (Page.IsValid)
            {
                PostPageChanges();
                title = title.Replace("'", "%27");
                Response.Write("<script language='javascript'> {window.open('./services_print_search_results_report.aspx?" + columnsForReport + "&comments=" + comments + "&totalColumnsPreview=" + totalColumnsPreview + "&totalColumnsExport=" + totalColumnsExport + "&totalSelectedColumns=" + columnsExcel.Length + "&title=" + title + "&format=excel', '_blank', 'toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=800, height=680');}</script>");
            }

            if (url != "") Response.Redirect(url);
        }
        protected void btnPreviewList_Click(object sender, EventArgs e)
        {
            string url = "";
            string headerValues = "";
            int totalColumnsExport = 37;
            int totalColumnsPreview = 36;
            string title = "Units Search Results";

            // ... for title view
            if (hdfBtnOrigin.Value == "Go")
            {
                int viewId = Int32.Parse(ddlView.SelectedValue.Trim());
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

                // ... Load name view
                FmViewGateway fmViewGateway = new FmViewGateway();
                fmViewGateway.LoadByViewId(viewId, companyId);

                title = fmViewGateway.GetName(viewId);
            }

            // ... For notes option
            string notes = "None";

            // Establishing header values
            if (grdUnitsNavigator.Columns[2].Visible) headerValues += "Code";
            if (grdUnitsNavigator.Columns[3].Visible) headerValues += " * Description";
            if (grdUnitsNavigator.Columns[4].Visible) headerValues += " * VIN/SN";
            if (grdUnitsNavigator.Columns[5].Visible) headerValues += " * State";
            if (grdUnitsNavigator.Columns[6].Visible) headerValues += " * Manufacturer";
            if (grdUnitsNavigator.Columns[7].Visible) headerValues += " * Model";
            if (grdUnitsNavigator.Columns[8].Visible) headerValues += " * Is Towable?";
            if (grdUnitsNavigator.Columns[9].Visible) headerValues += " * Insurance Class";
            if (grdUnitsNavigator.Columns[10].Visible) headerValues += " * Ryder Specified";

            // before columns 9 after columns 11
            if (grdUnitsNavigator.Columns[11].Visible) headerValues += " * Model Year";
            if (grdUnitsNavigator.Columns[12].Visible) headerValues += " * Category";
            if (grdUnitsNavigator.Columns[13].Visible) headerValues += " * Company Level";
            if (grdUnitsNavigator.Columns[14].Visible) headerValues += " * Acquisition Date";
            if (grdUnitsNavigator.Columns[15].Visible) headerValues += " * Cost (CAD)";
            if (grdUnitsNavigator.Columns[16].Visible) headerValues += " * Cost (USD)";
            if (grdUnitsNavigator.Columns[17].Visible) headerValues += " * License Country";
            if (grdUnitsNavigator.Columns[18].Visible) headerValues += " * License State";
            if (grdUnitsNavigator.Columns[19].Visible) headerValues += " * License Plate Number";
            if (grdUnitsNavigator.Columns[20].Visible) headerValues += " * Apportioned Tag Number";
            if (grdUnitsNavigator.Columns[21].Visible) headerValues += " * Actual Weight";
            if (grdUnitsNavigator.Columns[22].Visible) headerValues += " * Registered Weight";
            if (grdUnitsNavigator.Columns[23].Visible) headerValues += " * Tire Size Front";
            if (grdUnitsNavigator.Columns[24].Visible) headerValues += " * Tire Size Back";
            if (grdUnitsNavigator.Columns[25].Visible) headerValues += " * Number Of Axes";
            if (grdUnitsNavigator.Columns[26].Visible) headerValues += " * Fuel Type";
            if (grdUnitsNavigator.Columns[27].Visible) headerValues += " * Beginning Odometer";
            if (grdUnitsNavigator.Columns[28].Visible) headerValues += " * Is Reefer Equipped?";
            if (grdUnitsNavigator.Columns[29].Visible) headerValues += " * Is PTO Equipped?";
            if (grdUnitsNavigator.Columns[30].Visible) headerValues += " * Owner Type";
            if (grdUnitsNavigator.Columns[31].Visible) headerValues += " * Owner Country";
            if (grdUnitsNavigator.Columns[32].Visible) headerValues += " * Owner State";
            if (grdUnitsNavigator.Columns[33].Visible) headerValues += " * Owner Name";
            if (grdUnitsNavigator.Columns[34].Visible) headerValues += " * Contact Info";
            if (grdUnitsNavigator.Columns[35].Visible) headerValues += " * Qualified Date";
            if (grdUnitsNavigator.Columns[36].Visible) headerValues += " * Not Qualified Date";
            if (grdUnitsNavigator.Columns[37].Visible) headerValues += " * Not Qualified Explain";

            // Establishing columns to display
            string[] columns = headerValues.Split('*');
            string columnsForReport = "";
            int j;

            // ... For visible columns
            for (int i = 0; i < columns.Length; i++)
            {
                j = i + 1;
                columnsForReport += "&header" + j + "=" + columns[i].Trim();
            }

            // ... For not visible columns
            for (int i = columns.Length; i < totalColumnsPreview; i++)
            {
                j = i + 1;
                columnsForReport += "&header" + j + "=None";
            }

            if (grdUnitsNavigator.Columns[38].Visible) { notes = "Notes"; }

            // Report call
            Page.Validate();
            if (Page.IsValid)
            {
                PostPageChanges();
                title = title.Replace("'", "%27");
                Response.Write("<script language='javascript'> {window.open('./units_print_search_results_report.aspx?" + columnsForReport + "&notes=" + notes + "&totalColumnsPreview=" + totalColumnsPreview + "&totalColumnsExport=" + totalColumnsExport + "&totalSelectedColumns=" + columns.Length + "&title=" + title + "&format=pdf', '_blank', 'toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=800, height=680');}</script>");
            }

            if (url != "") Response.Redirect(url);
        }
Beispiel #5
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);
        }
        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();
                }
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int viewId = Int32.Parse(hdfViewId.Value);

                FmViewGateway fmViewGateway = new FmViewGateway();
                fmViewGateway.LoadByViewId(viewId, companyId );

                fmViewConditionTemp.Rows.Clear();

                // Create dataset
                FmViewTDS dataSet = new FmViewTDS();
                dataSet.FmViewConditionNew.Merge(fmViewConditionNew, true);
                dataSet.FmViewConditionTemp.Merge(fmViewConditionTemp, true);

                // Process conditions
                FmViewConditionTemp model = new FmViewConditionTemp(dataSet);
                FmViewConditionNew modelLogic = new FmViewConditionNew(dataSet);

                string originalLogic = fmViewGateway.GetLogic(viewId);
                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
                fmViewConditionNew.Rows.Clear();
                fmViewConditionNew.Merge(modelLogic.Table);
                fmViewConditionTemp.Rows.Clear();
                fmViewConditionTemp.Merge(model.Table);

                // Store tables
                Session.Remove("fmViewConditionNewDummy");
                Session.Remove("fmViewConditionTempDummy");
                Session["fmViewConditionNew"] = fmViewConditionNew;
                Session["fmViewConditionTemp"] = fmViewConditionTemp;

                Session["conditionsUpdate"] = null;

                return true;
            }
            else
            {
                return false;
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // 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();
        }