コード例 #1
0
        public static dsPersonnel GetPersonnel(string Database, string strSearch)
        {
            //Initializes the dataset and Set to look at the dataset
            dsPersonnel DS = new dsPersonnel();
            //Initializes the SQL connection and Sets the connection so it will look at the correct database
            OleDbConnection sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Database);
            //Initializes the adapter
            OleDbDataAdapter sqlDA;

            //If statment for if there is information in the strSearch
            if (strSearch == null || strSearch.Trim() == "")
            {
                //Sets the SQL be be using the connection
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
            }
            else
            {
                //Sets the SQL be be using the connection
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel where " + strSearch, sqlConn);
            }

            //Gets the information from the dataset
            sqlDA.Fill(DS.tblPersonnel);

            //Returns what is in the dataset
            return(DS);
        }
コード例 #2
0
    // This function gets the user activity from the tblPersonnel

    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        //create the connection string
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                      "Data Source=" + Database);



        if (String.IsNullOrEmpty(strSearch) == true)
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }

        else
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where lastName = '" + strSearch + "'", sqlConn);
        }


        // Defines DS and what each will consist of
        DS = new dsPersonnel();

        // Outputs the results from the information gathered
        sqlDA.Fill(DS.tblPersonnel);

        // Starts over for a new user
        return(DS);
    }
コード例 #3
0
    public static dsPersonnel  GetPersonnel(string Database, string strSearch)
    {
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        //Opens DB
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);
        // selects the user activity table from DB
        if (strSearch == null || strSearch.Trim() == "")
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        else
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
        }

        //sets dataset for new user activity
        DS = new dsPersonnel();
        // adds user dats activity to DB
        sqlDA.Fill(DS.tblPersonnel);
        //returns dataset with user activity
        return(DS);
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Retrieve search query
        string strSearchQuery = Request["txtSearchName"];

        if (!Page.IsPostBack)
        {
            //Declare the DataSet
            dsPersonnel myDataSet = new dsPersonnel();

            // Default no search string upon load
            if (strSearchQuery == null)
            {
                strSearchQuery = "";
            }

            // Fill the dataset with what is returned from the function
            myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), strSearchQuery.Trim());

            // Set the DataGrid to the DataSource based on the table
            grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

            // Bind the DataGrid
            grdViewPersonnel.DataBind();
        }
    }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //    if (!Page.IsPostBack)
        //    {

        //        // Declare the DataSet
        //        dsPersonnel myDataSet = new dsPersonnel();

        //        string strSearch = Request["txtSearch"];

        //        // Fill the dataset with what is returned from the function
        //        myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), strSearch);

        //        // Set the DataGrid to the DataSource based on the table
        //        grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

        //        // Bind the DataGrid
        //        grdViewPersonnel.DataBind();

        //    }

        if (!Page.IsPostBack)
        {
// Declare the DataSet
            dsPersonnel myDataSet = new dsPersonnel();

            // Fill the dataset with what is returned from the function
            myDataSet = clsDataLayer.GetPersonel(Server.MapPath("PayrollSystem_DB.mdb"));
// Set the DataGrid to the DataSource based on the table
            grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

// Bind the DataGrid
            grdViewPersonnel.DataBind();
        }
    }
コード例 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Retrieve search query
        string strSearchQuery = Request["txtSearchName"];

        if (!Page.IsPostBack)
        {
            //Declare the DataSet
            dsPersonnel myDataSet = new dsPersonnel();

            // Default no search string upon load
            if (strSearchQuery == null)
            {
                strSearchQuery = "";
            }

            // Fill the dataset with what is returned from the function
            myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), strSearchQuery.Trim());

            // Set the DataGrid to the DataSource based on the table
            grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

            // Bind the DataGrid
            grdViewPersonnel.DataBind();
        }
    }
コード例 #7
0
        // This function gets the user activity from the tblPersonnel
        public static dsPersonnel GetPersonnel(string Database, string strSearch)
        {
            // Opens the userActivity Data Set
            dsPersonnel      DS;
            OleDbConnection  sqlConn;
            OleDbDataAdapter sqlDA;

            // Connects to the database
            sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; " + "Data Source=" + Database);
            // Selects from the tblPersonnel table

            if (strSearch == null || strSearch.Trim() == "")
            {
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
            }
            else
            {
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
            }
            // Creates a new activity in table personnel
            DS = new dsPersonnel();
            // Fills the table with data
            sqlDA.Fill(DS.tblPersonnel);
            // Returns the data to the data set
            return(DS);
        }
