private void RefreshDataGridView(FrmMaster _frmMaster, EGOEntities _egoEntities)
        {
            Cursor.Current = Cursors.WaitCursor;
            _frmMaster.dataGridView.Columns.Clear();
            switch (typeof(T).Name)
            {
            case "FAMILY":
                string           lastNameFamily   = _frmMaster.textBox1.Text;
                FamilySearchView familySearchView = new FamilySearchView(_egoEntities.FAMILY.Where(x => x.LASTNAME.Contains(lastNameFamily)).ToList().OrderBy(x => x.LASTNAME).ToList());
                _frmMaster.dataGridView.DataSource = familySearchView.FamilySearchViews;
                _frmMaster.dataGridView.Columns["FAMILYID"].Visible = false;
                AddColumnEditDeleteToDataGridView(_frmMaster, false);
                DataGridViewControl.SetHeaderName(_frmMaster.dataGridView);
                SetAutoCompletion(_frmMaster.textBox1, familySearchView.FamilySearchViews.Select(x => x.LASTNAME).ToList());
                _frmMaster.label3.Text = "Famille(" + familySearchView.FamilySearchViews.Count + ")";
                break;

            case "PERSON":
                string lastNamePerson = _frmMaster.textBox1.Text;
                PersonMasterSearchView personSearchView = new PersonMasterSearchView(_egoEntities.PERSON.Where(x => x.LASTNAME.Contains(lastNamePerson)).ToList().OrderBy(x => x.LASTNAME).ToList());
                _frmMaster.dataGridView.DataSource = personSearchView.PersonSearchViews;
                _frmMaster.dataGridView.Columns["PERSONID"].Visible = false;
                AddColumnEditDeleteToDataGridView(_frmMaster, false);
                DataGridViewControl.SetHeaderName(_frmMaster.dataGridView);
                SetAutoCompletion(_frmMaster.textBox1, personSearchView.PersonSearchViews.Select(x => x.LASTNAME).ToList());
                _frmMaster.label3.Text = "Adhérent(" + personSearchView.PersonSearchViews.Count + ")";
                break;

            case "GYMGROUP":
                string             gymGroupName       = _frmMaster.textBox1.Text;
                GymGroupSearchView gymGroupSearchView = new GymGroupSearchView(_egoEntities.GYMGROUP.Where(x => x.GYMGROUPNAME.Contains(gymGroupName) && x.GYMGROUPYEAR == _frmMaster.numericUpDown1.Value).ToList());
                _frmMaster.dataGridView.DataSource = gymGroupSearchView.GymGroupSearchViews;
                _frmMaster.dataGridView.Columns["GYMGROUPID"].Visible = false;
                AddColumnEditDeleteToDataGridView(_frmMaster, false);
                DataGridViewControl.SetHeaderName(_frmMaster.dataGridView);
                SetAutoCompletion(_frmMaster.textBox1, gymGroupSearchView.GymGroupSearchViews.Select(x => x.GYMGROUPNAME).ToList());
                _frmMaster.label3.Text = "Groupe - " + _frmMaster.numericUpDown1.Value + "(" + gymGroupSearchView.GymGroupSearchViews.Count + ")";
                break;
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #2
0
        private void RefreshDataGridView(FrmSlave _frmSlave, int _currentStartYear)
        {
            _frmSlave.dataGridView.Columns.Clear();
            string masterObjectTypeName = GetObjectTypeName(masterObj);

            if (typeof(T).Name == "PERSON")
            {
                if (masterObjectTypeName == "FAMILY")
                {
                    int _familyId = Convert.ToInt32(Reflection.GetValue(masterObj, "FAMILYID"));
                    PersonSlaveSearchView _personSlaveSearchView = new PersonSlaveSearchView(egoEntities.PERSON.Where(x => x.FAMILYID == _familyId).ToList(), _currentStartYear);
                    _frmSlave.dataGridView.DataSource = _personSlaveSearchView.PersonSlaveSearchViews;
                    _frmSlave.dataGridView.Columns["PERSONID"].Visible = false;
                    AddColumnEditDeleteToDataGridView(_frmSlave, false);
                    DataGridViewControl.SetHeaderName(_frmSlave.dataGridView);
                    frmSlave.label1.Text = Translation.GetByKey(typeof(T).Name) + "(" + _personSlaveSearchView.PersonSlaveSearchViews.Count + ")";
                }
                if (masterObjectTypeName == "GYMGROUP")
                {
                    int _gymGroupId = Convert.ToInt32(Reflection.GetValue(masterObj, masterObjectTypeName + "ID"));
                    if (_gymGroupId == 0)
                    {
                        return;
                    }
                    GymGroupPersonSearchView _gymGroupPersonSearchView = new GymGroupPersonSearchView(egoEntities.PERSON_GYMGROUP.Where(x => x.GYMGROUPID == _gymGroupId).ToList());
                    _frmSlave.dataGridView.DataSource = _gymGroupPersonSearchView.GymGroupPersonSearchViews;
                    _frmSlave.dataGridView.Columns["PERSON_GYMGROUP_ID"].Visible = false;
                    AddColumnEditDeleteToDataGridView(_frmSlave, true);
                    DataGridViewControl.SetHeaderName(_frmSlave.dataGridView);
                    frmSlave.label1.Text = Translation.GetByKey(typeof(T).Name) + "(" + _gymGroupPersonSearchView.GymGroupPersonSearchViews.Count + ")";
                }
            }
            else if (typeof(T).Name == "PHONE")
            {
                if (masterObjectTypeName == "FAMILY")
                {
                    int             _familyId        = Convert.ToInt32(Reflection.GetValue(masterObj, "FAMILYID"));
                    PhoneSearchView _phoneSearchView = new PhoneSearchView(egoEntities.PHONE.Where(x => x.FAMILYID == _familyId).ToList());
                    _frmSlave.dataGridView.DataSource = _phoneSearchView.PhoneSearchViews;
                    _frmSlave.dataGridView.Columns["PHONEID"].Visible = false;
                    AddColumnEditDeleteToDataGridView(_frmSlave, false);
                    DataGridViewControl.SetHeaderName(_frmSlave.dataGridView);
                    frmSlave.label1.Text = Translation.GetByKey(typeof(T).Name) + "(" + _phoneSearchView.PhoneSearchViews.Count + ")";
                }
            }
            else if (typeof(T).Name == "DISCOUNT")
            {
                if (masterObjectTypeName == "FAMILY")
                {
                    int _familyId = Convert.ToInt32(Reflection.GetValue(masterObj, "FAMILYID"));
                    DiscountSearchView _discountSearchView = new DiscountSearchView(egoEntities.DISCOUNT.Where(x => x.FAMILYID == _familyId).ToList());
                    _frmSlave.dataGridView.DataSource = _discountSearchView.DiscountSearchViews;
                    _frmSlave.dataGridView.Columns["DISCOUNTID"].Visible = false;
                    AddColumnEditDeleteToDataGridView(_frmSlave, false);
                    DataGridViewControl.SetHeaderName(_frmSlave.dataGridView);
                    frmSlave.label1.Text = Translation.GetByKey(typeof(T).Name) + "(" + _discountSearchView.DiscountSearchViews.Count + ")";
                }
            }
            else if (typeof(T).Name == "PAYMENT")
            {
                if (masterObjectTypeName == "FAMILY")
                {
                    int _familyId = Convert.ToInt32(Reflection.GetValue(masterObj, "FAMILYID"));
                    PaymentSearchView _paymentSearchView = new PaymentSearchView(egoEntities.PAYMENT.Where(x => x.FAMILYID == _familyId).ToList());
                    _frmSlave.dataGridView.DataSource = _paymentSearchView.PaymentSearchViews;
                    _frmSlave.dataGridView.Columns["PAYMENTID"].Visible = false;
                    AddColumnEditDeleteToDataGridView(_frmSlave, false);
                    DataGridViewControl.SetHeaderName(_frmSlave.dataGridView);
                    frmSlave.label1.Text = Translation.GetByKey(typeof(T).Name) + "(" + _paymentSearchView.PaymentSearchViews.Count + ")";
                }
            }
            else if (typeof(T).Name == "DOCUMENT")
            {
                if (masterObjectTypeName == "PERSON")
                {
                    int _personId = Convert.ToInt32(Reflection.GetValue(masterObj, "PERSONID"));
                    DocumentSearchView _documentSearchView = new DocumentSearchView(egoEntities.DOCUMENT.Where(x => x.PERSONID == _personId).ToList());
                    _frmSlave.dataGridView.DataSource = _documentSearchView.DocumentSearchViews;
                    _frmSlave.dataGridView.Columns["DOCUMENTID"].Visible = false;
                    AddColumnEditDeleteToDataGridView(_frmSlave, false);
                    DataGridViewControl.SetHeaderName(_frmSlave.dataGridView);
                    frmSlave.label1.Text = Translation.GetByKey(typeof(T).Name) + "(" + _documentSearchView.DocumentSearchViews.Count + ")";
                }
            }
            else if (typeof(T).Name == "GYMGROUP")
            {
                if (masterObjectTypeName == "PERSON")
                {
                    int _personId = Convert.ToInt32(Reflection.GetValue(masterObj, "PERSONID"));
                    PersonGymGroupSearchView _personGymGroupSearchView = new PersonGymGroupSearchView(egoEntities.PERSON_GYMGROUP.Where(x => x.PERSONID == _personId).ToList());
                    _frmSlave.dataGridView.DataSource = _personGymGroupSearchView.PersonGymGroupSearchViews;
                    _frmSlave.dataGridView.Columns["PERSON_GYMGROUP_ID"].Visible = false;
                    AddColumnEditDeleteToDataGridView(_frmSlave, true);
                    DataGridViewControl.SetHeaderName(_frmSlave.dataGridView);
                    frmSlave.label1.Text = Translation.GetByKey(typeof(T).Name) + "(" + _personGymGroupSearchView.PersonGymGroupSearchViews.Count + ")";
                }
            }
        }