2024-03-20 14:09:42 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Web.UI;
|
2024-03-20 15:33:54 -04:00
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
2024-03-25 12:09:20 -04:00
|
|
|
|
using System.Security.Principal;
|
2024-03-20 14:09:42 -04:00
|
|
|
|
|
|
|
|
|
namespace CH78
|
|
|
|
|
{
|
|
|
|
|
public partial class Display : Page
|
|
|
|
|
{
|
2024-03-25 12:09:20 -04:00
|
|
|
|
protected string pageType;
|
2024-03-20 14:09:42 -04:00
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-03-20 15:33:54 -04:00
|
|
|
|
string studentID = "";
|
|
|
|
|
string gender;
|
2024-03-20 14:09:42 -04:00
|
|
|
|
|
2024-03-26 20:22:41 -04:00
|
|
|
|
string id = StudentDataTier.DecryptQueryString(Request.QueryString["ID"], "CNSAcnsa1", "salty");
|
|
|
|
|
|
2024-03-20 15:33:54 -04:00
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
2024-03-25 12:09:20 -04:00
|
|
|
|
pageType = Request.QueryString["type"].Trim().ToUpper();
|
|
|
|
|
|
2024-03-20 15:33:54 -04:00
|
|
|
|
// retrieve the querystring
|
2024-03-26 20:22:41 -04:00
|
|
|
|
if (String.IsNullOrEmpty(id))
|
2024-03-20 15:33:54 -04:00
|
|
|
|
{
|
|
|
|
|
// not the right entry point
|
|
|
|
|
Response.Redirect("Home.aspx");
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-26 20:22:41 -04:00
|
|
|
|
else if (id.ToUpper() == "NEW")
|
2024-03-20 15:33:54 -04:00
|
|
|
|
{
|
2024-03-25 12:09:20 -04:00
|
|
|
|
BindDDL();
|
2024-03-20 15:33:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (Request.QueryString["type"].Trim().ToUpper() == "VIEW") // display
|
|
|
|
|
{
|
2024-03-26 20:22:41 -04:00
|
|
|
|
GetStudent(id, Request.QueryString["type"].Trim().ToUpper());
|
2024-03-20 15:33:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (Request.QueryString["type"].Trim().ToUpper() == "EDIT") // edit
|
|
|
|
|
{
|
2024-03-26 20:22:41 -04:00
|
|
|
|
GetStudent(id, Request.QueryString["type"].Trim().ToUpper());
|
2024-03-20 15:33:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else // anything else
|
|
|
|
|
{
|
|
|
|
|
Response.Redirect("Home.aspx");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GetStudent(string studentid, string type)
|
|
|
|
|
{
|
|
|
|
|
// the right record
|
2024-03-21 14:09:34 -04:00
|
|
|
|
|
2024-03-20 15:33:54 -04:00
|
|
|
|
DataSet ds = new DataSet();
|
|
|
|
|
string gender;
|
|
|
|
|
ds = StudentDataTier.SearchStudents("","",studentid);
|
|
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
txtStuID.Text = ds.Tables[0].Rows[0]["student_id"].ToString();
|
|
|
|
|
txtFNAME.Text = ds.Tables[0].Rows[0]["fname"].ToString();
|
|
|
|
|
txtLNAME.Text = ds.Tables[0].Rows[0]["lname"].ToString();
|
2024-03-21 19:26:58 -04:00
|
|
|
|
txtMidInit.Text = ds.Tables[0].Rows[0]["midinit"].ToString();
|
|
|
|
|
txtDOB.Text = ds.Tables[0].Rows[0]["DOB"].ToString();
|
|
|
|
|
txtActBal.Text = ds.Tables[0].Rows[0]["ACCT_BAL"].ToString();
|
|
|
|
|
txtMajor.Text = ds.Tables[0].Rows[0]["MAJOR"].ToString();
|
|
|
|
|
txtCellPhone.Text = ds.Tables[0].Rows[0]["CELL_PHONE"].ToString();
|
|
|
|
|
txtAdr1.Text = ds.Tables[0].Rows[0]["ADDRESS_ONE"].ToString();
|
|
|
|
|
txtCity.Text = ds.Tables[0].Rows[0]["CITY"].ToString();
|
|
|
|
|
txtZip.Text = ds.Tables[0].Rows[0]["ZIP"].ToString();
|
|
|
|
|
txtCreds.Text = ds.Tables[0].Rows[0]["TOTALCREDITS"].ToString();
|
2024-03-20 15:33:54 -04:00
|
|
|
|
// TODO complete other fields
|
|
|
|
|
|
2024-03-21 14:09:34 -04:00
|
|
|
|
gender = ds.Tables[0].Rows[0]["GENDER"].ToString().Trim();
|
|
|
|
|
// if (gender.ToUpper() == "F")
|
|
|
|
|
// {
|
|
|
|
|
// txtGender.SelectedItem.Text = "FEMALE";
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// txtGender.SelectedItem.Text = "MALE";
|
|
|
|
|
// }
|
2024-03-20 15:33:54 -04:00
|
|
|
|
|
|
|
|
|
txtGender.Enabled = false;
|
|
|
|
|
//mysalary = Decimal.Parse(ds.Tables[0].Rows[0]["salary"])
|
|
|
|
|
//txtSalary.Text = mysalary.ToString("C")
|
|
|
|
|
//txtSalary.Enabled = False
|
|
|
|
|
|
2024-03-25 12:09:20 -04:00
|
|
|
|
BindDDL();
|
2024-03-21 19:26:58 -04:00
|
|
|
|
|
2024-03-21 14:09:34 -04:00
|
|
|
|
// txtState.SelectedValue = ds.Tables[0].Rows[0]["state"].ToString();
|
2024-03-20 15:33:54 -04:00
|
|
|
|
if (type.ToUpper() == "VIEW")
|
|
|
|
|
{
|
|
|
|
|
txtStuID.Enabled = false;
|
|
|
|
|
txtFNAME.Enabled = false;
|
|
|
|
|
txtLNAME.Enabled = false;
|
|
|
|
|
btnGoStu.Visible = false;
|
|
|
|
|
btnCancelStu.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
else if (type.ToUpper() == "EDIT")
|
|
|
|
|
{
|
2024-03-25 12:09:20 -04:00
|
|
|
|
txtGender.Enabled = true;
|
|
|
|
|
txtStuID.Enabled = false;
|
|
|
|
|
btnGoStu.Visible = true;
|
|
|
|
|
btnCancelStu.Visible = true;
|
|
|
|
|
btnGoStu.Text = "UPDATE";
|
|
|
|
|
btnCancelStu.Text = "REFRESH";
|
|
|
|
|
btnGoStu.ForeColor = Color.Red;
|
|
|
|
|
btnCancelStu.ForeColor = Color.Blue;
|
|
|
|
|
}
|
|
|
|
|
else if (type.ToUpper() == "NEW")
|
|
|
|
|
{
|
|
|
|
|
txtGender.Enabled = true;
|
2024-03-20 15:33:54 -04:00
|
|
|
|
txtStuID.Enabled = false;
|
|
|
|
|
btnGoStu.Visible = true;
|
|
|
|
|
btnCancelStu.Visible = true;
|
|
|
|
|
btnGoStu.Text = "UPDATE";
|
|
|
|
|
btnCancelStu.Text = "REFRESH";
|
|
|
|
|
btnGoStu.ForeColor = Color.Red;
|
|
|
|
|
btnCancelStu.ForeColor = Color.Blue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-20 14:09:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-25 12:09:20 -04:00
|
|
|
|
protected void BindDDL()
|
|
|
|
|
{
|
|
|
|
|
txtState.DataSource = StudentDataTier.GetStates();
|
|
|
|
|
txtState.DataTextField = "Name";
|
|
|
|
|
txtState.DataValueField = "StateID";
|
|
|
|
|
txtState.SelectedValue = "1";
|
|
|
|
|
txtState.DataBind();
|
|
|
|
|
|
|
|
|
|
txtGender.DataSource = StudentDataTier.GetGenders();
|
|
|
|
|
txtGender.DataTextField = "CommonName";
|
|
|
|
|
txtGender.DataValueField = "Gender_ID";
|
|
|
|
|
txtGender.SelectedValue = "0";
|
|
|
|
|
txtGender.DataBind();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-20 14:09:42 -04:00
|
|
|
|
protected void btnCancelStu_OnClick(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-03-26 20:22:41 -04:00
|
|
|
|
System.Text.StringBuilder cb = new System.Text.StringBuilder();
|
|
|
|
|
cb.Append(" opener.location.href = 'home.aspx';");
|
|
|
|
|
cb.Append("var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;");
|
|
|
|
|
cb.Append(" if (ie7)");
|
|
|
|
|
cb.Append(" { ");
|
|
|
|
|
cb.Append("window.open('','_parent','');");
|
|
|
|
|
cb.Append("window.close();");
|
|
|
|
|
cb.Append(" }");
|
|
|
|
|
cb.Append(" else ");
|
|
|
|
|
cb.Append(" { ");
|
|
|
|
|
cb.Append(" this.focus();");
|
|
|
|
|
cb.Append(" self.opener = this;");
|
|
|
|
|
cb.Append(" self.close();");
|
|
|
|
|
cb.Append(" }");
|
|
|
|
|
ClientScript.RegisterClientScriptBlock(this.GetType(), "CloseReloadScript", cb.ToString(), true);
|
2024-03-20 14:09:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void btnGoStu_OnClick(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-03-25 12:09:20 -04:00
|
|
|
|
|
|
|
|
|
if (Request.QueryString["type"].Trim().ToUpper() == "VIEW")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else if (Request.QueryString["type"].Trim().ToUpper() == "EDIT")
|
2024-03-26 20:22:41 -04:00
|
|
|
|
{
|
|
|
|
|
Decimal acct_bal = 0;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
acct_bal = decimal.Parse(txtActBal.Text);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Decimal creds = 0;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
creds = decimal.Parse(txtCreds.Text);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DateTime date = new DateTime(3000, 1, 1);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
date = DateTime.Parse(txtDOB.Text);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StudentDataTier.UpdateStudents(0,
|
|
|
|
|
txtStuID.Text,
|
|
|
|
|
txtFNAME.Text,
|
|
|
|
|
txtLNAME.Text,
|
|
|
|
|
txtMidInit.Text,
|
|
|
|
|
date,
|
|
|
|
|
txtGender.Text,
|
|
|
|
|
acct_bal,
|
2024-03-25 12:09:20 -04:00
|
|
|
|
txtMajor.Text, txtCellPhone.Text,
|
|
|
|
|
txtAdr1.Text,
|
|
|
|
|
txtCity.Text,
|
|
|
|
|
txtState.ToString(),
|
|
|
|
|
txtZip.Text,
|
2024-03-26 20:22:41 -04:00
|
|
|
|
creds);
|
2024-03-25 12:09:20 -04:00
|
|
|
|
}
|
|
|
|
|
else if (Request.QueryString["type"].Trim().ToUpper() == "NEW")
|
2024-03-26 20:22:41 -04:00
|
|
|
|
{
|
|
|
|
|
Decimal acct_bal = 0;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
acct_bal = decimal.Parse(txtActBal.Text);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Decimal creds = 0;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
creds = decimal.Parse(txtCreds.Text);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DateTime date = new DateTime(3000, 1, 1);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
date = DateTime.Parse(txtDOB.Text);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StudentDataTier.UpdateStudents(1,
|
2024-03-25 12:09:20 -04:00
|
|
|
|
txtStuID.Text,
|
|
|
|
|
txtFNAME.Text,
|
|
|
|
|
txtLNAME.Text,
|
|
|
|
|
txtMidInit.Text,
|
2024-03-26 20:22:41 -04:00
|
|
|
|
date,
|
2024-03-25 12:09:20 -04:00
|
|
|
|
txtGender.Text.ToString(),
|
2024-03-26 20:22:41 -04:00
|
|
|
|
acct_bal,
|
2024-03-25 12:09:20 -04:00
|
|
|
|
txtMajor.Text, txtCellPhone.Text,
|
|
|
|
|
txtAdr1.Text,
|
|
|
|
|
txtCity.Text,
|
|
|
|
|
txtState.Text.ToString(),
|
|
|
|
|
txtZip.Text,
|
2024-03-26 20:22:41 -04:00
|
|
|
|
creds);
|
2024-03-25 12:09:20 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-20 14:09:42 -04:00
|
|
|
|
}
|
2024-03-25 12:09:20 -04:00
|
|
|
|
|
2024-03-20 14:09:42 -04:00
|
|
|
|
}
|
|
|
|
|
}
|