public static List <TeachingStage> GetTeachingStageByOrphanID(int?OrphanID) { var tss = new List <TeachingStage>(); SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString); SqlCommand com = new SqlCommand("sp_GetTeachingStageAllByOrphanID", con); com.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter pr = new SqlParameter("@OrphanID", OrphanID); com.Parameters.Add(pr); try { con.Open(); SqlDataReader rd = com.ExecuteReader(); while (rd.Read()) { TeachingStage x = new TeachingStage(); if (!(rd["ID"] is DBNull)) { x.ID = System.Int32.Parse(rd["ID"].ToString()); } if (!(rd["OrphanID"] is DBNull)) { x.OrphanID = System.Int32.Parse(rd["OrphanID"].ToString()); } x.StudyStage = rd["StudyStage"].ToString(); x.School = rd["School"].ToString(); x.Class = rd["Class"].ToString(); x.Evaluation = rd["Evaluation"].ToString(); x.EvaluationReason = rd["EvaluationReason"].ToString(); if (!(rd["Date"] is DBNull)) { x.Date = System.DateTime.Parse(rd["Date"].ToString()); } if (!(rd["IsStopped"] is DBNull)) { x.IsStopped = System.Boolean.Parse(rd["IsStopped"].ToString()); } x.StopReason = rd["StopReason"].ToString(); x.Notes = rd["Notes"].ToString(); tss.Add(x); } rd.Close(); } catch { tss = new List <TeachingStage>(); } finally { con.Close(); } return(tss); }
private void btnNew_Click(object sender, RoutedEventArgs e) { var x = this.DataContext as TeachingStage; if (x.ID != null) { var ts = new TeachingStage(); ts.OrphanID = OrphanID; this.DataContext = ts; } }