public test Insert(test id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_TEST", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@firstName", id.firstName); cmd.Parameters.AddWithValue("@lastName", id.lastName); cmd.ExecuteReader(); con.Close(); con.Open(); cmd = new SqlCommand("SP_DMCS_GET_TEST", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@firstName", id.firstName); cmd.Parameters.AddWithValue("@lastName", id.lastName); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); id.id = rdr.GetInt32(0); } } catch (Exception ex) { id.SetColumnDefaults(); } finally { con.Close(); } return id; }
public test Insert_test_select(int ID) { test = test.Select(ID); Insert_firstName_txt.Text = Convert.ToString(test.firstName); Insert_lastName_txt.Text = Convert.ToString(test.lastName); return test; }
public test Delete_test_select(int ID) { test = test.Select(ID); Delete_id_txt_lbl.Text = Convert.ToString(test.id); Delete_firstName_txt_lbl.Text = Convert.ToString(test.firstName); Delete_lastName_txt_lbl.Text = Convert.ToString(test.lastName); return test; }
public test test_insert() { test.firstName = Insert_firstName_txt.Text; test.lastName = Insert_lastName_txt.Text; test = test.Insert(test); Insert_test_GridView.DataBind(); Update_test_GridView.DataBind(); Delete_test_GridView.DataBind(); return test; }
public test Select(int id) { test test = new test(); string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_TEST", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); if (!rdr.IsDBNull(0)) { test.id = rdr.GetInt32(0); } else { test.id = 0; } if (!rdr.IsDBNull(1)) { test.firstName = rdr.GetString(1); } else { test.firstName = " "; } if (!rdr.IsDBNull(2)) { test.lastName = rdr.GetString(2); } else { test.lastName = " "; } } else { test.SetColumnDefaults(); } } catch (Exception ex) { test.SetColumnDefaults(); return test; } finally { con.Close(); } return test; }
public Boolean Update(test id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_UPDATE_TEST", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", id.id); cmd.Parameters.AddWithValue("@firstName", id.firstName); cmd.Parameters.AddWithValue("@lastName", id.lastName); cmd.ExecuteReader(); con.Close(); return true; } catch (Exception ex) { return false; } finally { con.Close(); } }
public test test_update(int ID) { test = test.Select(ID); test.id = Convert.ToInt32(Update_id_txt.Text); test.firstName = Update_firstName_txt.Text; test.lastName = Update_lastName_txt.Text; test.Update(test); Insert_test_GridView.DataBind(); Update_test_GridView.DataBind(); Delete_test_GridView.DataBind(); return test; }
///////////////////////// //////////////////////// /////////////////////// ////////////////////// ///////////////////// //Update Tab Methods protected void Update_Select_Record(object sender, EventArgs e) { test = Update_test_select(Convert.ToInt32(Update_test_GridView.SelectedValue)); }
///////////////////////// //////////////////////// /////////////////////// ////////////////////// ///////////////////// //Insert Tab Methods protected void Insert_Select_Record(object sender, EventArgs e) { test = Insert_test_select(Convert.ToInt32(Insert_test_GridView.SelectedValue)); }
protected void UPDATE(object sender, EventArgs e) { test = test_update(Convert.ToInt32(Update_test_GridView.SelectedValue)); }
protected void INSERT(object sender, EventArgs e) { test = test_insert(); }