Exemplo n.º 1
0
        public static Sponsor GetSponsorByID(int id, bool bringDetails = false)
        {
            Sponsor       x   = new Sponsor();
            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_Get_ID_Sponsor", con);

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

            com.Parameters.Add(pr);
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                if (rd.Read())
                {
                    if (!(rd["SponsorID"] is DBNull))
                    {
                        x.SponsorID = int.Parse(rd["SponsorID"].ToString());
                    }
                    x.Name        = rd["Name"].ToString();
                    x.Nationality = rd["Nationality"].ToString();
                    if (!(rd["IsOrganazation"] is DBNull))
                    {
                        x.IsOrganazation = bool.Parse(rd["IsOrganazation"].ToString());
                    }
                    if (!(rd["DOB"] is DBNull))
                    {
                        x.DOB = DateTime.Parse(rd["DOB"].ToString());
                    }
                    x.Gender          = rd["Gender"].ToString();
                    x.Phone           = rd["Phone"].ToString();
                    x.Mobile          = rd["Mobile"].ToString();
                    x.Email           = rd["Email"].ToString();
                    x.Address         = rd["Address"].ToString();
                    x.MainSponsorship = rd["MainSponsorship"].ToString();
                    x.MediatorName    = rd["MediatorName"].ToString();
                    x.MediatorMobile  = rd["MediatorMobile"].ToString();
                    x.Notes           = rd["Notes"].ToString();
                    x.Status          = rd["Status"].ToString();

                    if (bringDetails)
                    {
                        x.Account               = Account.GetAccountByOwnerID(Account.AccountType.Sponsor, x.SponsorID.Value);
                        x.Sponsorships          = Sponsorship.GetSponsorshipAllBySponsorID(x);
                        x.AvailableSponsorships = AvailableSponsorship.GetAllAvailableSponsorshipBySponsorID(x);
                    }
                }
                rd.Close();
            }
            catch
            {
                x = null;
            }
            finally
            {
                con.Close();
            }
            return(x);
        }
 public NewSponsorshipsWindow(AvailableSponsorship a)
 {
     InitializeComponent();
     this.DataContext = a;
     if (!a.ID.HasValue)
     {
         a.SponsorType = "كفالة خاصة";
     }
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 public static bool UpdateData(AvailableSponsorship x)
 {
     return(BaseDataBase._StoredProcedure("sp_Update_AvailableSponsorship"
                                          , new SqlParameter("@ID", x.ID)
                                          , new SqlParameter("@SponsorID", x.RelatedSponsor.SponsorID)
                                          , new SqlParameter("@NOB", x.NOB)
                                          , new SqlParameter("@Duration", x.Duration)
                                          , new SqlParameter("@SponsorshipValue", x.SponsorshipValue)
                                          , new SqlParameter("@SponsorshipType", x.SponsorshipType)
                                          , new SqlParameter("@Notes", x.Notes)
                                          , new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID)
                                          , new SqlParameter("@IsCompensated", x.IsCompensated)
                                          , new SqlParameter("@OverMonths", x.OverMonths)
                                          , new SqlParameter("@SponsorType", x.SponsorType)
                                          , new SqlParameter("@CreateDate", x.CreateDate)));
 }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var a = this.DataContext as AvailableSponsorship;

            if (a != null)
            {
                if (a.IsValidate())
                {
                    if (AvailableSponsorship.InsertData(a))
                    {
                        MyMessage.InsertMessage();
                        DialogResult = true;
                    }
                }
            }
        }
Exemplo n.º 7
0
        public static bool InsertData(AvailableSponsorship x)
        {
            if (x.SponsorshipType == "")
            {
                x.Duration = null;
            }

            x.ID = BaseDataBase._StoredProcedureReturnable("sp_Add_AvailableSponsorship"
                                                           , new SqlParameter("@ID", System.Data.SqlDbType.Int)
                                                           , new SqlParameter("@SponsorID", x.RelatedSponsor.SponsorID)
                                                           , new SqlParameter("@NOB", x.NOB)
                                                           , new SqlParameter("@Duration", x.Duration)
                                                           , new SqlParameter("@SponsorshipValue", x.SponsorshipValue)
                                                           , new SqlParameter("@SponsorshipType", x.SponsorshipType)
                                                           , new SqlParameter("@Notes", x.Notes)
                                                           , new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID)
                                                           , new SqlParameter("@IsCompensated", x.IsCompensated)
                                                           , new SqlParameter("@OverMonths", x.OverMonths)
                                                           , new SqlParameter("@SponsorType", x.SponsorType)
                                                           , new SqlParameter("@CreateDate", x.CreateDate));
            return(x.ID.HasValue);
        }
        private void Filter()
        {
            ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(dgAvailableSponsorships.ItemsSource);

            view.Filter = delegate(object item)
            {
                AvailableSponsorship a = (AvailableSponsorship)item;
                if ((txtName.Text != "" && !a.RelatedSponsor.Name.Contains(txtName.Text)))
                {
                    return(false);
                }
                if (cmboIsCompensated.SelectedIndex > 0 && (cmboIsCompensated.SelectedIndex == 1 && !a.IsCompensated) || (cmboIsCompensated.SelectedIndex == 2 && a.IsCompensated))
                {
                    return(false);
                }
                if (cmboIsGeneral.SelectedIndex > 0 && a.SponsorType != (cmboIsGeneral.SelectedIndex == 1 ? "كفالة خاصة" : "كفالة عامة"))
                {
                    return(false);
                }
                return(true);
            };
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
 public static bool DeleteData(AvailableSponsorship x)
 {
     return(BaseDataBase._StoredProcedure("sp_Delete_AvailableSponsorship"
                                          , new SqlParameter("@ID", x.ID)));
 }
 public SelectAvailableSponsorshipControl()
 {
     InitializeComponent();
     dgAvailableSponsorships.ItemsSource = AvailableSponsorship.GetAllAvailableSponsorship();
 }