public List <clsctyprp> Find_Rec(Int32 ctycod) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("fndcty", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ctycod", ctycod); SqlDataReader dr = cmd.ExecuteReader(); List <clsctyprp> obj = new List <clsctyprp>(); if (dr.HasRows) { dr.Read(); clsctyprp k = new clsctyprp(); k.ctycod = Convert.ToInt32(dr[0]); k.ctynam = dr[1].ToString(); obj.Add(k); } dr.Close(); cmd.Dispose(); con.Close(); return(obj); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { nsgetwell.clscty obj = new nsgetwell.clscty(); nsgetwell.clsctyprp objprp = new nsgetwell.clsctyprp(); objprp.ctycod = Convert.ToInt32(GridView1.DataKeys [e.RowIndex][0]); obj.Delete_Rec(objprp); GridView1.DataBind(); e.Cancel = true; }
public void Delete_Rec(clsctyprp p) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("delcty", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ctycod", p.ctycod); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
protected void btnsub_Click(object sender, EventArgs e) { nsgetwell.clscty obj = new nsgetwell.clscty(); nsgetwell.clsctyprp objprp = new nsgetwell.clsctyprp(); objprp.ctynam = txtctynam.Text; if (btnsub.Text == "Submit") { obj.Save_Rec(objprp); } else { objprp.ctycod = Convert.ToInt32(ViewState["cod"]); obj.Update_Rec(objprp); btnsub.Text = "Submit"; } txtctynam.Text = String.Empty; GridView1.DataBind(); }
public List <clsctyprp> Disp_Rec() { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("dspcty", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = cmd.ExecuteReader(); List <clsctyprp> obj = new List <clsctyprp>(); while (dr.Read()) { clsctyprp k = new clsctyprp(); k.ctycod = Convert.ToInt32(dr[0]); k.ctynam = dr[1].ToString(); obj.Add(k); } dr.Close(); cmd.Dispose(); con.Close(); return(obj); }