protected void btn_delete_Click(object sender, EventArgs e) { try { LinkButton lnk = (LinkButton)sender; GridViewRow row = (GridViewRow)lnk.NamingContainer; Label l1 = (Label)row.FindControl("Lbl_id"); //SqlCommand cmd = new SqlCommand("batch_dlt_proc", con); //cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.AddWithValue("@action", "delete"); //cmd.Parameters.AddWithValue("@batch_id", l1.Text); //cmd.ExecuteNonQuery(); newbatchweb.newbatch obj = new newbatchweb.newbatch(); int a = obj.newbatchdelete(Convert.ToInt32(l1.Text)); if (a > 0) { gridshow(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "test", "alert('Data Deleted!!');", true); } } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void upd_btn_Click(object sender, EventArgs e) { con.Open(); newbatchweb.newbatch obj = new newbatchweb.newbatch(); int a = obj.newbatchupdate(Convert.ToInt32(Label_id.Text), batch_txt.Text); if (a > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "test", "alert('Data Updated!!');", true); gridshow(); blank(); } //SqlCommand cmd = new SqlCommand("batch_proc", con); //cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.AddWithValue("@action", "update"); //cmd.Parameters.AddWithValue("@batch_id", Label_id.Text); //cmd.Parameters.AddWithValue("@batch", batch_txt.Text); //cmd.ExecuteNonQuery(); con.Close(); upd_btn.Visible = false; submit_btn.Visible = true; }
protected void submit_btn_Click(object sender, EventArgs e) { con.Open(); SqlCommand cmd1 = new SqlCommand("batch_proc", con); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@action", "exist"); cmd1.Parameters.AddWithValue("@batch_id", ""); cmd1.Parameters.AddWithValue("@batch", batch_txt.Text); SqlDataReader dr = cmd1.ExecuteReader(); if (dr.Read()) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "test", "alert('Record Exist Already!!!!');", true); dr.Close(); } else { dr.Close(); //SqlCommand cmd = new SqlCommand("batch_proc", con); //cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.AddWithValue("@action", "insert"); //cmd.Parameters.AddWithValue("@batch_id", ""); //cmd.Parameters.AddWithValue("@batch", batch_txt.Text); //cmd.ExecuteNonQuery(); newbatchweb.newbatch obj = new newbatchweb.newbatch(); int a = obj.newbatchinsert(batch_txt.Text); if (a > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "test", "alert('Data Submitted!!!!');", true); gridshow(); blank(); } } con.Close(); }
public void gridshow() { newbatchweb.newbatch obj = new newbatchweb.newbatch(); GridView1.DataSource = obj.newbatchshow(); GridView1.DataBind(); }