This commit is contained in:
EggMan20339 2024-03-20 14:09:49 -04:00
parent 8d76048d27
commit 7ef9b9de87
7 changed files with 429 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="College2@sql.eggtech.net" uuid="2c5c5989-8863-4fcf-ba64-0ae21aeb66b5">
<driver-ref>sqlserver.jb</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
<jdbc-url>Server=sql.eggtech.net,1433;Database=College2</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="FinalProjectOfficialPharmacy@sql.eggtech.net" uuid="4e082a2e-f776-4996-9b80-441323bf5e1e">
<driver-ref>sqlserver.jb</driver-ref>
<synchronize>true</synchronize>
<configured-by-url>true</configured-by-url>
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
<jdbc-url>Server=sql.eggtech.net;Database=FinalProjectOfficialPharmacy;User Id=admin;Password=delirium-purveyor-overall-backboned-approval-amino;</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

177
CH78/Home.aspx Normal file
View File

@ -0,0 +1,177 @@
<%@ Page Language="C#" CodeBehind="Home.aspx.cs" Inherits="CH78.Home" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<link href="main2.css" rel="stylesheet"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" language="javascript">
function SelectAll(id)
{
//get reference of GridView control
var grid = document.getElementById("<%= gvStudent.ClientID %>");
//variable to contain the cell of the grid
var cell;
if (grid.rows.length > 0)
{
//loop starts from 1. rows[0] points to the header.
for (i=1; i<grid.rows.length; i++)
{
//get the reference of first column
cell = grid.rows[i].cells[0];
//loop according to the number of childNodes in the cell
for (j=0; j<cell.childNodes.length; j++)
{
//if childNode type is CheckBox
if (cell.childNodes[j].type == "checkbox")
{
//assign the status of the Select All checkbox to the cell checkbox within the grid
cell.childNodes[j].checked = document.getElementById(id).checked;
}
}
}
}
}
</script>
<title>Home</title>
</head>
<body>
<form id="frmHome" runat="server">
<table>
<tr>
<td style="width:15%" rowspan="3" valign="middle">
&nbsp;
<asp:HyperLink
ID="hplNew" runat="server" NavigateUrl="~/StudentEdit.aspx?ID=0">
New
Student
</asp:HyperLink>
</td>
<td colspan="2" style="height: 20px; width: 538px;">
<asp:Label ID="Label1" runat="server" Text="Search criteria" Font-Bold="True" Font-Size="Medium"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2" style="width: 538px">
<asp:Panel ID="pnlSearch" runat="server" Width="100%">
<table border="1" cellpadding="1" style="width: 100%; border-top-style: ridge; border-right-style: ridge; border-left-style: ridge; border-bottom-style: ridge;">
<tr>
<td style="width: 25%; height: 26px;">
Student ID:
</td>
<td style="border-style: ridge;" class="auto-style1">
<asp:TextBox ID="txtStudentID" runat="server" MaxLength="6"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 25%">
First Name:
</td>
<td style="border-style: ridge;" class="auto-style2">
<asp:TextBox ID="txtFName" runat="server" Width="80%"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 25%">
Last Name:
</td>
<td style="border-style: ridge;" class="auto-style2">
<asp:TextBox ID="txtLName" runat="server" Width="80%"></asp:TextBox>
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
<tr >
<td colspan="2" align="center" style="width: 700px">
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"/>
<asp:GridView AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" PageSize="2" CssClass="GridView" ID="gvStudent" OnSelectedIndexChanged="grdStudent_SelectedIndexChanged" runat="server" Width="100%">
<PagerSettings Mode="NextPreviousFirstLast" FirstPageText="Go To First Page" LastPageText="Go To Last Page" Position="Top" />
<Columns>
<asp:TemplateField HeaderText="Student ID">
<HeaderTemplate>
<asp:CheckBox ID="cbSelectAll" runat="server"/>
&nbsp;
<asp:LinkButton ID="lbtnDelete" runat="server" OnCommand="Delete_Click"
CommandName="lbtnDelete" CommandArgument='<%#Eval("Student_ID") %>'>
Delete
</asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkStudentID" runat="server" AutoPostBack="false"/>
<asp:Label ID="hidStudentID" runat="server" Text='<%#Eval("Student_ID") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FNAME" HeaderText="First Name" SortExpression="fname"/>
<asp:BoundField DataField="LNAME" HeaderText="Last Name" SortExpression="lname"/>
<asp:BoundField HeaderText="Cities" DataField="CITY" SortExpression="city"/>
<asp:BoundField DataField="CELL_PHONE" HeaderText="Phone" SortExpression="CELL_PHONE"/>
<asp:HyperLinkField DataNavigateUrlFields="Student_ID"
DataNavigateUrlFormatString="Display.aspx?ID={0} &type=view"
HeaderText="View" Text="View" runat="server" Target="_blank">
<HeaderStyle HorizontalAlign="Left"/>
</asp:HyperLinkField>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:LinkButton ID="lbtnEdit" runat="server"
OnCommand="lbtnEdit_Click" CommandName="lbtnEdit"
CommandArgument='<% # Eval("Student_IDs") %>'>
Edit
</asp:LinkButton>&nbsp;&nbsp;
<asp:ImageButton ID="imgDelete" runat="server" CommandArgument='<% # Eval("Student_ID") %>' OnCommand="Delete_Click"
CommandName="lbtnDelete" ImageUrl="~/images/delete.jpg" Height="30" Width="30"/>||
<asp:ImageButton ID="imgEdit" runat="server" CommandArgument='<% # Eval("Student_ID") %>' OnCommand="lbtnEdit_Click"
CommandName="lbtnEdit" ImageUrl="~/images/edit.jpg" Height="30" Width="30"/>
</ItemTemplate>
<ItemTemplate>
<asp:ImageButton ID="imgDelete" runat="server" CommandArgument='<% # Eval("Student_ID") %>' OnCommand="Delete_Click"
CommandName="lbtnDelete" ImageUrl="~/images/delete.jpg" Height="30" Width="30"/>||
<asp:ImageButton ID="imgEdit" runat="server" CommandArgument='<% # Eval("Student_ID") %>' OnCommand="lbtnEdit_Click"
CommandName="lbtnEdit" ImageUrl="~/images/edit.jpg" Height="30" Width="30"/>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left"/>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No Records Found Matching Your Search!
</EmptyDataTemplate>
</asp:GridView>
</td>
</tr>
<tr>
<td colspan="3" style="width: 100%">
&nbsp;
</td>
</tr>
</table>
</form>
</body>
</html>

201
CH78/Home.aspx.cs Normal file
View File

@ -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)
{
}
}
}