Ejemplo n.º 1
0
        private static List <Lister> GetListersAllByGroupID(int?id)
        {
            List <Lister> ls  = new List <Lister>();
            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_GetListersAllByGroupID", con);

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

            com.Parameters.Add(pr);
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                while (rd.Read())
                {
                    ls.Add(Lister.GetListerByID(rd.GetInt32(0)));
                }
                rd.Close();
            }
            catch
            {
                ls = new List <Lister>();
            }
            finally
            {
                con.Close();
            }
            return(ls);
        }
 private void Control_Changed(object sender, TextChangedEventArgs e)
 {
     if (dgListers.ItemsSource != null)
     {
         ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(dgListers.ItemsSource);
         view.Filter = delegate(object item)
         {
             Lister l = (Lister)item;
             if (txtFirstName.Text != "" && !l.FirstName.Contains(txtFirstName.Text))
             {
                 return(false);
             }
             if (txtLastName.Text != "" && !l.LastName.Contains(txtLastName.Text))
             {
                 return(false);
             }
             if (cmboGender.SelectedIndex > 0)
             {
                 return((cmboGender.SelectedIndex == 1) ? (l.Gender == "ذكر") : (l.Gender == "أنثى"));
             }
             return(true);
         };
         view.Refresh();
     }
 }
Ejemplo n.º 3
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.º 4
0
        public ListerControl(int ListerID)
        {
            InitializeComponent();
            this.DataContext = Lister.GetListerByID(ListerID);

            btnExecute.Visibility = System.Windows.Visibility.Hidden;
            btnUpdate.Visibility  = System.Windows.Visibility.Visible;
        }
 private void btnDelLister_Click(object sender, RoutedEventArgs e)
 {
     if (lbListerGroup.SelectedIndex != -1)
     {
         List <Lister> ListersLB = (List <Lister>)lbListerGroup.ItemsSource;
         Lister        l         = lbListerGroup.SelectedItem as Lister;
         ListersLB.Remove(l);
         lbListerGroup.Items.Refresh();
     }
 }
Ejemplo n.º 6
0
        public static Lister GetListerByID(int?id)
        {
            Lister        x   = new Lister();
            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_GetListerByID", con);

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

            com.Parameters.Add(pr);
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                if (rd.Read())
                {
                    if (!(rd["ListerID"] is DBNull))
                    {
                        x.ListerID = System.Int32.Parse(rd["ListerID"].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 = System.DateTime.Parse(rd["DOB"].ToString());
                    }
                    x.Job           = rd["Job"].ToString();
                    x.Phone         = rd["Phone"].ToString();
                    x.Mobile        = rd["Mobile"].ToString();
                    x.Email         = rd["Email"].ToString();
                    x.MaritalStatus = rd["MaritalStatus"].ToString();
                    if (!(rd["ChildCount"] is DBNull))
                    {
                        x.ChildCount = System.Int32.Parse(rd["ChildCount"].ToString());
                    }
                    x.PlaceAddress        = rd["PlaceAddress"].ToString();
                    x.ScientificQualifier = rd["ScientificQualifier"].ToString();
                    x.IdentityImage       = rd["IdentityImage"].ToString();
                    x.Notes = rd["Notes"].ToString();
                }
                rd.Close();
            }
            catch
            {
                x = null;
            }
            finally
            {
                con.Close();
            }
            return(x);
        }
Ejemplo n.º 7
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            Lister x = (Lister)this.DataContext;

            if (x.IsValidate())
            {
                if (DBMain.UpdateData(x))
                {
                    MyMessage.UpdateMessage();
                    DialogResult = true;
                }
            }
        }
 private void btnAddLister_Click(object sender, RoutedEventArgs e)
 {
     if (dgListers.SelectedIndex != -1)
     {
         List <Lister> ListersLB;
         if (lbListerGroup.ItemsSource == null)
         {
             ListersLB = new List <Lister>();
             lbListerGroup.ItemsSource = ListersLB;
         }
         else
         {
             ListersLB = lbListerGroup.ItemsSource as List <Lister>;
         }
         Lister l = dgListers.SelectedItem as Lister;
         if (!ListersLB.Contains(l))
         {
             ListersLB.Add(l);
         }
         lbListerGroup.Items.Refresh();
     }
 }
Ejemplo n.º 9
0
        //Done :)
        public static List <ListerGroup> GetListerGroupsByFamilyID(int?FamilyID)
        {
            List <ListerGroup> lgs = new List <ListerGroup>();
            SqlConnection      con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand         com = new SqlCommand("sp_Get_All_ListerGroups_ByFamilyID", con);

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

            com.Parameters.Add(pr);
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                ListerGroup   lg = null;
                while (rd.Read())
                {
                    if (lg == null || (int)rd["ListerGroupID"] != lg.GroupID.Value)
                    {
                        lg         = new ListerGroup();
                        lg.GroupID = (int)rd["ListerGroupID"];
                        if (!(rd["OrphanID"] is DBNull))
                        {
                            lg.OrphanID = System.Int32.Parse(rd["OrphanID"].ToString());
                        }
                        if (!(rd["Date"] is DBNull))
                        {
                            lg.Date = System.DateTime.Parse(rd["Date"].ToString());
                        }
                        lg.Evaluation   = rd["Evaluation"].ToString();
                        lg.Notes        = rd["ListerGroupNotes"].ToString();
                        lg.CreatePerson = rd["CreatePerson"].ToString();
                        if (!(rd["CreateDate"] is DBNull))
                        {
                            lg.CreateDate = System.DateTime.Parse(rd["CreateDate"].ToString());
                        }
                        lg.LastModifiedPerson = rd["LastModifiedPerson"].ToString();
                        lg.Notes = rd["ListerGroupNotes"].ToString();
                        if (!(rd["FamilyID"] is DBNull))
                        {
                            lg.FamilyID = System.Int32.Parse(rd["FamilyID"].ToString());
                        }

                        lgs.Add(lg);
                    }
                    Lister l = new Lister();
                    l.ListerID   = System.Int32.Parse(rd["ListerListerID"].ToString());
                    l.FirstName  = rd["FirstName"].ToString();
                    l.LastName   = rd["LastName"].ToString();
                    l.Gender     = rd["Gender"].ToString();
                    l.BirthPlace = rd["BirthPlace"].ToString();
                    if (!(rd["DOB"] is DBNull))
                    {
                        l.DOB = System.DateTime.Parse(rd["DOB"].ToString());
                    }
                    l.Job           = rd["Job"].ToString();
                    l.Phone         = rd["Phone"].ToString();
                    l.Mobile        = rd["Mobile"].ToString();
                    l.Email         = rd["Email"].ToString();
                    l.MaritalStatus = rd["MaritalStatus"].ToString();
                    if (!(rd["ChildCount"] is DBNull))
                    {
                        l.ChildCount = System.Int32.Parse(rd["ChildCount"].ToString());
                    }
                    l.PlaceAddress        = rd["PlaceAddress"].ToString();
                    l.ScientificQualifier = rd["ScientificQualifier"].ToString();
                    l.IdentityImage       = rd["IdentityImage"].ToString();
                    l.Notes = rd["ListerNotes"].ToString();

                    lg.Listers.Add(l);
                    // lg.FamilyNeeds = FamilyNeed_ListerGroup.GetFamilyNeed_ListerGroupByListerGroupID(lg.GroupID.Value);
                }
                rd.Close();
            }
            catch
            {
                lgs = new List <ListerGroup>();
            }
            finally
            {
                con.Close();
            }
            return(lgs);
        }