public static NominationSide GetNominationSideByID(int id) { NominationSide x = new NominationSide(); SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString); SqlCommand com = new SqlCommand("sp_GetNominationSideByID", con); com.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter pr = new SqlParameter("@NominationSideID", id); com.Parameters.Add(pr); try { con.Open(); SqlDataReader rd = com.ExecuteReader(); if (rd.Read()) { if (!(rd["NominationSideID"] is DBNull)) { x.NominationSideID = System.Int32.Parse(rd["NominationSideID"].ToString()); } x.Name = rd["Name"].ToString(); if (!(rd["AddDate"] is DBNull)) { x.AddDate = System.DateTime.Parse(rd["AddDate"].ToString()); } x.Phone = rd["Phone"].ToString(); x.Mobile = rd["Mobile"].ToString(); x.Email = rd["Email"].ToString(); x.Address = rd["Address"].ToString(); x.ResponsiblePerson = rd["ResponsiblePerson"].ToString(); x.Notes = rd["Notes"].ToString(); } rd.Close(); } catch { x = null; } finally { con.Close(); } return(x); }
public static List <NominationSide> GetAllNominationSides() { List <NominationSide> nss = new List <NominationSide>(); SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString); SqlCommand com = new SqlCommand("sp_GetAllNominationSides", con); com.CommandType = System.Data.CommandType.StoredProcedure; try { con.Open(); SqlDataReader rd = com.ExecuteReader(); if (rd.Read()) { NominationSide x = new NominationSide(); if (!(rd["NominationSideID"] is DBNull)) { x.NominationSideID = System.Int32.Parse(rd["NominationSideID"].ToString()); } x.Name = rd["Name"].ToString(); if (!(rd["AddDate"] is DBNull)) { x.AddDate = System.DateTime.Parse(rd["AddDate"].ToString()); } x.Phone = rd["Phone"].ToString(); x.Mobile = rd["Mobile"].ToString(); x.Email = rd["Email"].ToString(); x.Address = rd["Address"].ToString(); x.ResponsiblePerson = rd["ResponsiblePerson"].ToString(); x.Notes = rd["Notes"].ToString(); nss.Add(x); } rd.Close(); } catch { nss = null; } finally { con.Close(); } return(nss); }