Ejemplo n.º 1
0
 private void btnDelLister_Click(object sender, RoutedEventArgs e)
 {
     if (dgListers.SelectedIndex != -1)
     {
         if (!BaseDataBase.CurrentUser.CanDelete)
         {
             MyMessageBox.Show("ليس لديك صلاحيات للحذف");
         }
         else
         {
             Lister l = Lister.GetListerByID((int)(dgListers.Items[dgListers.SelectedIndex] as DataRowView)[0]);
             if (int.Parse(BaseDataBase._Scalar("select dbo.GetGroupCountByListerID(" + l.ListerID + ")")) > 0)
             {
                 MyMessageBox.Show("لا يمكن حذف المقيّم \nبسبب وجود بيانات تقييم سابقة له ضمن فرق التقييم");
             }
             else if (int.Parse(BaseDataBase._Scalar("select COUNT(ID) from Trained where TrainedType = 2 and TrainedID = " + l.ListerID)) > 0)
             {
                 MyMessageBox.Show("لا يمكن حذف المقيّم \nبسبب وجود بيانات تدريب سابقة له");
             }
             else if (DBMain.DeleteData(l))
             {
                 dgListers.ItemsSource = Lister.GetAllListersTable;
                 MyMessage.DeleteMessage();
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void DeleteFamilyPerson_CommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            if (!BaseDataBase.CurrentUser.CanUpdateFamily)
            {
                MyMessageBox.Show("ليس لديك صلاحية حذف");
                return;
            }
            FamilyPerson fp = dgChild.SelectedCells[0].Item as FamilyPerson;

            if (fp != null)
            {
                if (MyMessageBox.Show("هل تريد حذف السجل؟", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    var fps = dgChild.ItemsSource as List <FamilyPerson>;
                    if (fp != null)
                    {
                        dgChild.ItemsSource = null;
                        if (fp.FamilyPersonID.HasValue)
                        {
                            DBMain.DeleteData(fp);
                        }
                        fps.Remove(fp);
                        dgChild.ItemsSource = fps;
                    }
                }
            }
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            var x = this.DataContext as AdminEvaluation;

            if (x.FamilyID == null && x.OrphanID == null)
            {
                MyMessageBox.Show("لم يتم إدخال بيانات العائلة او اليتيم");
                return;
            }
            if (x.ID != null)
            {
                if (!BaseDataBase.CurrentUser.CanDelete)
                {
                    MyMessageBox.Show("لا يوجد لديك صلاحيات للحذف");
                }
                else if (DBMain.DeleteData(x))
                {
                    MyMessage.UpdateMessage();
                    if (FamilyID != null)
                    {
                        FamilyID = FamilyID;
                    }
                    else
                    {
                        OrphanID = OrphanID;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 private void btnDeleteFamilyData_Click(object sender, RoutedEventArgs e)
 {
     if (dgFamily.SelectedIndex != -1)
     {
         if (!BaseDataBase.CurrentUser.PointAdmin)
         {
             MyMessageBox.Show("ليس لديك صلاحيات للحذف");
         }
         else
         {
             Family f = Family.GetFamilyByID((int)(dgFamily.Items[dgFamily.SelectedIndex] as DataRowView)[0]);
             if (MyMessageBox.Show("هل تريد تأكيد حذف بيانات العائلة", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
             {
                 if (DBMain.DeleteData(f))
                 {
                     dt = BaseDataBase._TablingStoredProcedure("sp_GetFamilyAllTable");
                     SetItemsSource(1);
                     Control_Changed(null, null);
                     MyMessage.DeleteMessage();
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            var x = this.DataContext as FamilyNeed;

            if (x.FamilyNeedID != null)
            {
                if (!BaseDataBase.CurrentUser.CanDelete)
                {
                    MyMessageBox.Show("لا يوجد لديك صلاحيات للحذف");
                }
                else if (MyMessageBox.Show("هل تريد تأكيد حذف البيانات", MessageBoxButton.YesNo) == MessageBoxResult.Yes && DBMain.DeleteData(x))
                {
                    MyMessage.DeleteMessage();
                    FamilyID = FamilyID;
                    UpdateCombo();
                }
            }
        }
        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();
            }
        }
Ejemplo n.º 7
0
        private void btnDelParent_Click(object sender, RoutedEventArgs e)
        {
            var x = this.DataContext as Parent;

            if (x.ParentrID != null)
            {
                if (!BaseDataBase.CurrentUser.CanDelete)
                {
                    MyMessageBox.Show("لا يوجد لديك صلاحيات للحذف");
                }
                else if (MyMessageBox.Show("هل تريد تأكيد حذف البيانات\n\nملاحظة:\nسيتم حذف كل من: المؤهلات، الحالة الصحية، الدورات التدريبية والأخوة للوالد", MessageBoxButton.YesNo) == MessageBoxResult.Yes && DBMain.DeleteData(x))
                {
                    BaseDataBase.MakeTabItemRed(this.Parent as TabItem);
                    MyMessage.DeleteMessage();
                    Parent p;
                    if (x.Gender == "ذكر")
                    {
                        p = new Father();
                    }
                    else
                    {
                        p = new Mother();
                    }
                    p.FamilyID       = x.FamilyID;
                    this.DataContext = p;
                }
            }
        }
Ejemplo n.º 8
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (!BaseDataBase.CurrentUser.CanUpdateFamily)
            {
                MyMessageBox.Show("ليس لديك صلاحية تعديل بيانات عائلة");
                return;
            }
            MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
            var f = cFamily.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.FamilyHouse.OldAddress) || !string.IsNullOrEmpty(f.FamilyHouse.Address))
                {
                    if (!f.FamilyHouse.IsValidate())
                    {
                        return;
                    }
                }
                foreach (var fp in cFamily.dgChild.ItemsSource as List <FamilyPerson> )
                {
                    if (!fp.IsValidate())
                    {
                        return;
                    }
                }

                if (DBMain.UpdateData(f))
                {
                    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);
                    }

                    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);
                    }

                    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 cFamily.dgChild.ItemsSource as List <FamilyPerson> )
                    {
                        if (!fp.FamilyPersonID.HasValue)
                        {
                            fp.FamilyID = f.FamilyID;
                            DBMain.InsertData(fp);
                        }
                        else
                        {
                            DBMain.UpdateData(fp);
                        }
                    }
                    f.UpdateFamilyPersonCount();
                    MyMessage.UpdateMessage();
                }
            }
        }