예제 #1
0
        public static List <Sponsorship> GetAllSponsorship()
        {
            List <Sponsorship> xx  = new List <Sponsorship>();
            SqlConnection      con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand         com = new SqlCommand("sp_Get_All_Sponsorship", con);

            com.CommandType = System.Data.CommandType.StoredProcedure;
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                while (rd.Read())
                {
                    Sponsorship x = new Sponsorship();

                    if (!(rd["ID"] is DBNull))
                    {
                        x.ID = int.Parse(rd["ID"].ToString());
                    }
                    if (!(rd["OrphanID"] is DBNull))
                    {
                        x.OrphanID = int.Parse(rd["OrphanID"].ToString());
                    }
                    if (!(rd["StartDate"] is DBNull))
                    {
                        x.StartDate = DateTime.Parse(rd["StartDate"].ToString());
                    }
                    if (!(rd["EndDate"] is DBNull))
                    {
                        x.EndDate = DateTime.Parse(rd["EndDate"].ToString());
                    }
                    x.Notes = rd["Notes"].ToString();
                    if (!(rd["LastUserID"] is DBNull))
                    {
                        x.LastUserID = int.Parse(rd["LastUserID"].ToString());
                    }
                    if (!(rd["AvailableSponsorshipID"] is DBNull))
                    {
                        x.AvailableSponsorship = AvailableSponsorship.GetAvailableSponsorshipByID(int.Parse(rd["AvailableSponsorshipID"].ToString()));
                    }
                    x.IsDouble = (bool)rd["IsDouble"];
                    xx.Add(x);
                }
                rd.Close();
            }
            catch
            {
                xx = null;
            }
            finally
            {
                con.Close();
            }
            return(xx);
        }
예제 #2
0
        public static Sponsorship GetCurrentSponsorshipByOrphanID(int OrphanId)
        {
            Sponsorship   x   = new Sponsorship();
            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_Get_Current_Sponsorship", con);

            com.CommandType = System.Data.CommandType.StoredProcedure;
            SqlParameter pr = new SqlParameter("@OrphanId", OrphanId);

            com.Parameters.Add(pr);
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                if (rd.Read())
                {
                    if (!(rd["ID"] is DBNull))
                    {
                        x.ID = int.Parse(rd["ID"].ToString());
                    }
                    if (!(rd["OrphanID"] is DBNull))
                    {
                        x.OrphanID = int.Parse(rd["OrphanID"].ToString());
                    }
                    if (!(rd["StartDate"] is DBNull))
                    {
                        x.StartDate = DateTime.Parse(rd["StartDate"].ToString());
                    }
                    if (!(rd["EndDate"] is DBNull))
                    {
                        x.EndDate = DateTime.Parse(rd["EndDate"].ToString());
                    }
                    x.Notes = rd["Notes"].ToString();
                    if (!(rd["LastUserID"] is DBNull))
                    {
                        x.LastUserID = int.Parse(rd["LastUserID"].ToString());
                    }
                    if (!(rd["AvailableSponsorshipID"] is DBNull))
                    {
                        x.AvailableSponsorship = AvailableSponsorship.GetAvailableSponsorshipByID(int.Parse(rd["AvailableSponsorshipID"].ToString()));
                    }
                    x.IsDouble = (bool)rd["IsDouble"];
                }
                rd.Close();
            }
            catch
            {
                x = null;
            }
            finally
            {
                con.Close();
            }
            return(x);
        }
예제 #3
0
 public static bool UpdateData(Sponsorship x)
 {
     return(BaseDataBase._StoredProcedure("sp_Update_Sponsorship"
                                          , new SqlParameter("@ID", x.ID)
                                          , new SqlParameter("@OrphanID", x.OrphanID)
                                          , new SqlParameter("@StartDate", x.StartDate)
                                          , new SqlParameter("@EndDate", x.EndDate)
                                          , new SqlParameter("@Notes", x.Notes)
                                          , new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID)
                                          , new SqlParameter("@IsDouble", x.IsDouble)
                                          , new SqlParameter("@AvailableSponsorshipID", x.AvailableSponsorship.ID)));
 }
