From 7ef9b9de87fc2e76f47bd920995cf9de26c2f95d Mon Sep 17 00:00:00 2001
From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com>
Date: Wed, 20 Mar 2024 14:09:49 -0400
Subject: [PATCH] init
---
.../.idea/.gitignore | 13 ++
.../.idea/dataSources.xml | 20 ++
.../.idea/encodings.xml | 4 +
.../.idea/indexLayout.xml | 8 +
.../.idea.CNSA-216-Personal-v2/.idea/vcs.xml | 6 +
CH78/Home.aspx | 177 +++++++++++++++
CH78/Home.aspx.cs | 201 ++++++++++++++++++
7 files changed, 429 insertions(+)
create mode 100644 .idea/.idea.CNSA-216-Personal-v2/.idea/.gitignore
create mode 100644 .idea/.idea.CNSA-216-Personal-v2/.idea/dataSources.xml
create mode 100644 .idea/.idea.CNSA-216-Personal-v2/.idea/encodings.xml
create mode 100644 .idea/.idea.CNSA-216-Personal-v2/.idea/indexLayout.xml
create mode 100644 .idea/.idea.CNSA-216-Personal-v2/.idea/vcs.xml
create mode 100644 CH78/Home.aspx
create mode 100644 CH78/Home.aspx.cs
diff --git a/.idea/.idea.CNSA-216-Personal-v2/.idea/.gitignore b/.idea/.idea.CNSA-216-Personal-v2/.idea/.gitignore
new file mode 100644
index 0000000..a39e85f
--- /dev/null
+++ b/.idea/.idea.CNSA-216-Personal-v2/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/modules.xml
+/contentModel.xml
+/projectSettingsUpdater.xml
+/.idea.CNSA-216-Personal-v2.iml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/.idea.CNSA-216-Personal-v2/.idea/dataSources.xml b/.idea/.idea.CNSA-216-Personal-v2/.idea/dataSources.xml
new file mode 100644
index 0000000..28afd0c
--- /dev/null
+++ b/.idea/.idea.CNSA-216-Personal-v2/.idea/dataSources.xml
@@ -0,0 +1,20 @@
+
+
+
+
+ sqlserver.jb
+ true
+ com.jetbrains.jdbc.sqlserver.SqlServerDriver
+ Server=sql.eggtech.net,1433;Database=College2
+ $ProjectFileDir$
+
+
+ sqlserver.jb
+ true
+ true
+ com.jetbrains.jdbc.sqlserver.SqlServerDriver
+ Server=sql.eggtech.net;Database=FinalProjectOfficialPharmacy;User Id=admin;Password=delirium-purveyor-overall-backboned-approval-amino;
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.CNSA-216-Personal-v2/.idea/encodings.xml b/.idea/.idea.CNSA-216-Personal-v2/.idea/encodings.xml
new file mode 100644
index 0000000..df87cf9
--- /dev/null
+++ b/.idea/.idea.CNSA-216-Personal-v2/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.CNSA-216-Personal-v2/.idea/indexLayout.xml b/.idea/.idea.CNSA-216-Personal-v2/.idea/indexLayout.xml
new file mode 100644
index 0000000..7b08163
--- /dev/null
+++ b/.idea/.idea.CNSA-216-Personal-v2/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.CNSA-216-Personal-v2/.idea/vcs.xml b/.idea/.idea.CNSA-216-Personal-v2/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/.idea.CNSA-216-Personal-v2/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CH78/Home.aspx b/CH78/Home.aspx
new file mode 100644
index 0000000..998500e
--- /dev/null
+++ b/CH78/Home.aspx
@@ -0,0 +1,177 @@
+<%@ Page Language="C#" CodeBehind="Home.aspx.cs" Inherits="CH78.Home" %>
+
+
+
+
+
+
+
+
+
+
+ Home
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CH78/Home.aspx.cs b/CH78/Home.aspx.cs
new file mode 100644
index 0000000..39f40c0
--- /dev/null
+++ b/CH78/Home.aspx.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Data;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace CH78
+{
+ public partial class Home : Page
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+
+ Page.ClientScript.RegisterClientScriptInclude("Test", "MyScript.js");
+
+// Page.
+ gvStudent.RowDataBound += new GridViewRowEventHandler(grdStudent_RowDataBound); //row databound event
+ gvStudent.PageIndexChanging += new GridViewPageEventHandler(grdStudent_PageIndexChanging);
+ gvStudent.Sorting += new GridViewSortEventHandler(grdStudent_Sorting);
+
+ if (!IsPostBack)
+ {
+
+ }
+
+
+ }
+
+ private void grdStudent_Sorting(object sender, GridViewSortEventArgs e)
+ {
+ SortRecords(e.SortExpression);
+ }
+
+ public string sortDir
+ {
+ get => (string)ViewState["sortDir"];
+ set => ViewState["sortDir"] = value;
+ }
+
+ private void SortRecords(string sortExpress)
+ {
+ string oldExpression = gvStudent.SortExpression;
+ String newExpression = sortExpress;
+ String lastValue, theSortField;
+ String sortExpression;
+ DataView source;
+ String theDirection;
+
+ string oldSortExp, newSortExp;
+
+ string wildChar;
+ theDirection = " ";
+ wildChar = " %";
+
+ lastValue = (string) ViewState["sortValue"];
+ sortExpression = sortExpress;
+
+ oldSortExp = (string)ViewState["oldSortExpression"];
+
+ //get the last sort field and the new sort field
+ // if (oldSortExp != sortExpression) //check for new expression, that is DB field
+ // {
+ if (this.sortDir == "desc")
+ {
+ this.sortDir = "asc";
+ }
+ else if (this.sortDir == null)
+ {
+ this.sortDir = "asc";
+ }
+ else if (this.sortDir == "asc")
+ {
+ this.sortDir = "desc";
+ }
+ else //sort in ascending order the first time, column may not change if already sorted that way
+ {
+ this.sortDir = "asc";
+ }
+ theSortField = (string)ViewState["sortField"];
+
+ source = (DataView)Cache["StudentData"]; // use the cache
+
+ source.Sort = (" " + sortExpression + " " + this.sortDir);
+
+ ViewState["oldSortExpression"] = sortExpress; // save the sort as old sort
+
+ gvStudent.DataSource = source;
+ gvStudent.DataBind();
+ // }
+
+ }
+
+ private void grdStudent_PageIndexChanging(object sender, GridViewPageEventArgs e)
+ {
+
+ Int32 pageNum = 0;
+ pageNum = e.NewPageIndex;
+ if (txtStudentID.Text.Trim().Length > 0 || txtFName.Text.Trim().Length > 0 || txtLName.Text.Trim().Length > 0)
+ {
+ textHasValues = true;
+ }
+ Paging(pageNum);
+
+
+ }
+
+ private void Paging(Int32 page)
+ {
+ gvStudent.PageIndex = page;
+ BindData();
+ }
+
+ private void BindData()
+ {
+
+ DataSet ds = new DataSet();
+
+ string stuID = Convert.ToString(Session["vStuID"]);
+ string LNAME = Convert.ToString(Session["vLNAME"]);
+ string FNAME = Convert.ToString(Session["vFNAME"]);
+
+ txtStudentID.Text = stuID;
+ txtFName.Text = FNAME;
+ txtLName.Text = LNAME;
+
+ if (textHasValues)
+ {
+ ds = StudentDataTier.SearchStudents(FNAME, LNAME, stuID);
+ }
+
+
+ // ds = dt.GetStudents();
+ gvStudent.DataSource = ds.Tables[0];
+
+ if (Cache["StudentData"] == null)
+ {
+ Cache.Add("StudentData", new DataView(ds.Tables[0]),
+ null,System.Web.Caching.Cache.NoAbsoluteExpiration,
+ System.TimeSpan.FromMinutes(10), System.Web.Caching.CacheItemPriority.Default,
+ null);
+ }
+ gvStudent.DataBind();
+
+ }
+
+ protected void grdStudent_RowDataBound(Object sender, GridViewRowEventArgs e)
+ {
+ if (e.Row.RowType == DataControlRowType.Header) // header add click event to select checkboxes
+ {
+ ((CheckBox)e.Row.FindControl("cbSelectAll")).Attributes.Add("onclick", "javascript:SelectAll('" + ((CheckBox)e.Row.FindControl("cbSelectAll")).ClientID + "')");
+ }
+ }
+
+ private bool textHasValues = false;
+ protected void btnSearch_Click(object sender, EventArgs e)
+ {
+
+ if (txtStudentID.Text.Trim().Length > 0 || txtFName.Text.Trim().Length > 0 || txtLName.Text.Trim().Length > 0)
+ {
+
+
+ try
+ {
+
+ Session["vStuID"] = txtStudentID.Text.Trim();
+ Session["vFNAME"] = txtFName.Text.Trim();
+ Session["vLNAME"] = txtLName.Text.Trim();
+
+ Cache.Remove("StudentData");
+ textHasValues = true;
+ BindData();
+
+
+
+ }
+ catch (Exception exception)
+ {
+
+
+
+ }
+
+ }
+
+ }
+
+ protected void grdStudent_SelectedIndexChanged(object sender, EventArgs e)
+ {
+
+ }
+
+ protected void Delete_Click(object sender, CommandEventArgs e)
+ {
+
+ }
+
+ protected void lbtnEdit_Click(object sender, CommandEventArgs e)
+ {
+
+ }
+ }
+}
\ No newline at end of file