コード例 #8
0
        // End of Week 6 additions

        public static dsPersonnel GetPersonnel(string Database, string strSearch)
        {
            // These are the variables set for the database
            dsPersonnel      DS;
            OleDbConnection  sqlConn;
            OleDbDataAdapter sqlDA;

            // Here we start a new connection to the database
            sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);
            // Starting a new instance for the BD adapter
            if (strSearch == null || strSearch.Trim() == "")
            {
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
            }
            else
            {
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
            }
            // A new instance to track user activity
            DS = new dsPersonnel();
            // Add your comments here
            sqlDA.Fill(DS.tblPersonnel);
            // Add your comments here
            return(DS);
        }
コード例 #9
0
    // This function gets the user activity from the tblUserActivity
    public static dsPersonnel GetPersonnel(string Database, string searchTerm)
    {
        // define and intialize variables
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        // Define sqlConn and connect database
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                      "Data Source=" + Database);

        // check for blank search

        if (searchTerm == "" || searchTerm == null)
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        else
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + searchTerm + "'", sqlConn);
        }

        // defines DS which is database table Personnel
        DS = new dsPersonnel();

        // Using items selected from variable sqlDA and enters into table Personnel
        sqlDA.Fill(DS.tblPersonnel);

        // Returns the value DS which is simply a table of information from the SQL database
        return(DS);
    }
コード例 #10
0
    // This function gets the personnel information from the tblPersonnel table
    public static dsPersonnel GetPersonnel(string Database, string Search)
    {
        // Simplified Classes Being Used
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        // Defines sqlConn Class (OleDbConnection) with provided arguments
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                      "Data Source=" + Database);

        // Added search function
        string strSearchQuery = Search;

        // If there is a search
        if (strSearchQuery == "")
        {
            // Defines sqlDA Class (OleDbDataAdapter) with provided arguments, selecting all from table personnel
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        else
        {
            // Creates new data adapter for search query
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearchQuery + "'", sqlConn);
        }

        // Defines DS Class (dsPersonnel)
        DS = new dsPersonnel();

        // Outputs the results from the information gathered
        sqlDA.Fill(DS.tblPersonnel);

        // Returns the variable DS (dsPersonnel)
        return(DS);
    }
コード例 #11
0
        public static dsPersonnel GetPersonnel(string Database, string strSearch)
        {
            // variables to connect to database
            dsPersonnel      DS;
            OleDbConnection  sqlConn;
            OleDbDataAdapter sqlDA;

            // Create object to connect to database
            sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);

            // Create object to grab data from table
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);

            //test if a value is entered for a search parameter
            if (strSearch == null || strSearch.Trim() == "")
            {
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
            }
            else
            {
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
            }

            // Object to create new dataset
            DS = new dsPersonnel();

            // Fill in the object with the data
            sqlDA.Fill(DS.tblPersonnel);

            // Pass the data through
            return(DS);
        }
コード例 #12
0
    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        // creating OLEDB Dataset, OLEDB connection and Data adapter objects
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        //create a new connection and provide conenction string to the connection object
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                      "Data Source=" + Database);

        //A where clause for the sql query initially set to empty string
        string whereClause = "";

        //Checks if strSearch paramter has some value then set the where clause
        if (strSearch.Trim().Length > 0)
        {
            whereClause = whereClause + " where LastName = '" + strSearch + "'";
        }

        // create a new data adapter and provide query to the data adapter with the where clause
        sqlDA = new OleDbDataAdapter("select * from tblPersonnel " + whereClause, sqlConn);
        // allocate new data set
        DS = new dsPersonnel();
        // fill the dataset with the results generated from the query
        sqlDA.Fill(DS.tblPersonnel);
        // return the data set
        return(DS);
    }
