Ejemplo n.º 1
0
        public static List <AdminEvaluation> GetAdminEvaluationByOrphanID(int?OrphanID)
        {
            List <AdminEvaluation> aes = new List <AdminEvaluation>();
            SqlConnection          con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand             com = new SqlCommand("sp_GetAdminEvaluationsByOrphanID", 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())
                {
                    AdminEvaluation x = new AdminEvaluation();
                    if (!(rd["ID"] is DBNull))
                    {
                        x.ID = System.Int32.Parse(rd["ID"].ToString());
                    }
                    if (!(rd["FamilyID"] is DBNull))
                    {
                        x.FamilyID = System.Int32.Parse(rd["FamilyID"].ToString());
                    }
                    if (!(rd["OrphanID"] is DBNull))
                    {
                        x.OrphanID = System.Int32.Parse(rd["OrphanID"].ToString());
                    }
                    x.Evaluator  = rd["Evaluator"].ToString();
                    x.Evaluation = rd["Evaluation"].ToString();
                    x.Reason     = rd["Reason"].ToString();
                    if (!(rd["Date"] is DBNull))
                    {
                        x.Date = System.DateTime.Parse(rd["Date"].ToString());
                    }
                    x.Notes = rd["Notes"].ToString();

                    aes.Add(x);
                }
                rd.Close();
            }
            catch
            {
                aes = new List <AdminEvaluation>();
            }
            finally
            {
                con.Close();
            }
            return(aes);
        }
        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            var x = this.DataContext as AdminEvaluation;

            if (x.ID != null)
            {
                var ae = new AdminEvaluation();
                if (FamilyID == null)
                {
                    ae.OrphanID = OrphanID;
                }
                else
                {
                    ae.FamilyID = FamilyID;
                }
                this.DataContext = ae;
            }
        }