protected void Button3_Click(object sender, EventArgs e) { Label8.Text = ""; if (TextBox2.Equals("") || TextBox4.Equals("") || TextBox7.Equals("") || TextBox8.Equals("")) { //do nothing as either student or book has failed some criteria } else { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); con.Open(); String str3 = "select * from card_rules"; SqlCommand cmd3 = new SqlCommand(str3, con); cmd3.ExecuteNonQuery(); SqlDataAdapter da3 = new SqlDataAdapter(); da3.SelectCommand = cmd3; DataSet ds3 = new DataSet(); da3.Fill(ds3); int tl = Convert.ToInt32(ds3.Tables[0].Rows[0]["time_limit"].ToString()); int df = Convert.ToInt32(ds3.Tables[0].Rows[0]["daily_fine"].ToString()); String str2 = "SELECT CONVERT (date, SYSDATETIME())"; SqlCommand cmd2 = new SqlCommand(str2, con); cmd2.ExecuteNonQuery(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd2; DataSet ds = new DataSet(); da.Fill(ds); String issuedate = ds.Tables[0].Rows[0][0].ToString(); String str = "insert into issuebook values('" + TextBox1.Text + "','" + TextBox3.Text + "','" + TextBox8.Text + "','" + issuedate + "')"; SqlCommand cmd = new SqlCommand(str, con); //cmd.Parameters.AddWithValue("@accno", TextBox1.Text); //cmd.Parameters.AddWithValue("@id", TextBox3.Text); //cmd.Parameters.AddWithValue("@bname", TextBox8.Text); //cmd.Parameters.AddWithValue("@issuedate", issuedate); int i = cmd.ExecuteNonQuery(); if (i == 1) { Label8.Text = "Book with Accession No: " + TextBox1.Text + " assigned to " + TextBox3.Text + " and you have to return in " + tl + " days otherwise penalty per day: " + df + " Rupees"; } con.Close(); } }
protected override void OnPreRender(EventArgs e) { FirstName = Request.QueryString.Get("FirstName"); LastName = Request.QueryString.Get("LastName"); EmailAddress = Request.QueryString.Get("Email"); //MessageBox.Show("FN: " + FirstName); //MessageBox.Show("LN: " + LastName); //MessageBox.Show("EA: " + EmailAddress); TextBox1.Text = FirstName; TextBox2.Text = LastName; //TextBox3.Text = EmailAddress; if (!TextBox1.Text.Equals("") && !TextBox1.Text.Equals(null) && !TextBox2.Equals("") && !TextBox2.Equals(null)) { Button1_Click(this, null); } base.OnPreRender(e); }