public StudentDetailsControl(Family f)
        {
            InitializeComponent();
            tcm.Items.RemoveAt(0);
            tcm.Items.RemoveAt(2);
            tcm.Items.RemoveAt(7);
            Orphan o = new Orphan();

            o.OrphanFamily = f;
            if (!f.FamilyID.HasValue)
            {
                f.ApplyDate       = BaseDataBase.DateNow;
                f.OrphanNursemaid = new Guardian()
                {
                    Gender = "أنثى"
                };
                f.OrphanGuardian = new Guardian()
                {
                    Gender = "ذكر"
                };
                f.FamilyHouse = new House();
                cOrphanFamily.dgChild.ItemsSource = new List <FamilyPerson>();
                btnShowDetails_Click(null, null);
            }
            else
            {
                FillData(o);
            }
            this.DataContext = o;
        }
 public OrphanDetailsControl(Orphan o)
 {
     InitializeComponent();
     this.DataContext = o;
     tcm.Items.RemoveAt(tcm.Items.Count - 1);
     FillData(o);
 }
示例#3
0
        private void btnOrphanTeachingStage_Click(object sender, RoutedEventArgs e)
        {
            Orphan o = this.DataContext as Orphan;
            TeachingStageControl w = new TeachingStageControl();

            w.OrphanID = (this.DataContext as Orphan).OrphanID;
            w.ShowDialog();
        }
示例#4
0
        private void btnOrphanImpeding_Click(object sender, RoutedEventArgs e)
        {
            Orphan o = this.DataContext as Orphan;
            OrphanImpedingControl w = new OrphanImpedingControl();

            w.OrphanID = o.OrphanID;
            w.ShowDialog();
        }
示例#5
0
 public OrphanWindow(Orphan o)
 {
     InitializeComponent();
     this.DataContext = o;
     cOrphan.btnGoToFamilyDetails.Visibility = Visibility.Collapsed;
     cOrphan.btnSave.Click -= cOrphan.btnSave_Click;
     cOrphan.btnSave.Click += BtnSave_Click;
 }
示例#6
0
        private void btnOrphanHealth_Click(object sender, RoutedEventArgs e)
        {
            Orphan o = this.DataContext as Orphan;

            if (o != null && o.OrphanID != null)
            {
                OrphanHealthControl w = new OrphanHealthControl();
                w.OrphanID = o.OrphanID;
                w.ShowDialog();
            }
            else
            {
                MyMessageBox.Show("لم يتم إدخال بيانات اليتيم");
            }
        }
