Exemple #1
0
        private void BillDetailEditor_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (Columns[e.ColumnIndex] is DataGridViewButtonColumn col &&
                Rows[e.RowIndex].DataBoundItem is MappedViewModelBase mvm &&
                col.Tag is Type type &&
                type.Is(typeof(DataListBase)))
            {
                PropertyInfo p = mvm.GetRealType().GetProperty(Columns[e.ColumnIndex].DataPropertyName);

                if (p != null && mvm.PropertyMappedEntity.ContainsKey(p.Name))
                {
                    EntityObject entity = mvm.PropertyMappedEntity[p.Name];

                    if (entity != null)
                    {
                        string       entityType = entity.GetType().Name;
                        DataListBase f          = (DataListBase)Activator.CreateInstance(type, entityType);
                        if (f.ShowDialog(this.GetParentForm()) == DialogResult.OK)
                        {
                            EntityObject eo = f.SelectedEntity;
                            mvm.ChangeMappedEntity(Columns[e.ColumnIndex].DataPropertyName, eo);
                            mvm.UpdateEntityMappedValue(eo);

                            //事件
                            EntitySelected?.Invoke(e.RowIndex, e.ColumnIndex, eo);
                            InvalidateRow(e.RowIndex);
                        }
                    }
                }
            }
        }
Exemple #2
0
        public CalculateForm(DataListBase listForm)
        {
            _listForm = listForm;

            var query = from dgv in _listForm.AllGridView
                        from col in dgv.Columns.OfType <DataGridViewColumn>()
                        where !col.DataPropertyName.IsNullOrWhiteSpace() &&
                        !col.Name.StartsWith("STATICCOL") &&
                        col.ValueType.IsNumericType()
                        select new object[] { col.HeaderText, col.DataPropertyName };

            _fieldsTable = new DataTable();
            _fieldsTable.Columns.Add("Text");
            _fieldsTable.Columns.Add("Value");

            foreach (var item in query)
            {
                _fieldsTable.Rows.Add(item);
            }

            InitializeComponent();

            cmbFields.DataSource = _fieldsTable;
        }
Exemple #3
0
        public AdvFilterForm(DataListBase listForm)
        {
            //GetFiledsTable
            _listForm = listForm;
            var query = from dgv in _listForm.AllGridView
                        from col in dgv.Columns.OfType <DataGridViewColumn>()
                        where !col.DataPropertyName.IsNullOrWhiteSpace() && !col.Name.StartsWith("STATICCOL")
                        select new object[] { col.HeaderText, col.DataPropertyName, col.ValueType };

            _dataSource = new DataTable();
            _dataSource.Columns.Add("Text");
            _dataSource.Columns.Add("Value");
            _dataSource.Columns.Add("ValueType", typeof(Type));

            foreach (var item in query)
            {
                _dataSource.Rows.Add(item);
            }

            InitializeComponent();

            flowLayoutPanel1.Controls.Clear();
            bAdd_Click(this, EventArgs.Empty);
        }