Exemplo n.º 1
0
        public static bool InsertData(Sponsor x)
        {
            x.SponsorID = BaseDataBase._StoredProcedureReturnable("sp_Add_Sponsor"
                                                                  , new SqlParameter("@SponsorID", SqlDbType.Int)
                                                                  , new SqlParameter("@Name", x.Name)
                                                                  , new SqlParameter("@Nationality", x.Nationality)
                                                                  , new SqlParameter("@IsOrganazation", x.IsOrganazation)
                                                                  , new SqlParameter("@DOB", x.DOB)
                                                                  , new SqlParameter("@Gender", x.Gender)
                                                                  , new SqlParameter("@Phone", x.Phone)
                                                                  , new SqlParameter("@Mobile", x.Mobile)
                                                                  , new SqlParameter("@Email", x.Email)
                                                                  , new SqlParameter("@Address", x.Address)
                                                                  , new SqlParameter("@MainSponsorship", x.MainSponsorship)
                                                                  , new SqlParameter("@Notes", x.Notes)
                                                                  , new SqlParameter("@MediatorName", x.MediatorName)
                                                                  , new SqlParameter("@MediatorMobile", x.MediatorMobile)
                                                                  , new SqlParameter("@Status", x.Status));

            return(x.SponsorID.HasValue);
        }
Exemplo n.º 2
0
        public static List <Sponsorship> GetSponsorshipAllBySponsorID(Sponsor s)
        {
            List <Sponsorship> xx  = new List <Sponsorship>();
            SqlConnection      con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand         com = new SqlCommand("sp_Get_SponsorID_Sponsorship", con);

            com.CommandType = System.Data.CommandType.StoredProcedure;
            com.Parameters.Add(new SqlParameter("@SponsorID", s.SponsorID));
            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();
                    x.OrphanName = rd["OrphanName"].ToString();
                    if (!(rd["SponsorshipLastUserID"] is DBNull))
                    {
                        x.LastUserID = int.Parse(rd["SponsorshipLastUserID"].ToString());
                    }
                    x.IsDouble = (bool)rd["IsDouble"];

                    x.AvailableSponsorship = new AvailableSponsorship();
                    x.AvailableSponsorship.RelatedSponsor = s;
                    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.SponsorshipType = rd["SponsorshipType"].ToString();
                    x.AvailableSponsorship.SponsorType     = rd["SponsorType"].ToString();
                    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);
        }
Exemplo n.º 3
0
 public SponsorControl(Sponsor s)
 {
     InitializeComponent();
     myWindow.DataContext = s;
     cAccount.Account     = s.Account;
 }
Exemplo n.º 4
0
 public static bool DeleteData(Sponsor x)
 {
     return(BaseDataBase._StoredProcedure("sp_Delete_Sponsor"
                                          , new SqlParameter("@SponsorID", x.SponsorID)));
 }
Exemplo n.º 5
0
        public static List <AvailableSponsorship> GetAllAvailableSponsorshipBySponsorID(Sponsor s)
        {
            List <AvailableSponsorship> xx = new List <AvailableSponsorship>();
            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_Get_SponsorID_AvailableSponsorship", con);

            com.CommandType = System.Data.CommandType.StoredProcedure;
            com.Parameters.Add(new SqlParameter("@SponsorID", s.SponsorID));
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                while (rd.Read())
                {
                    AvailableSponsorship x = new AvailableSponsorship();
                    x.RelatedSponsor = s;
                    if (!(rd["ID"] is DBNull))
                    {
                        x.ID = int.Parse(rd["ID"].ToString());
                    }
                    if (!(rd["NOB"] is DBNull))
                    {
                        x.NOB = int.Parse(rd["NOB"].ToString());
                    }
                    x.remainingNOB = int.Parse(rd["RemainingNOB"].ToString());
                    if (!(rd["Duration"] is DBNull))
                    {
                        x.Duration = double.Parse(rd["Duration"].ToString());
                    }
                    if (!(rd["SponsorshipValue"] is DBNull))
                    {
                        x.SponsorshipValue = double.Parse(rd["SponsorshipValue"].ToString());
                    }
                    x.SponsorshipType = rd["SponsorshipType"].ToString();
                    x.Notes           = rd["Notes"].ToString();
                    if (!(rd["LastUserID"] is DBNull))
                    {
                        x.LastUserID = int.Parse(rd["LastUserID"].ToString());
                    }
                    if (!(rd["IsCompensated"] is DBNull))
                    {
                        x.IsCompensated = bool.Parse(rd["IsCompensated"].ToString());
                    }
                    if (!(rd["OverMonths"] is DBNull))
                    {
                        x.OverMonths = int.Parse(rd["OverMonths"].ToString());
                    }
                    x.SponsorType = rd["SponsorType"].ToString();
                    if (!(rd["CreateDate"] is DBNull))
                    {
                        x.CreateDate = DateTime.Parse(rd["CreateDate"].ToString());
                    }
                    xx.Add(x);
                }
                rd.Close();
            }
            catch
            {
                xx = null;
            }
            finally
            {
                con.Close();
            }
            return(xx);
        }