예제 #4
0
 public static bool InsertData(Sponsorship x)
 {
     x.ID = BaseDataBase._StoredProcedureReturnable("sp_Add_Sponsorship"
                                                    , new SqlParameter("@ID", System.Data.SqlDbType.Int)
                                                    , new SqlParameter("@OrphanID", x.OrphanID)
                                                    , new SqlParameter("@StartDate", x.StartDate)
                                                    , new SqlParameter("@EndDate", x.EndDate)
                                                    , new SqlParameter("@Notes", x.Notes)
                                                    , new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID)
                                                    , new SqlParameter("@IsDouble", x.IsDouble)
                                                    , new SqlParameter("@AvailableSponsorshipID", x.AvailableSponsorship.ID));
     return(x.ID.HasValue);
 }
예제 #5
0
        public static List <Sponsorship> GetSponsorshipAllByOrphanID(int OrphanID)
        {
            List <Sponsorship> xx  = new List <Sponsorship>();
            SqlConnection      con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand         com = new SqlCommand("sp_Get_OrphanID_Sponsorship", con);

            com.CommandType = System.Data.CommandType.StoredProcedure;
            com.Parameters.Add(new SqlParameter("@OrphanID", OrphanID));
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                while (rd.Read())
                {
                    Sponsorship x = new Sponsorship();

                    if (!(rd["SponsorshipID"] is DBNull))
                    {
                        x.ID = int.Parse(rd["SponsorshipID"].ToString());
                    }
                    if (!(rd["OrphanID"] is DBNull))
                    {
                        x.OrphanID = int.Parse(rd["OrphanID"].ToString());
                    }
                    if (!(rd["StartDate"] is DBNull))
                    {
                        x.StartDate = DateTime.Parse(rd["StartDate"].ToString());
                    }
                    if (!(rd["EndDate"] is DBNull))
                    {
                        x.EndDate = DateTime.Parse(rd["EndDate"].ToString());
                    }
                    x.Notes = rd["SponsorshipNotes"].ToString();
                    if (!(rd["SponsorshipLastUserID"] is DBNull))
                    {
                        x.LastUserID = int.Parse(rd["SponsorshipLastUserID"].ToString());
                    }
                    x.IsDouble = (bool)rd["IsDouble"];

                    x.AvailableSponsorship = new AvailableSponsorship();
                    if (!(rd["SponsorID"] is DBNull))
                    {
                        x.AvailableSponsorship.RelatedSponsor = new Sponsor()
                        {
                            SponsorID = int.Parse(rd["SponsorID"].ToString()), Name = rd["SponsorName"].ToString()
                        }
                    }
                    ;
                    if (!(rd["AvailableSponsorshipID"] is DBNull))
                    {
                        x.AvailableSponsorship.ID = int.Parse(rd["AvailableSponsorshipID"].ToString());
                    }
                    if (!(rd["NOB"] is DBNull))
                    {
                        x.AvailableSponsorship.NOB = int.Parse(rd["NOB"].ToString());
                    }
                    if (!(rd["Duration"] is DBNull))
                    {
                        x.AvailableSponsorship.Duration = double.Parse(rd["Duration"].ToString());
                    }
                    if (!(rd["SponsorshipValue"] is DBNull))
                    {
                        x.AvailableSponsorship.SponsorshipValue = double.Parse(rd["SponsorshipValue"].ToString());
                    }
                    x.AvailableSponsorship.SponsorType     = rd["SponsorType"].ToString();
                    x.AvailableSponsorship.SponsorshipType = rd["SponsorshipType"].ToString();
                    x.AvailableSponsorship.IsCompensated   = (bool)rd["IsCompensated"];
                    x.AvailableSponsorship.Notes           = rd["AvailableSponsorshipNotes"].ToString();
                    if (!(rd["AvailableSponsorshipLastUserID"] is DBNull))
                    {
                        x.AvailableSponsorship.LastUserID = int.Parse(rd["AvailableSponsorshipLastUserID"].ToString());
                    }

                    xx.Add(x);
                }
                rd.Close();
            }
            catch
            {
                xx = null;
            }
            finally
            {
                con.Close();
            }
            return(xx);
        }
예제 #6
0
 public static bool DeleteData(Sponsorship x)
 {
     return(BaseDataBase._StoredProcedure("sp_Delete_Sponsorship"
                                          , new SqlParameter("@ID", x.ID)));
 }