コード例 #13
0
    //This function gets the employee information from the tblPersonnel
    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        //Create variables
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        //Create the connection string
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);
        //Defines sqlDA and what each will consist of and test if a value is entered for a search parameter
        if (strSearch == null || strSearch.Trim() == "")
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        else
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
        }
        //Defines DS and what each will consist of
        DS = new dsPersonnel();
        //Outputs the results from the information gathered
        sqlDA.Fill(DS.tblPersonnel);
        //Starts over for a new user
        return(DS);
    }
コード例 #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["SecurityLevel"] == "U")
        {
            //LinkButton lb = (LinkButton)Master.FindControl("lbAddPersonnel");
            //lb.Visible = false;
            //(LinkButton)Master.FindControl("lbAddPersonnel").Visible = false;
            Master.FindControl("lbAddPersonnel").Visible = false;
            Master.FindControl("lbUserActivity").Visible = false;
            Master.FindControl("lbEditEmployees").Visible = false;
            Master.FindControl("lbManageUsers").Visible = false;
        }

        string searchVal = "";

        if (Session["txtSearchName"] != null)
        {
            searchVal = Session["txtSearchName"].ToString();
            Session["txtSearchName"] = "";
        }

        if (!Page.IsPostBack)
        {
            if (searchVal == null)
            {
                //Declare the DataSet
                dsPersonnel myDataSet = new dsPersonnel();

                //Fill the dataset with what is returned from the function
                myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"));

                //Set the dataset with what is returned from the function
                grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

                //Bind the DataGrid
                grdViewPersonnel.DataBind();
            }
            else
            {
                //Declare the DataSet
                dsPersonnel myDataSet = new dsPersonnel();

                //Fill the dataset with what is returned from the function
                myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), searchVal);

                //Set the dataset with what is returned from the function
                grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

                //Bind the DataGrid
                grdViewPersonnel.DataBind();
            }
        }

        clsDataLayer.SaveUserActivity(Server.MapPath("PayrollSystem_DB.mdb"), "frmViewPersonnel");
    }
コード例 #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["SecurityLevel"] == "U")
        {
            //LinkButton lb = (LinkButton)Master.FindControl("lbAddPersonnel");
            //lb.Visible = false;
            //(LinkButton)Master.FindControl("lbAddPersonnel").Visible = false;
            Master.FindControl("lbAddPersonnel").Visible  = false;
            Master.FindControl("lbUserActivity").Visible  = false;
            Master.FindControl("lbEditEmployees").Visible = false;
            Master.FindControl("lbManageUsers").Visible   = false;
        }

        string searchVal = "";

        if (Session["txtSearchName"] != null)
        {
            searchVal = Session["txtSearchName"].ToString();
            Session["txtSearchName"] = "";
        }

        if (!Page.IsPostBack)
        {
            if (searchVal == null)
            {
                //Declare the DataSet
                dsPersonnel myDataSet = new dsPersonnel();

                //Fill the dataset with what is returned from the function
                myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"));

                //Set the dataset with what is returned from the function
                grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

                //Bind the DataGrid
                grdViewPersonnel.DataBind();
            }
            else
            {
                //Declare the DataSet
                dsPersonnel myDataSet = new dsPersonnel();

                //Fill the dataset with what is returned from the function
                myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), searchVal);

                //Set the dataset with what is returned from the function
                grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

                //Bind the DataGrid
                grdViewPersonnel.DataBind();
            }
        }

        clsDataLayer.SaveUserActivity(Server.MapPath("PayrollSystem_DB.mdb"), "frmViewPersonnel");
    }
コード例 #16
0
        public static dsPersonnel GetPersonnel(string Database)
        {
            dsPersonnel      DS;
            OleDbConnection  sqlConn;
            OleDbDataAdapter sqlDA;

            sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);
            sqlDA   = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
            DS      = new dsPersonnel();
            sqlDA.Fill(DS.tblPersonnel);
            return(DS);
        }
コード例 #17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         //Declare the Dataset
         dsPersonnel myDataSet = new dsPersonnel();
         //Name value pair for the search value is passed as part of the request object.
         string strSearch = Request["txtSearch"];
         //Modifies the call of the GetPersonnel function
         //Fill the dataset with shat is returned from the method.
         myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), strSearch);
         //Set the DataGrid to the DataSource based on the table
         grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];
         //Bind the DataGrid
         grdViewPersonnel.DataBind();
     }
 }