示例#7
0
 private void btnDeleteOrphan_Click(object sender, RoutedEventArgs e)
 {
     if (lvOrphans.SelectedItem != null)
     {
         var o = lvOrphans.SelectedItem as Orphan;
         var f = DataContext as Family;
         if (MyMessageBox.Show("هل تريد تأكيد حذف اليتيم/طالب العلم؟", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         //if CanRemove
         {
             if (o.OrphanID.HasValue)
             {
                 Orphan.DeleteData(o);
             }
             Orphans.Remove(o);
             lvOrphans.Items.Refresh();
         }
     }
 }
示例#8
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            var x = this.DataContext as Orphan;

            if (x.IsValidate())
            {
                if (x.OrphanID.HasValue)
                {
                    if (Orphan.UpdateData(x))
                    {
                        MyMessage.UpdateMessage();
                        DialogResult = true;
                    }
                }
                else
                {
                    DialogResult = true;
                }
            }
        }
示例#9
0
 private void btnUpdate_Click(object sender, RoutedEventArgs e)
 {
     if (radOrphans.IsChecked == true && dgOrphans.SelectedIndex != -1)
     {
         var        drv = dgOrphans.SelectedItem as DataRowView;
         MainWindow m   = App.Current.MainWindow as MainWindow;
         m.SendTabItem(new TabItem()
         {
             Header = drv[1].ToString(), Content = new OrphanDetailsControl(Orphan.GetOrphanByID((int)drv[0]))
         });
     }
     else if (radFamilies.IsChecked == true && dgFamily.SelectedIndex != -1)
     {
         var        drv = dgFamily.SelectedItem as DataRowView;
         MainWindow m   = App.Current.MainWindow as MainWindow;
         m.SendTabItem(new TabItem()
         {
             Header = drv["FamilyName"].ToString(), Content = new OrphanDetailsControl(Family.GetFamilyByID((int)drv[0]))
         });
     }
 }
示例#10
0
        public void btnSave_Click(object sender, RoutedEventArgs e)
        {
            var x = this.DataContext as Orphan;

            if (x.IsValidate())
            {
                if (x.OrphanFamily.FamilyID == null)
                {
                    MyMessageBox.Show("لم يتم إدخال بيانات العائلة");
                    return;
                }

                if (x.OrphanFamily.FamilyType == "أيتام")
                {
                    if (x.Gender == "ذكر" && (((BaseDataBase.DateNow - x.DOB.Value)).Days / 30 / 12) >= 14)
                    {
                        if (MyMessageBox.Show("عمر اليتيم أكبر من 14\nهل تريد المتابعة", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
                        {
                            return;
                        }
                    }
                }

                if (x.OrphanID != null)
                {
                    if (Orphan.UpdateData(x))
                    {
                        MyMessage.UpdateMessage();
                    }
                }
                else
                {
                    if (Orphan.InsertData(x))
                    {
                        MyMessage.InsertMessage();
                    }
                }
            }
        }
示例#11
0
        private void btnAddNewOrphan_Click(object sender, RoutedEventArgs e)
        {
            var    f = DataContext as Family;
            Orphan o = new Orphan()
            {
                OrphanFamily = f
            };
            OrphanWindow w = new MainWPF.OrphanWindow(o);

            if (w.ShowDialog() == true)
            {
                lvOrphans.ItemsSource = null;
                if (Orphans == null)
                {
                    Orphans = new List <Orphan>();
                }
                Orphans.Add(o);
                if (f.FamilyID.HasValue)
                {
                    if (Orphan.InsertData(o))
                    {
                        o.Account                = new Account();
                        o.Account.Name           = o.FirstName + " " + o.LastName;
                        o.Account.Type           = o.Type == "يتيم" ? Account.AccountType.Orphan : o.Type == "يتيم طالب علم" ? Account.AccountType.OrphanStudent : Account.AccountType.Student;
                        o.Account.CurrentBalance = 0;
                        o.Account.CreateDate     = BaseDataBase.DateNow;
                        o.Account.OwnerID        = o.OrphanID;
                        o.Account.Status         = "مفعل";
                        o.Account.IsDebit        = true;

                        Account.InsertData(o.Account);
                    }
                    f.UpdateFamilyPersonCount();
                }
                f.FamilyOrphans       = Orphans;
                lvOrphans.ItemsSource = Orphans;
            }
        }
示例#12
0
 public static bool UpdateData(Orphan x)
 {
     return(BaseDataBase._StoredProcedure("sp_Update_Orphan"
                                          , new SqlParameter("@OrphanID", x.OrphanID)
                                          , new SqlParameter("@FamilyID", x.OrphanFamily.FamilyID)
                                          , new SqlParameter("@FirstName", x.FirstName)
                                          , new SqlParameter("@LastName", x.LastName)
                                          , new SqlParameter("@Gender", x.Gender)
                                          , new SqlParameter("@BirthPlace", x.BirthPlace)
                                          , new SqlParameter("@DOB", x.DOB)
                                          , new SqlParameter("@Nationality", x.Nationality)
                                          , new SqlParameter("@PID", x.PID)
                                          , new SqlParameter("@Mobile", x.Mobile)
                                          , new SqlParameter("@Email", x.Email)
                                          , new SqlParameter("@Notes", x.Notes)
                                          , new SqlParameter("@Image", x.Image)
                                          , new SqlParameter("@Tall", x.Tall)
                                          , new SqlParameter("@Weight", x.Weight)
                                          , new SqlParameter("@FeetSize", x.FeetSize)
                                          , new SqlParameter("@WaistSize", x.WaistSize)
                                          , new SqlParameter("@Status", x.Status)
                                          , new SqlParameter("@Type", x.Type)));
 }
示例#13
0
 public static bool InsertData(Orphan x)
 {
     x.OrphanID = BaseDataBase._StoredProcedureReturnable("sp_Add_Orphan"
                                                          , new SqlParameter("@OrphanID", System.Data.SqlDbType.Int)
                                                          , new SqlParameter("@FamilyID", x.OrphanFamily.FamilyID)
                                                          , new SqlParameter("@FirstName", x.FirstName)
                                                          , new SqlParameter("@LastName", x.LastName)
                                                          , new SqlParameter("@Gender", x.Gender)
                                                          , new SqlParameter("@BirthPlace", x.BirthPlace)
                                                          , new SqlParameter("@DOB", x.DOB)
                                                          , new SqlParameter("@Nationality", x.Nationality)
                                                          , new SqlParameter("@PID", x.PID)
                                                          , new SqlParameter("@Mobile", x.Mobile)
                                                          , new SqlParameter("@Email", x.Email)
                                                          , new SqlParameter("@Notes", x.Notes)
                                                          , new SqlParameter("@Image", x.Image)
                                                          , new SqlParameter("@Tall", x.Tall)
                                                          , new SqlParameter("@Weight", x.Weight)
                                                          , new SqlParameter("@FeetSize", x.FeetSize)
                                                          , new SqlParameter("@WaistSize", x.WaistSize)
                                                          , new SqlParameter("@Status", x.Status)
                                                          , new SqlParameter("@Type", x.Type));
     return(x.OrphanID.HasValue);
 }
示例#14
0
        public Transition_StudentWindow(Orphan o)
        {
            InitializeComponent();
            this.o          = o;
            txtStudent.Text = o.FirstName + " " + o.LastName;
            var i = new Invoice();
            var t = i.AddTransition();

            t.RightAccount = o.Account;
            t.LeftAccount  = new Account()
            {
                Id = 4
            };                                        //4 is the id of student fund account
            t.Value         = o.CurrentSponsorship.AvailableSponsorship.SponsorshipValue;
            t.Value         = o.CurrentSponsorship.IsDouble ? t.Value * 2 : t.Value;
            t.SponsorshipID = o.CurrentSponsorship.ID;
            t.AccountType   = Account.AccountType.Student; // 4 is the student type id
            txtSponsor.Text = o.CurrentSponsorship.AvailableSponsorship.RelatedSponsor.Name;

            i.Serial         = "B";
            i.Receiver       = BaseDataBase._Scalar($"select FirstName + ' ' + Isnull(LastName,'') from Parent where FamilyID = {o.OrphanFamily.FamilyID} and Gender = 'أنثى'");
            i.ReceiverPID    = BaseDataBase._Scalar($"select IsNull(PID,'') from Parent where FamilyID = {o.OrphanFamily.FamilyID} and Gender = 'أنثى'");
            this.DataContext = i;
        }
示例#15
0
        public static Task <List <Orphan> > GetAllOrphanByFamily(Family f, Orphan o = null, bool IncludeAccount = false)
        {
            List <Orphan> xx = new List <Orphan>();

            Task.Run(() =>
            {
                SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
                SqlCommand com    = new SqlCommand("sp_Get_All_Orphan_ByFamilyID", con);
                com.CommandType   = System.Data.CommandType.StoredProcedure;
                com.Parameters.Add(new SqlParameter("@FamilyID", f.FamilyID));
                if (o != null && o.OrphanID.HasValue)
                {
                    com.Parameters.Add(new SqlParameter("@OrphanID", o.OrphanID));
                }
                try
                {
                    con.Open();
                    SqlDataReader rd = com.ExecuteReader();
                    while (rd.Read())
                    {
                        Orphan x = new Orphan();

                        if (!(rd["OrphanID"] is DBNull))
                        {
                            x.OrphanID = int.Parse(rd["OrphanID"].ToString());
                        }
                        x.OrphanFamily = f;
                        x.FirstName    = rd["FirstName"].ToString();
                        x.LastName     = rd["LastName"].ToString();
                        x.Gender       = rd["Gender"].ToString();
                        x.BirthPlace   = rd["BirthPlace"].ToString();
                        if (!(rd["DOB"] is DBNull))
                        {
                            x.DOB = DateTime.Parse(rd["DOB"].ToString());
                        }
                        x.Nationality = rd["Nationality"].ToString();
                        x.PID         = rd["PID"].ToString();
                        x.Mobile      = rd["Mobile"].ToString();
                        x.Email       = rd["Email"].ToString();
                        x.Notes       = rd["Notes"].ToString();
                        x.Image       = rd["Image"].ToString();
                        if (!(rd["Tall"] is DBNull))
                        {
                            x.Tall = int.Parse(rd["Tall"].ToString());
                        }
                        if (!(rd["Weight"] is DBNull))
                        {
                            x.Weight = int.Parse(rd["Weight"].ToString());
                        }
                        if (!(rd["FeetSize"] is DBNull))
                        {
                            x.FeetSize = int.Parse(rd["FeetSize"].ToString());
                        }
                        if (!(rd["WaistSize"] is DBNull))
                        {
                            x.WaistSize = int.Parse(rd["WaistSize"].ToString());
                        }
                        x.Status = rd["Status"].ToString();
                        x.Type   = rd["Type"].ToString();

                        if (IncludeAccount)
                        {
                            x.Account = Account.GetAccountByOwnerID(x.Type == "يتيم" ? Account.AccountType.Orphan : x.Type == "طالب علم" ? Account.AccountType.Student : Account.AccountType.OrphanStudent, x.OrphanID.Value, false);
                        }
                        xx.Add(x);
                    }
                    rd.Close();
                }
                catch
                {
                    xx = null;
                }
                finally
                {
                    con.Close();
                }
            });

            return(Task.FromResult <List <Orphan> >(xx));
        }
示例#16
0
 private void lvOrphans_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (lvOrphans.SelectedItem != null)
     {
         var        o = lvOrphans.SelectedItem as Orphan;
         MainWindow m = App.Current.MainWindow as MainWindow;
         m.SendTabItem(new TabItem()
         {
             Header = o.FirstName + " " + o.LastName, Content = new OrphanDetailsControl(Orphan.GetOrphanByID(o.OrphanID.Value))
         });
     }
 }
        async void FillData(Orphan o)
        {
            Family f  = o.OrphanFamily;
            var    hs = House.GetHouseAllByFamilyID(f.FamilyID);

            if (hs != null && hs.Count() > 0)
            {
                f.FamilyHouse = hs.Last();
            }
            else
            {
                f.FamilyHouse = new House();
            }

            if (f.FamilyID.HasValue)
            {
                cOrphanFamily.dgChild.ItemsSource = (from x in FamilyPerson.GetFamilyPersonByFamilyID(f.FamilyID.Value) orderby x.DOB select x).ToList();
            }
            else
            {
                cOrphanFamily.dgChild.ItemsSource = new List <FamilyPerson>();
            }

            cFamilyNeed.FamilyID            = f.FamilyID;
            cExternalFamilySupport.FamilyID = f.FamilyID;
            cSpecialCard.FamilyID           = f.FamilyID;
            cListerGroup.FamilyID           = f.FamilyID;
            cTrainings.FamilyID             = f.FamilyID;

            if (o.OrphanID.HasValue)
            {
                cSponsor.OrphanID = o.OrphanID;
            }
            cOrders.FamilyID = f.FamilyID;
            cOrphanFamily.txtFamilyCode.IsReadOnly = true;

            if (o.OrphanID.HasValue)
            {
                o.Account        = Account.GetAccountByOwnerID(Account.AccountType.Student, o.OrphanID.Value);
                cAccount.Account = o.Account;
            }
            Guardian.GetAllGuardianByFamily(f);
            if (f.OrphanNursemaid == null)
            {
                f.OrphanNursemaid = new Guardian()
                {
                    Gender = "أنثى"
                }
            }
            ;
            if (f.OrphanGuardian == null)
            {
                f.OrphanGuardian = new Guardian()
                {
                    Gender = "ذكر"
                }
            }
            ;

            f.FamilyOrphans = await Orphan.GetAllOrphanByFamily(f, o, true);

            cOrphanFamily.Orphans = await Orphan.GetAllOrphanByFamily(f, o);
        }
 public StudentDetailsControl(Orphan o)
 {
     InitializeComponent();
     this.DataContext = o;
     FillData(o);
 }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
            var f = cOrphanFamily.DataContext as Family;

            if (f.IsValidate())
            {
                if (!(string.IsNullOrEmpty(f.FamilyFather.FirstName) && string.IsNullOrEmpty(f.FamilyFather.LastName)))
                {
                    if (!f.FamilyFather.IsValidate())
                    {
                        return;
                    }
                }
                if (!(string.IsNullOrEmpty(f.FamilyMother.FirstName) && string.IsNullOrEmpty(f.FamilyMother.LastName)))
                {
                    if (!f.FamilyMother.IsValidate())
                    {
                        return;
                    }
                }
                if (!(string.IsNullOrEmpty(f.OrphanGuardian.FirstName) && string.IsNullOrEmpty(f.OrphanGuardian.LastName)))
                {
                    if (!f.OrphanGuardian.IsValidate())
                    {
                        return;
                    }
                }
                if (!(string.IsNullOrEmpty(f.OrphanNursemaid.FirstName) && string.IsNullOrEmpty(f.OrphanNursemaid.LastName)))
                {
                    if (!f.OrphanNursemaid.IsValidate())
                    {
                        return;
                    }
                }
                if (!string.IsNullOrEmpty(f.FamilyHouse.OldAddress) || !string.IsNullOrEmpty(f.FamilyHouse.Address))
                {
                    if (!f.FamilyHouse.IsValidate())
                    {
                        return;
                    }
                }
                foreach (var fp in cOrphanFamily.dgChild.ItemsSource as List <FamilyPerson> )
                {
                    if (!fp.IsValidate())
                    {
                        return;
                    }
                }

                if (cOrphanFamily.Orphans == null || cOrphanFamily.Orphans.Count == 0)
                {
                    MyMessageBox.Show("يجب ادخال بيانات الايتام");
                    return;
                }

                if (!f.FamilyID.HasValue)
                {
                    if (!DBMain.InsertData(f))
                    {
                        return;
                    }
                    else
                    {
                        MyMessage.InsertMessage();
                        var tih = this.Parent as TabItem;
                        if (tih != null)
                        {
                            tih.Header = f.FamilyCode + " " + f.FamilyName;
                        }
                    }
                }
                else if (!DBMain.UpdateData(f))
                {
                    return;
                }
                else
                {
                    MyMessage.UpdateMessage();
                }

                //Father
                if (!(string.IsNullOrEmpty(f.FamilyFather.FirstName) && string.IsNullOrEmpty(f.FamilyFather.LastName)))
                {
                    if (f.FamilyFather.ParentrID.HasValue)
                    {
                        DBMain.UpdateData(f.FamilyFather);
                    }
                    else
                    {
                        DBMain.InsertData(f.FamilyFather);
                    }
                }
                else if (f.FamilyFather.ParentrID.HasValue)
                {
                    DBMain.DeleteData(f.FamilyFather);
                }
                //Mother
                if (!(string.IsNullOrEmpty(f.FamilyMother.FirstName) && string.IsNullOrEmpty(f.FamilyMother.LastName)))
                {
                    if (f.FamilyMother.ParentrID.HasValue)
                    {
                        DBMain.UpdateData(f.FamilyMother);
                    }
                    else
                    {
                        DBMain.InsertData(f.FamilyMother);
                    }
                }
                else if (f.FamilyMother.ParentrID.HasValue)
                {
                    DBMain.DeleteData(f.FamilyMother);
                }
                //Guardian
                if (!(string.IsNullOrEmpty(f.OrphanGuardian.FirstName) && string.IsNullOrEmpty(f.OrphanGuardian.LastName)))
                {
                    f.OrphanGuardian.FamilyID = f.FamilyID;
                    if (f.OrphanGuardian.GuardianID.HasValue)
                    {
                        Guardian.UpdateData(f.OrphanGuardian);
                    }
                    else
                    {
                        Guardian.InsertData(f.OrphanGuardian);
                    }
                }
                else if (f.OrphanGuardian.GuardianID.HasValue)
                {
                    Guardian.DeleteData(f.OrphanGuardian);
                }
                //Nursemaid
                if (!(string.IsNullOrEmpty(f.OrphanNursemaid.FirstName) && string.IsNullOrEmpty(f.OrphanNursemaid.LastName)))
                {
                    f.OrphanNursemaid.FamilyID = f.FamilyID;
                    if (f.OrphanNursemaid.GuardianID.HasValue)
                    {
                        Guardian.UpdateData(f.OrphanNursemaid);
                    }
                    else
                    {
                        Guardian.InsertData(f.OrphanNursemaid);
                    }
                }
                else if (f.OrphanNursemaid.GuardianID.HasValue)
                {
                    Guardian.DeleteData(f.OrphanNursemaid);
                }

                f.FamilyHouse.FamilyID = f.FamilyID;
                if (!string.IsNullOrEmpty(f.FamilyHouse.OldAddress) || !string.IsNullOrEmpty(f.FamilyHouse.HouseSection))
                {
                    if (f.FamilyHouse.HouseID == null)
                    {
                        DBMain.InsertData(f.FamilyHouse);
                    }
                    else
                    {
                        DBMain.UpdateData(f.FamilyHouse);
                    }
                }

                foreach (var fp in cOrphanFamily.dgChild.ItemsSource as List <FamilyPerson> )
                {
                    if (fp.FamilyPersonID.HasValue)
                    {
                        DBMain.UpdateData(fp);
                    }
                    else if (f.FamilyID.HasValue)
                    {
                        fp.FamilyID = f.FamilyID;
                        DBMain.InsertData(fp);
                    }
                }
                foreach (var o in cOrphanFamily.Orphans)
                {
                    if (o.OrphanID.HasValue)
                    {
                        Orphan.UpdateData(o);
                    }
                    else if (f.FamilyID.HasValue)
                    {
                        if (Orphan.InsertData(o))
                        {
                            o.Account                = new Account();
                            o.Account.Name           = o.FirstName + " " + o.LastName;
                            o.Account.Type           = o.Type == "يتيم" ? Account.AccountType.Orphan : o.Type == "يتيم طالب علم" ? Account.AccountType.OrphanStudent : Account.AccountType.Student;
                            o.Account.CurrentBalance = 0;
                            o.Account.CreateDate     = BaseDataBase.DateNow;
                            o.Account.OwnerID        = o.OrphanID;
                            o.Account.Status         = "مفعل";
                            o.Account.IsDebit        = true;

                            Account.InsertData(o.Account);
                        }
                    }
                }
                cFamilyNeed.FamilyID            = f.FamilyID;
                cExternalFamilySupport.FamilyID = f.FamilyID;
                cSpecialCard.FamilyID           = f.FamilyID;
                cListerGroup.FamilyID           = f.FamilyID;
                cOrders.FamilyID = f.FamilyID;

                f.UpdateFamilyPersonCount();
            }
        }
示例#20
0
        public static List <Orphan> GetAllOrphan(bool ContainFamilyData = false)
        {
            List <Orphan> xx  = new List <Orphan>();
            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_Get_All_Orphan", con);

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

                    if (!(rd["OrphanID"] is DBNull))
                    {
                        x.OrphanID = int.Parse(rd["OrphanID"].ToString());
                    }
                    if (!(rd["FamilyID"] is DBNull) && ContainFamilyData)
                    {
                        x.OrphanFamily = Family.GetFamilyByID(int.Parse(rd["FamilyID"].ToString()));
                    }
                    x.FirstName  = rd["FirstName"].ToString();
                    x.LastName   = rd["LastName"].ToString();
                    x.Gender     = rd["Gender"].ToString();
                    x.BirthPlace = rd["BirthPlace"].ToString();
                    if (!(rd["DOB"] is DBNull))
                    {
                        x.DOB = DateTime.Parse(rd["DOB"].ToString());
                    }
                    x.Nationality = rd["Nationality"].ToString();
                    x.PID         = rd["PID"].ToString();
                    x.Mobile      = rd["Mobile"].ToString();
                    x.Email       = rd["Email"].ToString();
                    x.Notes       = rd["Notes"].ToString();
                    x.Image       = rd["Image"].ToString();
                    if (!(rd["Tall"] is DBNull))
                    {
                        x.Tall = int.Parse(rd["Tall"].ToString());
                    }
                    if (!(rd["Weight"] is DBNull))
                    {
                        x.Weight = int.Parse(rd["Weight"].ToString());
                    }
                    if (!(rd["FeetSize"] is DBNull))
                    {
                        x.FeetSize = int.Parse(rd["FeetSize"].ToString());
                    }
                    if (!(rd["WaistSize"] is DBNull))
                    {
                        x.WaistSize = int.Parse(rd["WaistSize"].ToString());
                    }
                    x.Status = rd["Status"].ToString();
                    x.Type   = rd["Type"].ToString();
                    xx.Add(x);
                }
                rd.Close();
            }
            catch
            {
                xx = null;
            }
            finally
            {
                con.Close();
            }
            return(xx);
        }
示例#21
0
        public static Orphan GetOrphanByID(int id, Family f = null)
        {
            Orphan        x   = new Orphan();
            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_Get_ID_Orphan", con);

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

            com.Parameters.Add(pr);
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                if (rd.Read())
                {
                    if (!(rd["OrphanID"] is DBNull))
                    {
                        x.OrphanID = int.Parse(rd["OrphanID"].ToString());
                    }
                    x.OrphanFamily = f == null?Family.GetFamilyByID(int.Parse(rd["FamilyID"].ToString())) : f;

                    x.FirstName  = rd["FirstName"].ToString();
                    x.LastName   = rd["LastName"].ToString();
                    x.Gender     = rd["Gender"].ToString();
                    x.BirthPlace = rd["BirthPlace"].ToString();
                    if (!(rd["DOB"] is DBNull))
                    {
                        x.DOB = DateTime.Parse(rd["DOB"].ToString());
                    }
                    x.Nationality = rd["Nationality"].ToString();
                    x.PID         = rd["PID"].ToString();
                    x.Mobile      = rd["Mobile"].ToString();
                    x.Email       = rd["Email"].ToString();
                    x.Notes       = rd["Notes"].ToString();
                    x.Image       = rd["Image"].ToString();
                    if (!(rd["Tall"] is DBNull))
                    {
                        x.Tall = int.Parse(rd["Tall"].ToString());
                    }
                    if (!(rd["Weight"] is DBNull))
                    {
                        x.Weight = int.Parse(rd["Weight"].ToString());
                    }
                    if (!(rd["FeetSize"] is DBNull))
                    {
                        x.FeetSize = int.Parse(rd["FeetSize"].ToString());
                    }
                    if (!(rd["WaistSize"] is DBNull))
                    {
                        x.WaistSize = int.Parse(rd["WaistSize"].ToString());
                    }
                    x.Status = rd["Status"].ToString();
                    x.Type   = rd["Type"].ToString();
                }
                rd.Close();
            }
            catch (Exception ex)
            {
                x = null;
            }
            finally
            {
                con.Close();
            }
            return(x);
        }
示例#22
0
 public static bool DeleteData(Orphan x)
 {
     return(BaseDataBase._StoredProcedure("sp_Delete_Orphan"
                                          , new SqlParameter("@OrphanID", x.OrphanID)));
 }