122 lines
3.0 KiB
C#
122 lines
3.0 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Windows.Forms;
|
|
using Traffic;
|
|
|
|
namespace Database3
|
|
{
|
|
public partial class frmEdit : Form
|
|
{
|
|
|
|
private frmSearch forminstance;
|
|
public frmEdit(frmSearch there)
|
|
{
|
|
InitializeComponent();
|
|
forminstance = there;
|
|
}
|
|
|
|
private void Form_Closing(object sender, FormClosingEventArgs e)
|
|
{
|
|
|
|
forminstance.btnSearch_Click(sender, e);
|
|
|
|
}
|
|
|
|
private void frmEdit_Load(object sender, EventArgs e)
|
|
{
|
|
// txtStuID.Text = frmSearch.myID;
|
|
|
|
try
|
|
{
|
|
|
|
|
|
DataSet ds = new DataSet();
|
|
StudentDataTier stuDT = new StudentDataTier();
|
|
|
|
ds = stuDT.GetStudents(frmSearch.myID.ToString());
|
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
|
|
txtStuID.Text = ds.Tables[0].Rows[0]["student_id"].ToString();
|
|
txtStuID.Enabled = false;
|
|
txtfname.Text = ds.Tables[0].Rows[0]["fname"].ToString();
|
|
txtlname.Text = ds.Tables[0].Rows[0]["lname"].ToString();
|
|
|
|
}
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
// Do Nothing
|
|
}
|
|
|
|
}
|
|
|
|
private void btnUpdate_Click(object sender, EventArgs e)
|
|
{
|
|
string studid = "";
|
|
string firstname = "";
|
|
string lastname = "";
|
|
DateTime dob = new DateTime(1/1/1111);
|
|
decimal acctbal = 0;
|
|
string gender = "";
|
|
decimal credits = 0;
|
|
string state = "";
|
|
|
|
try
|
|
{
|
|
DataSet ds = new DataSet();
|
|
StudentDataTier stuDT = new StudentDataTier();
|
|
|
|
studid = txtStuID.Text.Trim();
|
|
firstname = txtfname.Text.Trim();
|
|
lastname = txtlname.Text.Trim();
|
|
try
|
|
{
|
|
dob = DateTime.Parse(txtDOB.Text.Trim());
|
|
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
}
|
|
|
|
try
|
|
{
|
|
acctbal = decimal.Parse(txtSalary.Text.Trim());
|
|
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
}
|
|
|
|
|
|
|
|
gender = cboGender.Text.Trim();
|
|
if (gender != "MALE" && gender != "FEMALE")
|
|
{
|
|
|
|
gender = "NA";
|
|
|
|
}
|
|
try
|
|
{
|
|
|
|
credits = decimal.Parse(txtCredits.Text.Trim());
|
|
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
}
|
|
state = cboState.Text.Trim();
|
|
|
|
stuDT.UpdateStudent(studid, firstname, lastname, dob, acctbal, gender, credits, state);
|
|
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
} |