コード例 #18
0
    public static dsPersonnel GetPersonnel(string Database)
    {
        dsPersonnel DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;

        // Add your comments here
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);

        sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);

        DS = new dsPersonnel();
        // fill the dataset with the tblPersonnel data
        sqlDA.Fill(DS.tblPersonnel);
        // return the data filled dsPersonnel
        return DS;
    }
コード例 #19
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            String searchTerm = Request["txtSearchName"];
            // Declare the DataSet
            dsPersonnel myDataSet = new dsPersonnel();

            // Fill the dataset with what is returned from the function
            myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), searchTerm);

            // Sets the DataGrid to the DataSource based on the table
            grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

            //Bind the DataGrid
            grdViewPersonnel.DataBind();
        }
    }
コード例 #20
0
    public static dsPersonnel GetPersonnel(string Database)
    {
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        // Add your comments here
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                      "Data Source=" + Database);

        sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);

        DS = new dsPersonnel();
        // fill the dataset with the tblPersonnel data
        sqlDA.Fill(DS.tblPersonnel);
        // return the data filled dsPersonnel
        return(DS);
    }
コード例 #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // Declares the DataSet
            dsPersonnel myDataSet = new dsPersonnel();

            string search = Request["txtSearch"];
            
            // Fill the dataset with what is returned from the function
            myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), search);

            // Sets the DataGrid to the DataSource based on the table
            grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

            // Binds the DataGrid
            grdViewPersonnel.DataBind();
        }
    }
コード例 #22
0
    //public static dsUser GetUser(string Database)
    //{
    //    dsUser DS;
    //    OleDbConnection sqlConn;
    //    OleDbDataAdapter sqlDA;
    //    sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Database);
    //    sqlDA = new OleDbDataAdapter("select * from tblUserLogin", sqlConn);
    //    DS = new dsUser();
    //    sqlDA.Fill(DS.tblUserLogin);
    //    return DS;
    //}

    public static dsPersonnel GetPersonnel(string Database, string searchVal)
    {
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                      "Data Source=" + Database);

        sqlDA = new OleDbDataAdapter("select * from tblPersonnel WHERE LastName LIKE '%" + searchVal + "%' ", sqlConn);

        DS = new dsPersonnel();

        // fill the dataset with the tblPersonnel data
        sqlDA.Fill(DS.tblPersonnel);

        // return the data filled dsPersonnel
        return(DS);
    }
コード例 #23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string strSearch = Convert.ToString(Request["txtSearchName"]);

            //Declare the DataSet
            dsPersonnel myDateSet = new dsPersonnel();


            myDateSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), strSearch);

            //Set the DataGrid to the DataSource based on the table
            grdViewPersonnel.DataSource = myDateSet;

            //Bind the DataSet
            grdViewPersonnel.DataBind();
        }
    }
コード例 #24
0
ファイル: clsDataLayer.cs プロジェクト: grigsby7310/WebCode
 public static dsPersonnel GetPersonnel(string Database, string strSearch)
 {
     dsPersonnel DS;
     OleDbConnection sqlConn;
     OleDbDataAdapter sqlDA;
     // Instantiation of OleDbConnection 'sqlConn'
     sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);
     // Instantiation of OledbDataAdapter 'sqlDA'
     if (strSearch == null || strSearch.Trim() == "")
         sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
     else
         sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
     // Instantiation of dsUserActivity 'DS'
     DS = new dsPersonnel();
     //The 'Fill' method of 'sqlDA' class used with a parameter to access the table in the dataset
     sqlDA.Fill(DS.tblPersonnel);
     // The method will return information from the UserActivity Dataset
     return DS;
 }
