public static List <Orphan_Supervisor> GetOrphanSupervisorAllByOrphanID(int?id) { List <Orphan_Supervisor> oss = new List <Orphan_Supervisor>(); SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString); SqlCommand com = new SqlCommand("sp_GetOrphanSupervisorAllByOrphanID", con); com.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter pr = new SqlParameter("@OrphanID", id); com.Parameters.Add(pr); try { con.Open(); SqlDataReader rd = com.ExecuteReader(); while (rd.Read()) { Orphan_Supervisor x = new Orphan_Supervisor(); if (!(rd["ID"] is DBNull)) { x.ID = System.Int32.Parse(rd["ID"].ToString()); } if (!(rd["SupervisorID"] is DBNull)) { x.SupervisorID = System.Int32.Parse(rd["SupervisorID"].ToString()); } if (!(rd["OrphanID"] is DBNull)) { x.OrphanID = System.Int32.Parse(rd["OrphanID"].ToString()); } if (!(rd["EndDate"] is DBNull)) { x.EndDate = System.DateTime.Parse(rd["EndDate"].ToString()); } if (!(rd["Date"] is DBNull)) { x.Date = System.DateTime.Parse(rd["Date"].ToString()); } x.SupervisorType = rd["SupervisorType"].ToString(); x.Notes = rd["Notes"].ToString(); oss.Add(x); } rd.Close(); } catch { oss = new List <Orphan_Supervisor>(); } finally { con.Close(); } return(oss); }
private void btnNew_Click(object sender, RoutedEventArgs e) { var x = this.DataContext as Orphan_Supervisor; if (x.ID != null) { var os = new Orphan_Supervisor(); os.OrphanID = OrphanID; this.DataContext = os; } }