示例#1
0
        //
        // btnSubmit_Click
        //
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid && (tbxSearch.Text.Trim() != ""))
            {
                //--- Get data from database gateway
                tdsLfsRecordForArchiveTool = this.SubmitSearch();
                Session["tdsLfsRecordForArchiveTool"] = tdsLfsRecordForArchiveTool;

                //--- Show results
                if (tdsLfsRecordForArchiveTool.ARCHIVE.DefaultView.Count > 0)
                {
                    //--- ... Yes results
                    //--- ... Store archive tool state
                    Session["ddlSearchSelectedIndexForAT"] = ddlSearch.SelectedIndex;
                    Session["tbxSearchTextForAT"] = tbxSearch.Text;
                    Session["lblHintVisibleForAT"] = lblHint.Visible;
                    Session["lblHintTextForAT"] = lblHint.Text;

                    //--- ... Go to results page
                    Response.Redirect("archive2.aspx?source_page=archive.aspx&search_results=true");
                }
                else
                {
                    //--- ... No results
                    pNoResults.Visible = true;
                    lblResults.Visible = true;
                }
            }
        }
        //
        // GetRecordsByCompanyIdClient()
        //
        // Returns records that match a Client name (where Name like %client%) ordered by client, recordId
        //
        public TDSLFSRecordForArchiveTool GetRecordsByCompanyIdClient(int companyId, string client)
        {
            //--- Prepare search condition
            string[] tokens = client.Split(new char[]{' ',',',';','.',':','-','_','\\','/'}, 50);
            string condition = null;
            for (int i=0; i<tokens.Length; i++)
            {
                if (i==0)
                {
                    condition = "COMPANIES.NAME LIKE '%" + tokens[i].ToString() + "%' ";
                }
                else
                {
                    condition += "AND COMPANIES.NAME LIKE '%" + tokens[i].ToString() + "%' ";
                }
            }

            //--- Execute query
            SqlConnection connection = new SqlConnection(ConnectionString);

            string commandText = "SELECT LFS_MASTER_AREA.ID, LFS_MASTER_AREA.COMPANY_ID, LFS_MASTER_AREA.RecordID, LFS_MASTER_AREA.COMPANIES_ID, COMPANIES.NAME, LFS_MASTER_AREA.Street, LFS_MASTER_AREA.USMH, LFS_MASTER_AREA.DSMH, LFS_MASTER_AREA.Archived, CAST(0 AS BIT) AS Selected FROM LFS_MASTER_AREA INNER JOIN LFS_RESOURCES_COMPANIES AS COMPANIES ON LFS_MASTER_AREA.COMPANIES_ID = COMPANIES.COMPANIES_ID WHERE (LFS_MASTER_AREA.COMPANY_ID = @companyId) AND (" + condition + ") AND (LFS_MASTER_AREA.Deleted = 0) ORDER BY COMPANIES.NAME, LFS_MASTER_AREA.RecordID";
            SqlCommand command = new SqlCommand(commandText, connection);
            command.Parameters.Add(new SqlParameter("@companyId", companyId));

            SqlDataAdapter dataAdapter = new SqlDataAdapter(command);

            TDSLFSRecordForArchiveTool dataSet = new TDSLFSRecordForArchiveTool();
            dataAdapter.Fill(dataSet, "ARCHIVE");

            return dataSet;
        }
示例#3
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.tdsLfsRecordForArchiveTool = new TDSLFSRecordForArchiveTool();
     ((System.ComponentModel.ISupportInitialize)(this.tdsLfsRecordForArchiveTool)).BeginInit();
     //
     // tdsLfsRecordForArchiveTool
     //
     this.tdsLfsRecordForArchiveTool.DataSetName = "TDSLfsRecordForArchiveTool";
     this.tdsLfsRecordForArchiveTool.Locale = new System.Globalization.CultureInfo("en-US");
     ((System.ComponentModel.ISupportInitialize)(this.tdsLfsRecordForArchiveTool)).EndInit();
 }
        //
        // GetRecordsByCompanyIdDsmh()
        //
        // Returns records that match a dsmh (where dsmh like dsmh%) ordered by dsmh
        //
        public TDSLFSRecordForArchiveTool GetRecordsByCompanyIdDsmh(int companyId, string dsmh)
        {
            SqlConnection connection = new SqlConnection(ConnectionString);

            string commandText = "SELECT LFS_MASTER_AREA.ID, LFS_MASTER_AREA.COMPANY_ID, LFS_MASTER_AREA.RecordID, LFS_MASTER_AREA.COMPANIES_ID, COMPANIES.NAME, LFS_MASTER_AREA.Street, LFS_MASTER_AREA.USMH, LFS_MASTER_AREA.DSMH, LFS_MASTER_AREA.Archived, CAST(0 AS BIT) AS Selected FROM LFS_MASTER_AREA INNER JOIN LFS_RESOURCES_COMPANIES AS COMPANIES ON LFS_MASTER_AREA.COMPANIES_ID = COMPANIES.COMPANIES_ID WHERE (LFS_MASTER_AREA.COMPANY_ID = @companyId) AND (LFS_MASTER_AREA.DSMH LIKE @dsmh) AND (LFS_MASTER_AREA.Deleted = 0) ORDER BY LFS_MASTER_AREA.DSMH";
            SqlCommand command = new SqlCommand(commandText, connection);
            command.Parameters.Add(new SqlParameter("@companyId", companyId));
            command.Parameters.Add(new SqlParameter("@dsmh", dsmh + "%"));

            SqlDataAdapter dataAdapter = new SqlDataAdapter(command);

            TDSLFSRecordForArchiveTool dataSet = new TDSLFSRecordForArchiveTool();
            dataAdapter.Fill(dataSet, "ARCHIVE");

            return dataSet;
        }
        ///////////////////////////////////////////////////////////////////////////
        /// EVENTS
        ///
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                //--- Security check
                if (!(Convert.ToBoolean(Session["sgLFS_APP_VIEW"]) && Convert.ToBoolean(Session["sgLFS_APP_ADMIN"])))
                {
                    Response.Redirect("./../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

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

                //--- If coming from archive.aspx
                if (Request.QueryString["source_page"] == "archive.aspx")
                {
                    //--- Restore archive tool state
                    ddlSearch.SelectedIndex = (int)Session["ddlSearchSelectedIndexForAT"];
                    tbxSearch.Text = (string)Session["tbxSearchTextForAT"];
                    lblHint.Visible = (bool)Session["lblHintVisibleForAT"];
                    lblHint.Text = (string)Session["lblHintTextForAT"];

                    //--- Restore searched data
                    tdsLfsRecordForArchiveTool = (TDSLFSRecordForArchiveTool)Session["tdsLfsRecordForArchiveTool"];
                    archiveTool = tdsLfsRecordForArchiveTool.ARCHIVE;
                    Session["archiveTool"] = archiveTool;
                }
            }
            else
            {
                //--- Restore searched data (if any)
                tdsLfsRecordForArchiveTool = (TDSLFSRecordForArchiveTool)Session["tdsLfsRecordForArchiveTool"];
                archiveTool = tdsLfsRecordForArchiveTool.ARCHIVE;
                Session["archiveTool"] = archiveTool;
            }
        }