コード例 #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["SecurityLevel"] == null) // If security level is neither A nor U
            {
                Response.Redirect("frmLogin.aspx");
            }

            // declare local variable strSearch
            string strSearch = "";

            // CHeck whether accessed page does not have a null / empty string
            if (Session["txtSearch"] != null)
            {
                strSearch = Session["txtSearch"].ToString();
            }
            if (!Page.IsPostBack)
            {
                // if string is not null, search and display matching value from table
                if (strSearch != null)
                {
                    //Declare the Dataset
                    dsPersonnel myDataSet = new dsPersonnel();
                    //Fill the dataset with shat is returned from the method.
                    myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.accdb"), strSearch);
                    //Set the DataGrid to the DataSource based on the table
                    grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];
                    //Bind the DataGrid
                    grdViewPersonnel.DataBind();
                }
                else
                {
                    //Declare the Dataset
                    dsPersonnel myDataSet = new dsPersonnel();
                    //Fill the dataset with shat is returned from the method.
                    myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.accdb"));
                    //Set the DataGrid to the DataSource based on the table
                    grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];
                    //Bind the DataGrid
                    grdViewPersonnel.DataBind();
                }
            }
        }
コード例 #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["SecurityLevel"] != "A")
            {
                Response.Redirect("frmLogin.aspx");
            }

            if (!Page.IsPostBack)
            {
                //Declare the Dataset
                dsPersonnel myDataSet = new dsPersonnel();
                string      strSearch = Request["txtSearch"];
                //Fill the dataset with what is returned from the method.
                myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.accdb"), strSearch);
                //Set the DataGrid to the DataSource based on the table
                grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];
                //Bind the DataGrid
                grdViewPersonnel.DataBind();
            }
        }
コード例 #27
0
        public static dsPersonnel GetPersonnel(string Database, string strSearch)
        {
            dsPersonnel      DS;
            OleDbConnection  sqlConn;
            OleDbDataAdapter sqlDA;

            sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);

            if (strSearch == null || strSearch.Trim() == "")
            {
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
            }
            else
            {
                sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
            }

            DS = new dsPersonnel();
            sqlDA.Fill(DS.tblPersonnel);
            return(DS);
        }
コード例 #28
0
    // This function gets the personnel data from the tblPersonnel
    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        // Decare object variables to allocate memory
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        // Instantiate an OleDbConnection object called "sqlConn"
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                      "Data Source=" + Database);

        // Instantiate an OleDbDataAdapter object called "sqlDA" and pass it a SQL command
        //(next line commented out for search capability)
        //sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);

        // New code added for search capability
        // If nothing is entered in the search box, then return all personnel
        if (strSearch == null || strSearch.Trim() == "")
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        // O'wise, return only personnel with last name entered
        else
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" +
                                         strSearch + "'", sqlConn);
        }

        // Instantiate a dsPersonnel object called "DS"
        DS = new dsPersonnel();

        // Call to the sqlDA method called "Fill" passing the DS object as an argument,
        // passing the table Personnel with it
        sqlDA.Fill(DS.tblPersonnel);

        // Return the DS dataset object
        return(DS);
    }
コード例 #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // Declare the DataSet
            dsPersonnel myDataSet = new dsPersonnel();

            string strSearch = "";
            //Gets Search Name from the request object from the previous form's text box
            if (Request["txtSearchName"] != null) //Checks if the request string is null
            {
                strSearch = Request["txtSearchName"].ToString();
            }

            // Fill the dataset with what is returned from the function
            myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("App_Data\\PayrollSystem_DB.mdb"), strSearch);
            // Set the DataGrid to the DataSource based on the table
            grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

            // Bind the DataGrid
            grdViewPersonnel.DataBind();
        }
    }
コード例 #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Displays who has been looking at the View Personnel page
            clsDataLayer.SaveUserActivity(Server.MapPath("PayrollSystem_DB.mdb"), "frmViewPersonnel");

            //If this isn't a postback then do the following
            if (!Page.IsPostBack)
            {
                //Initializes and declares dataset
                dsPersonnel myDataSet = new dsPersonnel();
                string      strString = null;
                if (Session["txtLastNameSearch"] != null)
                {
                    strString = Session["txtLastNameSearch"].ToString();
                }

                if (strString == null)
                {
                    //Calls the information
                    myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), strString);
                }
                else
                {
                    //Calls the information
                    myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"), strString);
                }

                //Populates the datagrid area on this page
                grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

                //Committs the information to the grid
                grdViewPersonnel.DataBind();

                //Sets to null after being used
                Session["txtLastNameSearch"] = null;
            }
        }
