//Method called when searching with a name for an employee protected void NameSearch(object sender, EventArgs e) { //Checks to see if the itemnametxt textbox is an empty string if (itemnametxt.Text != "") { //if string is not empty it will create a new statement to append to the where clause using the itemname column and call for a datasource refresh from the TableBase object this.Binding(Base.Search("ItemName LIKE '%" + itemnametxt.Text + "%'")); } else { //if string is empty it will clear any current where clauses besides any filters and call for a datasoruce refresh with the TableBase object this.Binding(Base.Search()); } }
//Method called when searching with a department name protected void NameSearch(object sender, EventArgs e) { //If condition on the case that the textbox being based on isnt empty if (departnametxt.Text != "") { //Search query is sent to the table base class and refreshes the table this.Binding(Base.Search("DepartmentName LIKE '%" + departnametxt.Text + "%'")); } //If the textbox is empty and the submit button is pressed it just refreshes the table. also sends true statement in order to prevent sorting else { //Empty search query is sent to the table base class and refreshes the table this.Binding(Base.Search()); } }
TableBase Base; //Empty TableBase class called for built in methods to be avaliable protected void Page_Load(object sender, EventArgs e) { //Grabs the cookie and checks to see if a user is logged in and if not will redirect to the login page HttpCookie cookie = Request.Cookies["userInfo"]; if (Request.Cookies["userInfo"] == null) { Response.Redirect("login.aspx"); } else { nameLabel.Text = Request.Cookies["userInfo"]["firstName"]; cookie.Expires = DateTime.Now.AddMinutes(10); //Checks to see if the user is an admin or not and enables related department and employee items to be shown if (Request.Cookies["userInfo"]["admin"] == "True") { departmentnav.Visible = true; employeenav.Visible = true; } else { //The user is redirected to the index if Response.Redirect("index.aspx"); } Response.Cookies.Set(cookie); } if (!Page.IsPostBack) //Checks to see if the page is a refresh or initial load { //Creates default TableBase object based on target view/table and Default sorting column Base = new TableBase("EmployeesWithDeptName", "ID"); //Binds the default data to ViewState in order to keep throughout postbacks ViewState["Table"] = Base; //Initial binding and loading of data onto table //calls the show data method to fill table //On the event that there is a query string coming from the departments page it will instead load the table with a where clause if (Request.QueryString["departmentid"] != null) { this.Binding(Base.Search("DepartmentID = '" + Request.QueryString["departmentid"] + "' ")); //Places department id redirect query string in the search textbox for visual cue departidtxt.Text = Request.QueryString["departmentid"].Trim(new Char[] { ' ', 'D', '-' }); } else { //The default cause on the event there is no query string and the user goes directly to the page this.Binding(); } } else { //Grabs the viewstate versino of the tablebase and assigns it to the base object Base = (TableBase)ViewState["Table"]; } }
TableBase Base; //Empty TableBase class called for built in methods to be avaliable protected void Page_Load(object sender, EventArgs e) { //Grabs the cookie and checks to see if a user is logged in and if not will redirect to the login page HttpCookie cookie = Request.Cookies["userInfo"]; if (Request.Cookies["userInfo"] == null) { Response.Redirect("login.aspx"); } else { nameLabel.Text = Request.Cookies["userInfo"]["firstName"]; cookie.Expires = DateTime.Now.AddMinutes(10); //Checks to see if the user is an admin or not and enables related department and employee items to be shown if (Request.Cookies["userInfo"]["admin"] == "True") { departmentnav.Visible = true; employeenav.Visible = true; } Response.Cookies.Set(cookie); } //Detects if this is the first page load or refresh if (!Page.IsPostBack) { //Grabs the id attached to query string after redirect from purchaseorders page string purchid = Request.QueryString["purchid"]; //Labels give basic overall information of purchase order using query string LabOrderID.Text = purchid; LabOrderer.Text = Request.QueryString["name"]; LabODate.Text = Request.QueryString["odate"]; LabDDate.Text = Request.QueryString["ddate"]; //Creates default TableBase object based on target view/table and Default sorting column Base = new TableBase("PurchasePriceLine ", "SKU"); this.Binding(Base.Search("PurchID = '" + purchid + "' ")); //Binds the default data to ViewState in order to keep throughout postbacks ViewState["Table"] = Base; //Initial binding and loading of data onto table this.Binding(); } //All consecutive refreshes/postbacks will update the ViewState key with new recurring data. else { Base = (TableBase)ViewState["Table"]; } }
//Method called when searching for given employee name protected void NameSearch(object sender, EventArgs e) { //If condition on the case that the textbox being based on isnt empty if (employeenametxt.Text != "") { this.Binding(Base.Search("Name LIKE '%" + employeenametxt.Text + "%'")); } //If the textbox is empty and the submit button is pressed it just refreshes the table. also sends true statement in order to prevent sorting else { //if string is empty it will clear any current where clauses besides any filters and call for a datasoruce refresh with the TableBase object this.Binding(Base.Search()); } }