private void SearchBanksForm_Load(object sender, EventArgs e)
        {
            try
            {
                AccountFields.Add(new Field("banksortcode", "string"));
                AccountFields.Add(new Field("bankcode", "string"));
                AccountFields.Add(new Field("bankname", "string"));
                AccountFields.Add(new Field("branchcode", "string"));
                AccountFields.Add(new Field("branchname", "string"));

                cbField.DataSource    = AccountFields;
                cbField.DisplayMember = "Name";
                cbField.ValueMember   = "Name";

                cbOperator.DataSource    = Op.GetList();
                cbOperator.DisplayMember = "Description";
                cbOperator.ValueMember   = "Symbol";

                lstCriteria.DataSource = criteriaBuilder.CriterionItemList();

                var _Banksquery = from b in db.Banks
                                  select b;
                List <Bank> _Banks = _Banksquery.ToList();


                DataGridViewComboBoxColumn colBank = new DataGridViewComboBoxColumn();
                colBank.HeaderText                 = "Bank";
                colBank.Name                       = "cbBank";
                colBank.DataSource                 = _Banks;
                colBank.DisplayMember              = "BankName";
                colBank.DataPropertyName           = "BankCode";
                colBank.ValueMember                = "BankCode";
                colBank.MaxDropDownItems           = 10;
                colBank.DisplayIndex               = 4;
                colBank.MinimumWidth               = 5;
                colBank.Width                      = 200;
                colBank.AutoSizeMode               = DataGridViewAutoSizeColumnMode.Fill;
                colBank.FlatStyle                  = FlatStyle.Flat;
                colBank.DefaultCellStyle.NullValue = "--- Select ---";
                colBank.ReadOnly                   = true;
                if (!this.dataGridViewBanks.Columns.Contains("cbBank"))
                {
                    dataGridViewBanks.Columns.Add(colBank);
                }

                var _BankBranchesquery = from bb in db.BankBranches
                                         select bb;
                List <BankBranch> _BankBranches = _BankBranchesquery.ToList();

                DataGridViewComboBoxColumn colBranch = new DataGridViewComboBoxColumn();
                colBranch.HeaderText                 = "Branch";
                colBranch.Name                       = "cbBranch";
                colBranch.DataSource                 = _BankBranches;
                colBranch.DisplayMember              = "BranchName";
                colBranch.DataPropertyName           = "BankSortCode";
                colBranch.ValueMember                = "BankSortCode";
                colBranch.MaxDropDownItems           = 10;
                colBranch.DisplayIndex               = 3;
                colBranch.MinimumWidth               = 5;
                colBranch.Width                      = 150;
                colBranch.FlatStyle                  = FlatStyle.Flat;
                colBranch.DefaultCellStyle.NullValue = "--- Select ---";
                colBranch.ReadOnly                   = true;
                if (!this.dataGridViewBanks.Columns.Contains("cbBranch"))
                {
                    dataGridViewBanks.Columns.Add(colBranch);
                }

                this.dataGridViewBanks.AutoGenerateColumns = false;
                this.dataGridViewBanks.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }
Ejemplo n.º 2
0
        private void SelectForm_Load(object sender, EventArgs e)
        {
            try
            {
                empFields.Add(new Field("EmpNo", "string"));
                empFields.Add(new Field("Surname", "string"));
                empFields.Add(new Field("DoB", "date"));
                empFields.Add(new Field("DoE", "date"));
                empFields.Add(new Field("Department", "string"));
                empFields.Add(new Field("MaritalStatus", "string"));
                empFields.Add(new Field("PayPoint", "string"));
                empFields.Add(new Field("EmpGroup", "string"));
                empFields.Add(new Field("EmpPayroll", "string"));
                empFields.Add(new Field("Gender", "string"));

                cbField.DataSource    = empFields;
                cbField.DisplayMember = "Name";
                cbField.ValueMember   = "Name";

                cbOperator.DataSource    = Op.GetList();
                cbOperator.DisplayMember = "Description";
                cbOperator.ValueMember   = "Symbol";

                lbCriteria.DataSource = criteriaBuilder.CriterionItemList();

                var _departmentsquery = from dp in db.Departments
                                        select dp;
                List <Department>          _Departments      = _departmentsquery.ToList();
                DataGridViewComboBoxColumn colCboxDepartment = new DataGridViewComboBoxColumn();
                colCboxDepartment.HeaderText = "Department";
                colCboxDepartment.Name       = "cbDepartment";
                colCboxDepartment.DataSource = _Departments;
                // The display member is the name column in the column datasource
                colCboxDepartment.DisplayMember = "Description";
                // The DataPropertyName refers to the foreign key column on the datagridview datasource
                colCboxDepartment.DataPropertyName = "Department";
                // The value member is the primary key of the parent table
                colCboxDepartment.ValueMember                = "Code";
                colCboxDepartment.MaxDropDownItems           = 10;
                colCboxDepartment.Width                      = 100;
                colCboxDepartment.DisplayIndex               = 4;
                colCboxDepartment.MinimumWidth               = 5;
                colCboxDepartment.AutoSizeMode               = DataGridViewAutoSizeColumnMode.Fill;
                colCboxDepartment.FlatStyle                  = FlatStyle.Flat;
                colCboxDepartment.DefaultCellStyle.NullValue = "--- Select ---";
                colCboxDepartment.ReadOnly                   = true;
                if (!this.dataGridViewEmployees.Columns.Contains("cbDepartment"))
                {
                    dataGridViewEmployees.Columns.Add(colCboxDepartment);
                }

                var gender = new BindingList <KeyValuePair <string, string> >();
                gender.Add(new KeyValuePair <string, string>("M", "Male"));
                gender.Add(new KeyValuePair <string, string>("F", "Female"));
                DataGridViewComboBoxColumn colCboxGender = new DataGridViewComboBoxColumn();
                colCboxGender.HeaderText = "Gender";
                colCboxGender.Name       = "cbGender";
                colCboxGender.DataSource = gender;
                // The display member is the name column in the column datasource
                colCboxGender.DisplayMember = "Value";
                // The DataPropertyName refers to the foreign key column on the datagridview datasource
                colCboxGender.DataPropertyName = "Gender";
                // The value member is the primary key of the parent table
                colCboxGender.ValueMember      = "Key";
                colCboxGender.MaxDropDownItems = 10;
                colCboxGender.Width            = 100;
                colCboxGender.DisplayIndex     = 3;
                colCboxGender.MinimumWidth     = 5;
                //colCboxGender.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                colCboxGender.FlatStyle = FlatStyle.Flat;
                colCboxGender.DefaultCellStyle.NullValue = "--- Select ---";
                colCboxGender.ReadOnly = true;
                if (!this.dataGridViewEmployees.Columns.Contains("cbGender"))
                {
                    dataGridViewEmployees.Columns.Add(colCboxGender);
                }

                dataGridViewEmployees.AutoGenerateColumns = false;
                this.dataGridViewEmployees.SelectionMode  = DataGridViewSelectionMode.FullRowSelect;
                dataGridViewEmployees.DataSource          = bindingSourceEmployees;
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }