/// <summary> /// 标记出警告的行 更新设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewUpdateData_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { foreach (DataGridViewRow dr in this.dataGridViewUpdateData.Rows) { if (dr != null) { UpdateFormDataEvent.UpdateItem update = dr.DataBoundItem as UpdateFormDataEvent.UpdateItem; //新增时,警告字典没有相应的警告信息,也不需要在新增时checkwarning if (this._warningTable.Keys.Contains(update) == false) { continue; } if (this._warningTable[update]) { dr.DefaultCellStyle.BackColor = UIHelper.DataGridViewRowBackColorWarning; dr.DefaultCellStyle.SelectionBackColor = UIHelper.DataGridViewSelectedRowBackColorWarning; dr.DefaultCellStyle.ForeColor = UIHelper.DataGridViewRowForeColorWarning; dr.DefaultCellStyle.SelectionForeColor = UIHelper.DataGridViewSelectedRowForeColorWarning; } else { dr.DefaultCellStyle.BackColor = UIHelper.DataGridViewRowBackColorNormal; dr.DefaultCellStyle.SelectionBackColor = UIHelper.DataGridViewSelectedRowBackColorNormal; dr.DefaultCellStyle.ForeColor = UIHelper.DataGridViewRowForeColorNormal; dr.DefaultCellStyle.SelectionForeColor = UIHelper.DataGridViewSelectedRowForeColorNormal; } } } }
/// <summary> /// 删除更新数据设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeleteUpdate_Click(object sender, EventArgs e) { if (this.dataGridViewUpdateData.SelectedRows.Count != 1) { return; } UpdateFormDataEvent.UpdateItem update = this.dataGridViewUpdateData.SelectedRows[0].DataBoundItem as UpdateFormDataEvent.UpdateItem; this._updates.Remove(update); this._warningTable.Remove(update); }
/// <summary> /// 自动填充更新数据设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdateAll_Click(object sender, EventArgs e) { this._updates.Clear(); this._warningTable.Clear(); string selectedDataEntityId = _formDataEntityTreeChoose.SelectedId; DataEntity dataEntity = _dataEntityComponentService.GetDataEntity(selectedDataEntityId); IUIElementEditControl iFormElementEditControl; foreach (UIElement formElement in this.HostAdapter.HostFormEntity.Elements) { iFormElementEditControl = formElement as IUIElementEditControl; if (iFormElementEditControl == null) { continue; } if (String.IsNullOrEmpty(iFormElementEditControl.DataItemId)) { continue; } string[] ids = iFormElementEditControl.DataItemId.Split('.'); string dataEntityId = ids[0]; string dataItemId = ids[1]; if (dataEntityId != selectedDataEntityId) { continue; } DataItemEntity dataItemEntity = dataEntity.Items.GetEntityById(dataItemId); if (dataItemEntity == null) { continue; } UpdateFormDataEvent.UpdateItem update = new UpdateFormDataEvent.UpdateItem() { DataItem = dataItemId, DataItemName = dataItemEntity.Name, Source = new DataSource(StringParserLogic.DataSourceString(formElement)), SourceName = StringParserLogic.DataSourceVisibleString(formElement) }; this._updates.Add(update); this._warningTable.Add(update, false); } }
/// <summary> /// 添加更新数据设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddUpdate_Click(object sender, EventArgs e) { using (FormEventDataItemDataSet formEventDataItemDataSet = new FormEventDataItemDataSet(this.HostAdapter.HostFormEntity)) { formEventDataItemDataSet.DataEntityId = this._formDataEntityTreeChoose.SelectedId; formEventDataItemDataSet.AllowDataSourceType = UpdateFormDataDev.AllowDataSourceType; formEventDataItemDataSet.AllowFormElementControlType = UpdateFormDataDev.AllowFormElementControlType; if (formEventDataItemDataSet.ShowDialog() == DialogResult.OK) { UpdateFormDataEvent.UpdateItem update = new UpdateFormDataEvent.UpdateItem() { DataItem = formEventDataItemDataSet.SelectedDataItemId, DataItemName = formEventDataItemDataSet.SelectedDataItemName, Source = new DataSource(formEventDataItemDataSet.SelectedDataSourceString), SourceName = formEventDataItemDataSet.SelectedDataSourceVisibleString, }; this._updates.Add(update); } } }