コード例 #31
0
    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        dsPersonnel DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;
        // assigning OleDbConnection to sqlConn
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);
        // assigning DB query to sqlDA
        if (strSearch == null || strSearch.Trim() == "")
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        else
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
        }
        // instantiate dsUserActivity object
        DS = new dsPersonnel();
        // gets the information from the DB
        sqlDA.Fill(DS.tblPersonnel);
        // returns the info from dsUserActivity
        return DS;

    }
コード例 #32
0
    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        dsPersonnel      DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        // Instantiation of OleDbConnection 'sqlConn'
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);
        // Instantiation of OledbDataAdapter 'sqlDA'
        if (strSearch == null || strSearch.Trim() == "")
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        else
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
        }
        // Instantiation of dsUserActivity 'DS'
        DS = new dsPersonnel();
        //The 'Fill' method of 'sqlDA' class used with a parameter to access the table in the dataset
        sqlDA.Fill(DS.tblPersonnel);
        // The method will return information from the UserActivity Dataset
        return(DS);
    }
コード例 #33
0
    // This function retrieves all data from tblPersonnel table
    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        dsPersonnel     DS;
        OleDbConnection SqlConn;
        OleDbAdapter    sqlDA;

        //Opens OleDbConnection
        sqlConn = new OleDBConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);
        //Employee Search (procured from video, add in later?
        if (strSearch == null || strSearch == "")
        {
            sqlDA = new OleDbDataAdapter("Select * from tblPersonnel", sqlConn);
        }
        else
        {
            sqlDA = new OleDbAdapter("Select '' from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
        }
        //Sets Value of DS
        DS = new dsPersonnel();
        //Fills Table with Data
        sqlDA_Fill(DS.tblPersonnel);
        //Return value
        return(DS);
    }
コード例 #34
0
    // This function gets the personnel information from the tblPersonnel table
    public static dsPersonnel GetPersonnel(string Database, string Search)
    {
        // Simplified Classes Being Used
        dsPersonnel DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;

        // Defines sqlConn Class (OleDbConnection) with provided arguments
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);

        // Added search function
        string strSearchQuery = Search;

        // If there is a search
        if (strSearchQuery == "")
        {
            // Defines sqlDA Class (OleDbDataAdapter) with provided arguments, selecting all from table personnel
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        else
        {
            // Creates new data adapter for search query
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearchQuery + "'", sqlConn);
        }

        // Defines DS Class (dsPersonnel)
        DS = new dsPersonnel();

        // Outputs the results from the information gathered
        sqlDA.Fill(DS.tblPersonnel);

        // Returns the variable DS (dsPersonnel)
        return DS;
    }
コード例 #35
0
    public static dsPersonnel GetPersonnel(string Database)
    {
        dsPersonnel DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;

        // Connect to database
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);

        sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);

        DS = new dsPersonnel();
        // Fill dataset 
        sqlDA.Fill(DS.tblPersonnel);
        // Return data
        return DS;
    }
コード例 #36
0
    public static dsPersonnel GetPersonnel(string Database, string searchVal)
    {
        dsPersonnel DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;

        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);

        sqlDA = new OleDbDataAdapter("select * from tblPersonnel WHERE LastName LIKE '%"+searchVal+"%' ", sqlConn);

        DS = new dsPersonnel();

        // Fill dataset 
        sqlDA.Fill(DS.tblPersonnel);

        // Return data
        return DS;
    }
コード例 #37
0
    // This function gets the personnel data from the tblPersonnel
    public static dsPersonnel GetPersonnel(string Database,string strSearch)
    {
        // Decare object variables to allocate memory
        dsPersonnel DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;

        // Instantiate an OleDbConnection object called "sqlConn"
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);

        // Instantiate an OleDbDataAdapter object called "sqlDA" and pass it a SQL command
        //(next line commented out for search capability)
        //sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);

        // New code added for search capability
        // If nothing is entered in the search box, then return all personnel
        if (strSearch == null || strSearch.Trim() == "")
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        // O'wise, return only personnel with last name entered
        else
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" +
                strSearch + "'", sqlConn);
        }

        // Instantiate a dsPersonnel object called "DS"
        DS = new dsPersonnel();

        // Call to the sqlDA method called "Fill" passing the DS object as an argument,
        // passing the table Personnel with it
        sqlDA.Fill(DS.tblPersonnel);

        // Return the DS dataset object
        return DS;
    }