Skip to content

Instantly share code, notes, and snippets.

Created May 11, 2011 21:02
Show Gist options
  • Save anonymous/967347 to your computer and use it in GitHub Desktop.
Save anonymous/967347 to your computer and use it in GitHub Desktop.
n00b asp.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace PIF
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
String fname = (string)(Session["fname"]);
String lname = (string)(Session["lname"]);
String email = (string)(Session["email"]);
String PID="";
using (SqlConnection connection = new SqlConnection("Data Source=ofapif.db.2938559.hostedresource.com; Initial Catalog=ofapif; User ID=username; Password=password"))
{
connection.Open();
String request = "Select P_Id FROM pifTable WHERE GIFname=@fname AND GILname=@lname AND PCemail=@email";
SqlCommand requestQuery = new SqlCommand(request, connection);
requestQuery.Parameters.Add("fname", SqlDbType.VarChar, 50);
requestQuery.Parameters.Add("lname", SqlDbType.VarChar, 50);
requestQuery.Parameters.Add("email", SqlDbType.VarChar, 50);
requestQuery.Parameters[0].Value = fname;
requestQuery.Parameters[1].Value = lname;
requestQuery.Parameters[2].Value = email;
requestQuery.Prepare();
requestQuery.ExecuteNonQuery();
SqlDataReader reader = requestQuery.ExecuteReader();
while (reader.Read())
{
PID = Convert.ToString(reader.GetString(0));
}
reader.Close();
String query = "INSERT INTO pifTable2 (P_Id,Gender,Birthdate,Age,HeightFeet,HeightInches,Weight,ShoeSize,Disability,DiagnosisYear,SeizureHistory,SeizureTypeGM,SeizureTypePM,SeizureTypeOT,SeizureRecent,SeizureIndicators,SpinalInjC1T1,SpinalInjT1T6,SpinalInjT7T12,SpinalInjL1L5,SpinalInjS1S5,SpinalInjInc,SpinalInjComp,BathAssist,BathExpl,MobilityWI,MobilityAD,MobilityMW,MobilityPWC,Transferable) VALUES (@pid,@gender,@birthdate,@age,@heightfeet,@heightinches,@weight,@shoesize,@primarydisability,@diagnosisyear, @seizurehistory,@seizuretypegm,@seizuretypepm,@seizuretypeot,@seizurerecent,@seizureindicators,@SpinalInjC1T1, @SpinalInjT1T6,@SpinalInjT7T12,@SpinalInjL1L5,@SpinalInjS1S5,@SpinalInjInc,@SpinalInjComp,@bathassist,@bathexpl,@mobilitywi,@mobilityad,@mobilitymwc,@mobilitypwc,@transferable)";
SqlCommand update = new SqlCommand(query, connection);
update.Parameters.Add("gender", SqlDbType.VarChar, 50);
update.Parameters.Add("birthdate", SqlDbType.VarChar, 50);
update.Parameters.Add("age", SqlDbType.VarChar, 50);
update.Parameters.Add("heightfeet", SqlDbType.VarChar, 50);
update.Parameters.Add("heightinches", SqlDbType.VarChar, 50);
update.Parameters.Add("weight", SqlDbType.VarChar, 50);
update.Parameters.Add("shoesize", SqlDbType.VarChar, 50);
update.Parameters.Add("primarydisability", SqlDbType.VarChar, 50);
update.Parameters.Add("diagnosisyear", SqlDbType.VarChar, 50);
update.Parameters.Add("seizurehistory", SqlDbType.VarChar, 50);
update.Parameters.Add("seizuretypeGM", SqlDbType.VarChar, 50);
update.Parameters.Add("seizuretypePM", SqlDbType.VarChar, 50);
update.Parameters.Add("seizuretypeOT", SqlDbType.VarChar, 50);
update.Parameters.Add("seizurerecent", SqlDbType.VarChar, 50);
update.Parameters.Add("seizureindicators", SqlDbType.VarChar, 50);
update.Parameters.Add("spinalinjC1T1", SqlDbType.VarChar, 50);
update.Parameters.Add("spinalinjT1T6", SqlDbType.VarChar, 50);
update.Parameters.Add("spinalinjT7T12", SqlDbType.VarChar, 50);
update.Parameters.Add("spinalinjL1L5", SqlDbType.VarChar, 50);
update.Parameters.Add("spinalinjS1S5", SqlDbType.VarChar, 50);
update.Parameters.Add("spinalinjInc", SqlDbType.VarChar, 50);
update.Parameters.Add("spinalinjComp", SqlDbType.VarChar, 50);
update.Parameters.Add("bathassist", SqlDbType.VarChar, 50);
update.Parameters.Add("bathexpl", SqlDbType.VarChar, 50);
update.Parameters.Add("mobilitywi", SqlDbType.VarChar, 50);
update.Parameters.Add("mobilityad", SqlDbType.VarChar, 50);
update.Parameters.Add("mobilitymwc", SqlDbType.VarChar, 50);
update.Parameters.Add("mobilitypwc", SqlDbType.VarChar, 50);
update.Parameters.Add("transferable", SqlDbType.VarChar, 50);
update.Parameters.Add("pid", SqlDbType.VarChar, 50);
update.Parameters[0].Value = rdoGender.Text;
update.Parameters[1].Value = Calendar1.SelectedDate.ToString();
update.Parameters[2].Value = txtAge.Text;
update.Parameters[3].Value = ddlFeet.Text;
update.Parameters[4].Value = ddlInches.Text;
update.Parameters[5].Value = txtWeight.Text;
update.Parameters[6].Value = txtShoeSize.Text;
update.Parameters[7].Value = txtPrimaryDisability.Text;
update.Parameters[8].Value = ddlDiagnoseYear.Text;
update.Parameters[9].Value = rdoSeizureHist.Text;
update.Parameters[10].Value = cboGrandMal.Text;
update.Parameters[11].Value = cboPetiteMal.Text;
update.Parameters[12].Value = cboOtherType.Text;
update.Parameters[13].Value = rdoRecentSeizure.Text;
update.Parameters[14].Value = txtSeizureInd.Text;
update.Parameters[15].Value = cboC1T1.Checked;
update.Parameters[16].Value = cboT1T6.Checked;
update.Parameters[17].Value = cboT7T12.Checked;
update.Parameters[18].Value = cboL1L5.Checked;
update.Parameters[19].Value = cboS1S5.Checked;
update.Parameters[20].Value = cboComplete.Checked;
update.Parameters[21].Value = cboIncomplete.Checked;
update.Parameters[22].Value = rdoBathAssist.Text;
update.Parameters[23].Value = txtBathAssist.Text;
update.Parameters[24].Value = cboMobilityWI.Checked;
update.Parameters[25].Value = cboMobilityAD.Checked;
update.Parameters[26].Value = cboMobilityMWC.Checked;
update.Parameters[27].Value = cboMobilityPWC.Checked;
update.Parameters[28].Value = rdoTransfer.Text;
update.Parameters[29].Value = PID;
update.Prepare();
update.ExecuteNonQuery();
}
Response.Redirect("WebForm3.aspx");
}
protected void rdoOtherType_CheckedChanged(object sender, EventArgs e)
{
/*lblOtherType.Visible = true;
txtOtherType.Visible = true;
UpdatePanel2.Update();
txtOtherType.Focus();*/
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment