框架四
来源:互联网 发布:pla算法python实现 编辑:程序博客网 时间:2024/04/28 23:35
完整的基于泛形、SOA设计思想的.net 框架 CS外观层(七)之一
namespace Unie2e.Yuking.Forms
{
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
using Unie2e.Common.Configuration;
using Unie2e.Common.Model;
using Unie2e.Common;
using Unie2e.Win;
using Unie2e.Yuking.SDO;
using Unie2e.Yuking.Proxy;
[E2EFormAttribute("DOSDO")]
public partial class DOSDOLForm : E2EForm
{
提示#region 提示
private const string E_NONEINIT = "请先赋值或新建";
private const string S_SAVEOK = "保存成功";
private const string S_DELETEOK = "删除成功";
private const string E_NONECHANGE = "数据没有改变";
private const string E_NONEDATA = "请选择数据";
private const string S_LOADED = "数据加载完毕";
#endregion
基本控件#region 基本控件
private System.ComponentModel.IContainer components = null;
private ToolStripContainer toolStripContainer;
private UserToolStrip userToolStrip;
private DataGridView dataGridView;
private GridViewExtender gridViewExtender;
private BindingSource bindingSource;
#endregion
private DataGridViewTextBoxColumn dOIdDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn customerIdDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn dONumberDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn dOStatusDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn dOCommentDataGridViewTextBoxColumn;
private BindingSource bindingSource_Customer;
private DOServiceSO dOServiceSO;
public DOSDOLForm()
{
this.InitializeComponent();
this.BindStrip();
this.BindData();
this.BindExtender();
this.BindCreateNew();
// 绑定数据错误不提示
this.dataGridView.DataError += delegate(object sender, DataGridViewDataErrorEventArgs e) { };
}
输入参数Input#region 输入参数Input
public DataCollection<DOSDO> Input
{
get
{
if (!(this.bindingSource.DataSource is DataCollection<DOSDO>))
{
bindingSource.DataSource = new DataCollection<DOSDO>();
}
return ((DataCollection<DOSDO>)(bindingSource.DataSource));
}
set
{
if (!(value is DataCollection<DOSDO>))
{
value = new DataCollection<DOSDO>();
}
bindingSource.DataSource = value;
}
}
#endregion
public event EventHandler<E2ETEventArgs<DataCollection<Unie2e.Yuking.SDO.DOSDO>>> OnSavedBatch;
public event EventHandler<E2ETEventArgs<DataCollection<Unie2e.Yuking.SDO.DOSDO>>> OnDataLoad;
public event EventHandler<E2ETEventArgs<Unie2e.Yuking.SDO.DOSDO>> OnCreated;
public event EventHandler<E2ETEventArgs<Unie2e.Yuking.SDO.DOSDO>> OnView;
public event EventHandler<E2ETEventArgs<Unie2e.Yuking.SDO.DOSDO>> OnDeleted;
初始化#region 初始化
protected override void Dispose(bool disposing)
{
if ((disposing == true))
{
if ((components != null))
{
components.Dispose();
}
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.toolStripContainer = new System.Windows.Forms.ToolStripContainer();
this.userToolStrip = new Unie2e.Win.UserToolStrip();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.dOIdDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.customerIdDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dONumberDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dOStatusDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dOCommentDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
this.bindingSource_Customer = new System.Windows.Forms.BindingSource(this.components);
this.toolStripContainer.ContentPanel.SuspendLayout();
this.toolStripContainer.TopToolStripPanel.SuspendLayout();
this.toolStripContainer.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource_Customer)).BeginInit();
this.SuspendLayout();
//
// toolStripContainer
//
this.toolStripContainer.BottomToolStripPanelVisible = false;
//
// toolStripContainer.ContentPanel
//
this.toolStripContainer.ContentPanel.Controls.Add(this.dataGridView);
this.toolStripContainer.ContentPanel.Size = new System.Drawing.Size(792, 548);
this.toolStripContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer.LeftToolStripPanelVisible = false;
this.toolStripContainer.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer.Name = "toolStripContainer";
this.toolStripContainer.RightToolStripPanelVisible = false;
this.toolStripContainer.Size = new System.Drawing.Size(792, 573);
this.toolStripContainer.TabIndex = 0;
this.toolStripContainer.Text = "toolStripContainer";
//
// toolStripContainer.TopToolStripPanel
//
this.toolStripContainer.TopToolStripPanel.Controls.Add(this.userToolStrip);
//
// userToolStrip
//
this.userToolStrip.Dock = System.Windows.Forms.DockStyle.None;
this.userToolStrip.EnabledCancel = true;
this.userToolStrip.EnabledClose = true;
this.userToolStrip.EnabledDelete = true;
this.userToolStrip.EnabledLoad = true;
this.userToolStrip.EnabledNew = true;
this.userToolStrip.EnabledSave = true;
this.userToolStrip.EnabledView = true;
this.userToolStrip.Location = new System.Drawing.Point(3, 0);
this.userToolStrip.Name = "userToolStrip";
this.userToolStrip.Size = new System.Drawing.Size(241, 25);
this.userToolStrip.TabIndex = 0;
this.userToolStrip.VisibleCancel = true;
this.userToolStrip.VisibleClose = true;
this.userToolStrip.VisibleDelete = true;
this.userToolStrip.VisibleLoad = true;
this.userToolStrip.VisibleNew = true;
this.userToolStrip.VisibleSave = true;
this.userToolStrip.VisibleView = true;
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToOrderColumns = true;
this.dataGridView.AutoGenerateColumns = false;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dOIdDataGridViewTextBoxColumn,
this.customerIdDataGridViewTextBoxColumn,
this.dONumberDataGridViewTextBoxColumn,
this.dOStatusDataGridViewTextBoxColumn,
this.dOCommentDataGridViewTextBoxColumn});
this.dataGridView.DataSource = this.bindingSource;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 23;
this.dataGridView.Size = new System.Drawing.Size(792, 548);
this.dataGridView.TabIndex = 0;
//
// dOIdDataGridViewTextBoxColumn
//
this.dOIdDataGridViewTextBoxColumn.DataPropertyName = "DOId";
this.dOIdDataGridViewTextBoxColumn.HeaderText = "DOId";
this.dOIdDataGridViewTextBoxColumn.Name = "dOIdDataGridViewTextBoxColumn";
//
// customerIdDataGridViewTextBoxColumn
//
this.customerIdDataGridViewTextBoxColumn.DataPropertyName = "CustomerId";
this.customerIdDataGridViewTextBoxColumn.HeaderText = "CustomerId";
this.customerIdDataGridViewTextBoxColumn.Name = "customerIdDataGridViewTextBoxColumn";
//
// dONumberDataGridViewTextBoxColumn
//
this.dONumberDataGridViewTextBoxColumn.DataPropertyName = "DONumber";
this.dONumberDataGridViewTextBoxColumn.HeaderText = "DONumber";
this.dONumberDataGridViewTextBoxColumn.Name = "dONumberDataGridViewTextBoxColumn";
//
// dOStatusDataGridViewTextBoxColumn
//
this.dOStatusDataGridViewTextBoxColumn.DataPropertyName = "DOStatus";
this.dOStatusDataGridViewTextBoxColumn.HeaderText = "DOStatus";
this.dOStatusDataGridViewTextBoxColumn.Name = "dOStatusDataGridViewTextBoxColumn";
//
// dOCommentDataGridViewTextBoxColumn
//
this.dOCommentDataGridViewTextBoxColumn.DataPropertyName = "DOComment";
this.dOCommentDataGridViewTextBoxColumn.HeaderText = "DOComment";
this.dOCommentDataGridViewTextBoxColumn.Name = "dOCommentDataGridViewTextBoxColumn";
//
// bindingSource
//
this.bindingSource.DataSource = typeof(Unie2e.Yuking.SDO.DOSDO);
//
// bindingSource_Customer
//
this.bindingSource_Customer.DataSource = typeof(Unie2e.Yuking.SDO.CustomerSDO);
//
// DOSDOLForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(792, 573);
this.Controls.Add(this.toolStripContainer);
this.Name = "DOSDOLForm";
this.toolStripContainer.ContentPanel.ResumeLayout(false);
this.toolStripContainer.TopToolStripPanel.ResumeLayout(false);
this.toolStripContainer.TopToolStripPanel.PerformLayout();
this.toolStripContainer.ResumeLayout(false);
this.toolStripContainer.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource_Customer)).EndInit();
this.ResumeLayout(false);
}
#endregion
数据绑定#region 数据绑定
// 数据绑定
private void BindData()
{
this.bindingSource_Customer.DataSource = GlobleCache.CustomerCollection;
// 请在上面添加额外的绑定数据源
gridViewExtender = new GridViewExtender(this.dataGridView);
gridViewExtender.DataSources["CustomerId".ToLower()] = this.bindingSource_Customer;
gridViewExtender.DataSources["DOStatus".ToLower()] = Enum.GetValues(typeof(Yuking.Common.ActiveStatus));
// 上面为控件绑定
gridViewExtender.CfgFileName ="DOSDO.xml";
gridViewExtender.BindColumn();
}
void BindStrip()
{
userToolStrip.OnCancel+=DataCancel;
userToolStrip.OnClose+=delegate(object sender, EventArgs e) { this.Close(); };
userToolStrip.OnCreateNew+=DataCreateNew;
userToolStrip.OnLoad+=DataLoad;
userToolStrip.OnSave+=DataSave;
userToolStrip.OnDelete+=DataDelete;
userToolStrip.OnView+=DataView;
}
private void BindExtender()
{
}
private void BindCreateNew()
{
DataCollection<DOSDO> source = this.Input;
source.AddingNew += DataCreateNew;
source.AddingNewBefore += AddingNewBefore;
}
#endregion
private DOServiceSO getProxy()
{
if ((dOServiceSO == null))
{
dOServiceSO = new DOServiceSO();
}
return dOServiceSO;
}
基本操作#region 基本操作
// 新建对象
private void DataCreateNew(object sender, System.ComponentModel.AddingNewEventArgs e)
{
DOSDO data = DOSDO.CreateNew();
data.BeginInit();
// 更多的初始化
// 结束初始化
data.EndInit();
e.NewObject = data;
if ((this.OnCreated != null))
{
this.OnCreated(this, new E2ETEventArgs<DOSDO>(data));
}
}
private DOSDO AddingNewBefore()
{
return ((DOSDO)(this.bindingSource.AddNew()));
}
private void DataCreateNew(object sender, System.EventArgs e)
{
this.DataCreateNew();
}
// 新建并显示明细
private void DataCreateNew()
{
DataCollection<DOSDO> source = this.Input;
DOSDO data = source.AddNew();
DOSDOForm form = ((DOSDOForm)(E2EForm.Show(typeof(DOSDOForm))));
form.Input = data;
}
// 加载数据,这儿要根据实现的情况进行更改
private void DataLoad()
{
DataCollection<DOSDO> source = this.Input;
try
{
DataCollection<DOSDO> rlt = this.getProxy().FindByAll();
source.Load(rlt);
if ((OnDataLoad != null))
{
this.OnDataLoad(this, new E2ETEventArgs<DataCollection<DOSDO>>(rlt));
}
MessageBox.Show(S_LOADED);
}
catch (E2EException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
// 加载数据
private void DataLoad(object sender, System.EventArgs e)
{
this.DataLoad();
}
private void DataDelete()
{
DOSDO data = this.bindingSource.Current as DOSDO;
if (data is DOSDO)
{
if (data.IsCreated())
{
data.DirectDelete();
}
else
{
try
{
DOSDO rlt = getProxy().Deleted(data);
MessageBox.Show(S_DELETEOK);
if ((OnDeleted != null))
{
this.OnDeleted(this, new E2ETEventArgs<DOSDO>(data));
}
data.DirectDelete();
}
catch (E2EException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
else
{
MessageBox.Show(E_NONEDATA);
}
}
private void DataDelete(object sender, System.EventArgs e)
{
this.DataDelete();
}
private void DataSave()
{
DataCollection<DOSDO> source = this.Input;
DataCollection<DOSDO> collection = source.GetChanges();
if ((collection.Count == 0))
{
MessageBox.Show(E_NONECHANGE);
return;
}
try
{
DataCollection<DOSDO> rlt = this.getProxy().SavedBatch(collection);
source.Merage(rlt);
source.AcceptChange();
if ((OnSavedBatch != null))
{
this.OnSavedBatch(this, new E2ETEventArgs<DataCollection<DOSDO>>(rlt));
}
MessageBox.Show(S_SAVEOK);
}
catch (E2EException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void DataSave(object sender, System.EventArgs e)
{
this.DataSave();
}
// 显示明细
private void DataView()
{
if (!(this.bindingSource.Current is DOSDO))
{
MessageBox.Show(E_NONEDATA);
return;
}
DOSDO data = ((DOSDO)(this.bindingSource.Current));
DOSDOForm form = ((DOSDOForm)(E2EForm.Show(typeof(DOSDOForm))));
form.Input = data;
if ((this.OnView != null))
{
this.OnView(this, new E2ETEventArgs<DOSDO>(data));
}
}
// 显示明细
private void DataView(object sender, System.EventArgs e)
{
this.DataView();
}
private void DataCancel()
{
DataCollection<DOSDO> source = this.Input;
source.RejectChange();
}
private void DataCancel(object sender, System.EventArgs e)
{
this.DataCancel();
}
#endregion
}
}
{
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
using Unie2e.Common.Configuration;
using Unie2e.Common.Model;
using Unie2e.Common;
using Unie2e.Win;
using Unie2e.Yuking.SDO;
using Unie2e.Yuking.Proxy;
[E2EFormAttribute("DOSDO")]
public partial class DOSDOLForm : E2EForm
{
提示#region 提示
private const string E_NONEINIT = "请先赋值或新建";
private const string S_SAVEOK = "保存成功";
private const string S_DELETEOK = "删除成功";
private const string E_NONECHANGE = "数据没有改变";
private const string E_NONEDATA = "请选择数据";
private const string S_LOADED = "数据加载完毕";
#endregion
基本控件#region 基本控件
private System.ComponentModel.IContainer components = null;
private ToolStripContainer toolStripContainer;
private UserToolStrip userToolStrip;
private DataGridView dataGridView;
private GridViewExtender gridViewExtender;
private BindingSource bindingSource;
#endregion
private DataGridViewTextBoxColumn dOIdDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn customerIdDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn dONumberDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn dOStatusDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn dOCommentDataGridViewTextBoxColumn;
private BindingSource bindingSource_Customer;
private DOServiceSO dOServiceSO;
public DOSDOLForm()
{
this.InitializeComponent();
this.BindStrip();
this.BindData();
this.BindExtender();
this.BindCreateNew();
// 绑定数据错误不提示
this.dataGridView.DataError += delegate(object sender, DataGridViewDataErrorEventArgs e) { };
}
输入参数Input#region 输入参数Input
public DataCollection<DOSDO> Input
{
get
{
if (!(this.bindingSource.DataSource is DataCollection<DOSDO>))
{
bindingSource.DataSource = new DataCollection<DOSDO>();
}
return ((DataCollection<DOSDO>)(bindingSource.DataSource));
}
set
{
if (!(value is DataCollection<DOSDO>))
{
value = new DataCollection<DOSDO>();
}
bindingSource.DataSource = value;
}
}
#endregion
public event EventHandler<E2ETEventArgs<DataCollection<Unie2e.Yuking.SDO.DOSDO>>> OnSavedBatch;
public event EventHandler<E2ETEventArgs<DataCollection<Unie2e.Yuking.SDO.DOSDO>>> OnDataLoad;
public event EventHandler<E2ETEventArgs<Unie2e.Yuking.SDO.DOSDO>> OnCreated;
public event EventHandler<E2ETEventArgs<Unie2e.Yuking.SDO.DOSDO>> OnView;
public event EventHandler<E2ETEventArgs<Unie2e.Yuking.SDO.DOSDO>> OnDeleted;
初始化#region 初始化
protected override void Dispose(bool disposing)
{
if ((disposing == true))
{
if ((components != null))
{
components.Dispose();
}
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.toolStripContainer = new System.Windows.Forms.ToolStripContainer();
this.userToolStrip = new Unie2e.Win.UserToolStrip();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.dOIdDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.customerIdDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dONumberDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dOStatusDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dOCommentDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
this.bindingSource_Customer = new System.Windows.Forms.BindingSource(this.components);
this.toolStripContainer.ContentPanel.SuspendLayout();
this.toolStripContainer.TopToolStripPanel.SuspendLayout();
this.toolStripContainer.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource_Customer)).BeginInit();
this.SuspendLayout();
//
// toolStripContainer
//
this.toolStripContainer.BottomToolStripPanelVisible = false;
//
// toolStripContainer.ContentPanel
//
this.toolStripContainer.ContentPanel.Controls.Add(this.dataGridView);
this.toolStripContainer.ContentPanel.Size = new System.Drawing.Size(792, 548);
this.toolStripContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer.LeftToolStripPanelVisible = false;
this.toolStripContainer.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer.Name = "toolStripContainer";
this.toolStripContainer.RightToolStripPanelVisible = false;
this.toolStripContainer.Size = new System.Drawing.Size(792, 573);
this.toolStripContainer.TabIndex = 0;
this.toolStripContainer.Text = "toolStripContainer";
//
// toolStripContainer.TopToolStripPanel
//
this.toolStripContainer.TopToolStripPanel.Controls.Add(this.userToolStrip);
//
// userToolStrip
//
this.userToolStrip.Dock = System.Windows.Forms.DockStyle.None;
this.userToolStrip.EnabledCancel = true;
this.userToolStrip.EnabledClose = true;
this.userToolStrip.EnabledDelete = true;
this.userToolStrip.EnabledLoad = true;
this.userToolStrip.EnabledNew = true;
this.userToolStrip.EnabledSave = true;
this.userToolStrip.EnabledView = true;
this.userToolStrip.Location = new System.Drawing.Point(3, 0);
this.userToolStrip.Name = "userToolStrip";
this.userToolStrip.Size = new System.Drawing.Size(241, 25);
this.userToolStrip.TabIndex = 0;
this.userToolStrip.VisibleCancel = true;
this.userToolStrip.VisibleClose = true;
this.userToolStrip.VisibleDelete = true;
this.userToolStrip.VisibleLoad = true;
this.userToolStrip.VisibleNew = true;
this.userToolStrip.VisibleSave = true;
this.userToolStrip.VisibleView = true;
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToOrderColumns = true;
this.dataGridView.AutoGenerateColumns = false;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dOIdDataGridViewTextBoxColumn,
this.customerIdDataGridViewTextBoxColumn,
this.dONumberDataGridViewTextBoxColumn,
this.dOStatusDataGridViewTextBoxColumn,
this.dOCommentDataGridViewTextBoxColumn});
this.dataGridView.DataSource = this.bindingSource;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 23;
this.dataGridView.Size = new System.Drawing.Size(792, 548);
this.dataGridView.TabIndex = 0;
//
// dOIdDataGridViewTextBoxColumn
//
this.dOIdDataGridViewTextBoxColumn.DataPropertyName = "DOId";
this.dOIdDataGridViewTextBoxColumn.HeaderText = "DOId";
this.dOIdDataGridViewTextBoxColumn.Name = "dOIdDataGridViewTextBoxColumn";
//
// customerIdDataGridViewTextBoxColumn
//
this.customerIdDataGridViewTextBoxColumn.DataPropertyName = "CustomerId";
this.customerIdDataGridViewTextBoxColumn.HeaderText = "CustomerId";
this.customerIdDataGridViewTextBoxColumn.Name = "customerIdDataGridViewTextBoxColumn";
//
// dONumberDataGridViewTextBoxColumn
//
this.dONumberDataGridViewTextBoxColumn.DataPropertyName = "DONumber";
this.dONumberDataGridViewTextBoxColumn.HeaderText = "DONumber";
this.dONumberDataGridViewTextBoxColumn.Name = "dONumberDataGridViewTextBoxColumn";
//
// dOStatusDataGridViewTextBoxColumn
//
this.dOStatusDataGridViewTextBoxColumn.DataPropertyName = "DOStatus";
this.dOStatusDataGridViewTextBoxColumn.HeaderText = "DOStatus";
this.dOStatusDataGridViewTextBoxColumn.Name = "dOStatusDataGridViewTextBoxColumn";
//
// dOCommentDataGridViewTextBoxColumn
//
this.dOCommentDataGridViewTextBoxColumn.DataPropertyName = "DOComment";
this.dOCommentDataGridViewTextBoxColumn.HeaderText = "DOComment";
this.dOCommentDataGridViewTextBoxColumn.Name = "dOCommentDataGridViewTextBoxColumn";
//
// bindingSource
//
this.bindingSource.DataSource = typeof(Unie2e.Yuking.SDO.DOSDO);
//
// bindingSource_Customer
//
this.bindingSource_Customer.DataSource = typeof(Unie2e.Yuking.SDO.CustomerSDO);
//
// DOSDOLForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(792, 573);
this.Controls.Add(this.toolStripContainer);
this.Name = "DOSDOLForm";
this.toolStripContainer.ContentPanel.ResumeLayout(false);
this.toolStripContainer.TopToolStripPanel.ResumeLayout(false);
this.toolStripContainer.TopToolStripPanel.PerformLayout();
this.toolStripContainer.ResumeLayout(false);
this.toolStripContainer.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource_Customer)).EndInit();
this.ResumeLayout(false);
}
#endregion
数据绑定#region 数据绑定
// 数据绑定
private void BindData()
{
this.bindingSource_Customer.DataSource = GlobleCache.CustomerCollection;
// 请在上面添加额外的绑定数据源
gridViewExtender = new GridViewExtender(this.dataGridView);
gridViewExtender.DataSources["CustomerId".ToLower()] = this.bindingSource_Customer;
gridViewExtender.DataSources["DOStatus".ToLower()] = Enum.GetValues(typeof(Yuking.Common.ActiveStatus));
// 上面为控件绑定
gridViewExtender.CfgFileName ="DOSDO.xml";
gridViewExtender.BindColumn();
}
void BindStrip()
{
userToolStrip.OnCancel+=DataCancel;
userToolStrip.OnClose+=delegate(object sender, EventArgs e) { this.Close(); };
userToolStrip.OnCreateNew+=DataCreateNew;
userToolStrip.OnLoad+=DataLoad;
userToolStrip.OnSave+=DataSave;
userToolStrip.OnDelete+=DataDelete;
userToolStrip.OnView+=DataView;
}
private void BindExtender()
{
}
private void BindCreateNew()
{
DataCollection<DOSDO> source = this.Input;
source.AddingNew += DataCreateNew;
source.AddingNewBefore += AddingNewBefore;
}
#endregion
private DOServiceSO getProxy()
{
if ((dOServiceSO == null))
{
dOServiceSO = new DOServiceSO();
}
return dOServiceSO;
}
基本操作#region 基本操作
// 新建对象
private void DataCreateNew(object sender, System.ComponentModel.AddingNewEventArgs e)
{
DOSDO data = DOSDO.CreateNew();
data.BeginInit();
// 更多的初始化
// 结束初始化
data.EndInit();
e.NewObject = data;
if ((this.OnCreated != null))
{
this.OnCreated(this, new E2ETEventArgs<DOSDO>(data));
}
}
private DOSDO AddingNewBefore()
{
return ((DOSDO)(this.bindingSource.AddNew()));
}
private void DataCreateNew(object sender, System.EventArgs e)
{
this.DataCreateNew();
}
// 新建并显示明细
private void DataCreateNew()
{
DataCollection<DOSDO> source = this.Input;
DOSDO data = source.AddNew();
DOSDOForm form = ((DOSDOForm)(E2EForm.Show(typeof(DOSDOForm))));
form.Input = data;
}
// 加载数据,这儿要根据实现的情况进行更改
private void DataLoad()
{
DataCollection<DOSDO> source = this.Input;
try
{
DataCollection<DOSDO> rlt = this.getProxy().FindByAll();
source.Load(rlt);
if ((OnDataLoad != null))
{
this.OnDataLoad(this, new E2ETEventArgs<DataCollection<DOSDO>>(rlt));
}
MessageBox.Show(S_LOADED);
}
catch (E2EException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
// 加载数据
private void DataLoad(object sender, System.EventArgs e)
{
this.DataLoad();
}
private void DataDelete()
{
DOSDO data = this.bindingSource.Current as DOSDO;
if (data is DOSDO)
{
if (data.IsCreated())
{
data.DirectDelete();
}
else
{
try
{
DOSDO rlt = getProxy().Deleted(data);
MessageBox.Show(S_DELETEOK);
if ((OnDeleted != null))
{
this.OnDeleted(this, new E2ETEventArgs<DOSDO>(data));
}
data.DirectDelete();
}
catch (E2EException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
else
{
MessageBox.Show(E_NONEDATA);
}
}
private void DataDelete(object sender, System.EventArgs e)
{
this.DataDelete();
}
private void DataSave()
{
DataCollection<DOSDO> source = this.Input;
DataCollection<DOSDO> collection = source.GetChanges();
if ((collection.Count == 0))
{
MessageBox.Show(E_NONECHANGE);
return;
}
try
{
DataCollection<DOSDO> rlt = this.getProxy().SavedBatch(collection);
source.Merage(rlt);
source.AcceptChange();
if ((OnSavedBatch != null))
{
this.OnSavedBatch(this, new E2ETEventArgs<DataCollection<DOSDO>>(rlt));
}
MessageBox.Show(S_SAVEOK);
}
catch (E2EException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void DataSave(object sender, System.EventArgs e)
{
this.DataSave();
}
// 显示明细
private void DataView()
{
if (!(this.bindingSource.Current is DOSDO))
{
MessageBox.Show(E_NONEDATA);
return;
}
DOSDO data = ((DOSDO)(this.bindingSource.Current));
DOSDOForm form = ((DOSDOForm)(E2EForm.Show(typeof(DOSDOForm))));
form.Input = data;
if ((this.OnView != null))
{
this.OnView(this, new E2ETEventArgs<DOSDO>(data));
}
}
// 显示明细
private void DataView(object sender, System.EventArgs e)
{
this.DataView();
}
private void DataCancel()
{
DataCollection<DOSDO> source = this.Input;
source.RejectChange();
}
private void DataCancel(object sender, System.EventArgs e)
{
this.DataCancel();
}
#endregion
}
}
- 框架四
- AjAX四种框架
- .Net 四层框架
- .NET四层框架
- JAVAEE四框架
- Android 四层框架
- Java集合框架(四)
- 胖虎谈ImageLoader框架(四)
- Spring框架学习(四)
- 框架(四)安全
- Struts2框架(四)
- Struts2框架进阶(四)
- Struts2框架(四)
- MVC框架设计(四)
- android框架四
- ThinkPHP框架总结四
- unittest框架实战(四)
- .Net 四层框架浅析
- 乱七八糟
- ArcEngine开发之Command控件使用篇
- delphi 实现 图片类型转换 jpg---bmp 及修改位图大小
- Bash shell 字符串操作符详解
- 天寒地冻正是读书好时节
- 框架四
- VS2005快捷键大全
- 英文报刊的网址
- 格式化时间
- H264基本概念之 采样(sampling)、帧(frame)与场(field)
- 一个环境变量设置导致????的小问题
- 有关新手提问和使用的编程工具。
- 如何创建基于MapXtreme 6.6 的Web 应用程序
- 标识(logo)设计的12条规则