Пример #1
0
    private void BindGridExp()
    {
        adp = new SqlDataAdapter("select * from StudentExp where SID='" + txtSID.Text.ToString() + "' and Type='" + ddlSponExpType.SelectedValue.ToString() + "'", con);
        DataTable dt = new DataTable();

        adp.Fill(dt);
        GridSponExp.DataSource = dt;
        GridSponExp.DataBind();
    }
Пример #2
0
 protected void btnDelExp_Click(object sender, EventArgs e)
 {
     try
     {
         con.Close(); con.Open();
         cmd = new SqlCommand("delete from StudentExp where SID='" + GridSponExp.SelectedRow.Cells[1].Text.ToString() + "' and Type='" + GridSponExp.SelectedRow.Cells[2].Text.ToString() + "'  and Organization='" + GridSponExp.SelectedRow.Cells[3].Text.ToString() + "' and Designation='" + GridSponExp.SelectedRow.Cells[4].Text.ToString() + "' and Location='" + GridSponExp.SelectedRow.Cells[6].Text.ToString() + "'", con);
         cmd.ExecuteNonQuery();
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('Data Deleted SuccessFully!')", true);
         BindGridExp(); clear2(); GridSponExp.Focus();
         con.Close(); con.Dispose();
     }
     catch (ArgumentOutOfRangeException ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('" + ex.ToString() + "')", true);
     }
     catch (NullReferenceException ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('" + ex.ToString() + "')", true);
     }
 }
Пример #3
0
 protected void btnUpdateDetails_Click(object sender, EventArgs e)
 {
     try
     {
         con.Close(); con.Open();
         cmd = new SqlCommand("update StudentExp set SID=@SID,Type=@Type,Organization=@Organization,Designation=@Designation,Year=@Year,Location=@Location where SID='" + GridSponExp.SelectedRow.Cells[1].Text.ToString() + "' and Type='" + GridSponExp.SelectedRow.Cells[2].Text.ToString() + "'  and Organization='" + GridSponExp.SelectedRow.Cells[3].Text.ToString() + "' and Designation='" + GridSponExp.SelectedRow.Cells[4].Text.ToString() + "' and Location='" + GridSponExp.SelectedRow.Cells[6].Text.ToString() + "'", con);
         cmd.Parameters.AddWithValue("SID", txtSID.Text.ToString());
         cmd.Parameters.AddWithValue("Type", ddlSponExpType.SelectedValue.ToString());
         cmd.Parameters.AddWithValue("Organization", txtOrg.Text.ToString());
         cmd.Parameters.AddWithValue("Designation", txtDesig.Text.ToString());
         cmd.Parameters.AddWithValue("Year", txtYearExp.Text.ToString());
         cmd.Parameters.AddWithValue("Location", txtLocation.Text.ToString());
         cmd.ExecuteNonQuery();
         con.Close(); con.Open();
         cmd = new SqlCommand("update Student set ExpStatus=@ExpStatus where SID='" + GridSponExp.SelectedRow.Cells[1].Text.ToString() + "'", con);
         if (chkDoc.Checked == true)
         {
             cmd.Parameters.AddWithValue("@ExpStatus", "yes");
         }
         else
         {
             cmd.Parameters.AddWithValue("@ExpStatus", "no");
         }
         cmd.ExecuteNonQuery();
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('Data Updated SuccessFully!')", true);
         BindGridExp(); clear2(); GridSponExp.Focus();
         con.Close(); con.Dispose();
     }
     catch (ArgumentOutOfRangeException ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('Please Select Membership No')", true);
     }
     catch (NullReferenceException ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('" + ex.ToString() + "')", true);
     }
 }