public Resource Insert_Resource_select(int ID) { Resource = Resource.Select(ID); Insert_Resource_Type_ID_txt.Text = Convert.ToString(Resource.Resource_Type_ID); Insert_Description_txt.Text = Convert.ToString(Resource.Description); Insert_Address_txt.Text = Convert.ToString(Resource.Address); Insert_City_txt.Text = Convert.ToString(Resource.City); Insert_State_txt.Text = Convert.ToString(Resource.State); Insert_Zip Code_txt.Text = Convert.ToString(Resource.Zip Code); Insert_PayType_txt.Text = Convert.ToString(Resource.PayType); Insert_PayRate_txt.Text = Convert.ToString(Resource.PayRate); Insert_AvailabilityDate_txt.Text = Convert.ToString(Resource.AvailabilityDate); Insert_AvailabilityHours_txt.Text = Convert.ToString(Resource.AvailabilityHours); return Resource; }
public Resource Resource_insert() { Resource.Resource_Type_ID = Convert.ToInt32(Insert_Resource_Type_ID_txt.Text); Resource.Description = Insert_Description_txt.Text; Resource.Address = Insert_Address_txt.Text; Resource.City = Insert_City_txt.Text; Resource.State = Insert_State_txt.Text; Resource.Zip Code = Insert_Zip Code_txt.Text; Resource.PayType = Insert_PayType_txt.Text; Resource.PayRate = Convert.ToDecimal(Insert_PayRate_txt.Text); Resource.AvailabilityDate = Convert.ToDateTime(Insert_AvailabilityDate_txt.Text); Resource.AvailabilityHours = Convert.ToDateTime(Insert_AvailabilityHours_txt.Text); Resource = Resource.Insert(Resource); Insert_Resource_GridView.DataBind(); Update_Resource_GridView.DataBind(); Delete_Resource_GridView.DataBind(); return Resource; }
///////////////////////// //////////////////////// /////////////////////// ////////////////////// ///////////////////// //Update Tab Methods protected void Update_Select_Record(object sender, EventArgs e) { Resource = Update_Resource_select(Convert.ToInt32(Update_Resource_GridView.SelectedValue)); }
protected void INSERT(object sender, EventArgs e) { Resource = Resource_insert(); }
protected void UPDATE(object sender, EventArgs e) { Resource = Resource_update(Convert.ToInt32(Update_Resource_GridView.SelectedValue)); }
public Resource Resource_update(int ID) { Resource = Resource.Select(ID); Resource.Resource_ID = Convert.ToInt32(Update_Resource_ID_txt.Text); Resource.Resource_Type_ID = Convert.ToInt32(Update_Resource_Type_ID_txt.Text); Resource.Description = Update_Description_txt.Text; Resource.Address = Update_Address_txt.Text; Resource.City = Update_City_txt.Text; Resource.State = Update_State_txt.Text; Resource.Zip Code = Update_Zip Code_txt.Text; Resource.PayType = Update_PayType_txt.Text; Resource.PayRate = Convert.ToDecimal(Update_PayRate_txt.Text); Resource.AvailabilityDate = Convert.ToDateTime(Update_AvailabilityDate_txt.Text); Resource.AvailabilityHours = Convert.ToDateTime(Update_AvailabilityHours_txt.Text); Resource.Update(Resource); Insert_Resource_GridView.DataBind(); Update_Resource_GridView.DataBind(); Delete_Resource_GridView.DataBind(); return Resource; }
public Resource Select(int id) { Resource Resource = new Resource(); string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_RESOURCE", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Resource_ID", id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); if (!rdr.IsDBNull(0)) { Resource.Resource_ID = rdr.GetInt32(0); } else { Resource.Resource_ID = 0; } if (!rdr.IsDBNull(1)) { Resource.Resource_Type_ID = rdr.GetInt32(1); } else { Resource.Resource_Type_ID = 0; } if (!rdr.IsDBNull(2)) { Resource.Description = rdr.GetString(2); } else { Resource.Description = " "; } if (!rdr.IsDBNull(3)) { Resource.Address = rdr.GetString(3); } else { Resource.Address = " "; } if (!rdr.IsDBNull(4)) { Resource.City = rdr.GetString(4); } else { Resource.City = " "; } if (!rdr.IsDBNull(5)) { Resource.State = rdr.GetString(5); } else { Resource.State = " "; } if (!rdr.IsDBNull(6)) { Resource.Zip Code = rdr.GetString(6); } else { Resource.Zip Code = " "; } if (!rdr.IsDBNull(7)) { Resource.PayType = rdr.GetString(7); } else { Resource.PayType = " "; } if (!rdr.IsDBNull(8)) { Resource.PayRate = rdr.GetDecimal(8); } else { Resource.PayRate = 0; } if (!rdr.IsDBNull(9)) { Resource.AvailabilityDate = rdr.GetDateTime(9); } else { Resource.AvailabilityDate = DateTime.Now; } if (!rdr.IsDBNull(10)) { Resource.AvailabilityHours = rdr.GetDateTime(10); } else { Resource.AvailabilityHours = DateTime.Now; } } else { Resource.SetColumnDefaults(); } } catch (Exception ex) { Resource.SetColumnDefaults(); return(Resource); } finally { con.Close(); } return(Resource); }
public Resource Select(int id) { Resource Resource = new Resource(); string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_RESOURCE", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Resource_ID", id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); if (!rdr.IsDBNull(0)) { Resource.Resource_ID = rdr.GetInt32(0); } else { Resource.Resource_ID = 0; } if (!rdr.IsDBNull(1)) { Resource.Resource_Type_ID = rdr.GetInt32(1); } else { Resource.Resource_Type_ID = 0; } if (!rdr.IsDBNull(2)) { Resource.Description = rdr.GetString(2); } else { Resource.Description = " "; } if (!rdr.IsDBNull(3)) { Resource.Address = rdr.GetString(3); } else { Resource.Address = " "; } if (!rdr.IsDBNull(4)) { Resource.City = rdr.GetString(4); } else { Resource.City = " "; } if (!rdr.IsDBNull(5)) { Resource.State = rdr.GetString(5); } else { Resource.State = " "; } if (!rdr.IsDBNull(6)) { Resource.Zip Code = rdr.GetString(6); } else { Resource.Zip Code = " "; } if (!rdr.IsDBNull(7)) { Resource.PayType = rdr.GetString(7); } else { Resource.PayType = " "; } if (!rdr.IsDBNull(8)) { Resource.PayRate = rdr.GetDecimal(8); } else { Resource.PayRate = 0; } if (!rdr.IsDBNull(9)) { Resource.AvailabilityDate = rdr.GetDateTime(9); } else { Resource.AvailabilityDate = DateTime.Now; } if (!rdr.IsDBNull(10)) { Resource.AvailabilityHours = rdr.GetDateTime(10); } else { Resource.AvailabilityHours = DateTime.Now; } } else { Resource.SetColumnDefaults(); } } catch (Exception ex) { Resource.SetColumnDefaults(); return Resource; } finally { con.Close(); } return Resource; }
public Boolean Update(Resource id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_UPDATE_RESOURCE", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Resource_ID", id.Resource_ID); cmd.Parameters.AddWithValue("@Resource_Type_ID", id.Resource_Type_ID); cmd.Parameters.AddWithValue("@Description", id.Description); cmd.Parameters.AddWithValue("@Address", id.Address); cmd.Parameters.AddWithValue("@City", id.City); cmd.Parameters.AddWithValue("@State", id.State); cmd.Parameters.AddWithValue("@Zip Code", id.Zip Code); cmd.Parameters.AddWithValue("@PayType", id.PayType); cmd.Parameters.AddWithValue("@PayRate", id.PayRate); cmd.Parameters.AddWithValue("@AvailabilityDate", id.AvailabilityDate); cmd.Parameters.AddWithValue("@AvailabilityHours", id.AvailabilityHours); cmd.ExecuteReader(); con.Close(); return true; } catch (Exception ex) { return false; } finally { con.Close(); } }
public Resource Insert(Resource id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_RESOURCE", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Resource_Type_ID", id.Resource_Type_ID); cmd.Parameters.AddWithValue("@Description", id.Description); cmd.Parameters.AddWithValue("@Address", id.Address); cmd.Parameters.AddWithValue("@City", id.City); cmd.Parameters.AddWithValue("@State", id.State); cmd.Parameters.AddWithValue("@Zip Code", id.Zip Code); cmd.Parameters.AddWithValue("@PayType", id.PayType); cmd.Parameters.AddWithValue("@PayRate", id.PayRate); cmd.Parameters.AddWithValue("@AvailabilityDate", id.AvailabilityDate); cmd.Parameters.AddWithValue("@AvailabilityHours", id.AvailabilityHours); cmd.ExecuteReader(); con.Close(); con.Open(); cmd = new SqlCommand("SP_DMCS_GET_RESOURCE", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Resource_Type_ID", id.Resource_Type_ID); cmd.Parameters.AddWithValue("@Description", id.Description); cmd.Parameters.AddWithValue("@Address", id.Address); cmd.Parameters.AddWithValue("@City", id.City); cmd.Parameters.AddWithValue("@State", id.State); cmd.Parameters.AddWithValue("@Zip Code", id.Zip Code); cmd.Parameters.AddWithValue("@PayType", id.PayType); cmd.Parameters.AddWithValue("@PayRate", id.PayRate); cmd.Parameters.AddWithValue("@AvailabilityDate", id.AvailabilityDate); cmd.Parameters.AddWithValue("@AvailabilityHours", id.AvailabilityHours); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); id.Resource_ID = rdr.GetInt32(0); } } catch (Exception ex) { id.SetColumnDefaults(); } finally { con.Close(); } return id; }