#region
|
|
using System;
|
using System.Data;
|
using System.Windows.Forms;
|
using CSFrameworkV5.Business;
|
using CSFrameworkV5.Common;
|
using CSFrameworkV5.Core;
|
using CSFrameworkV5.Library;
|
using CSFrameworkV5.Library.CommonClass;
|
using DevExpress.XtraEditors.Controls;
|
using DevExpress.XtraGrid.Views.Grid;
|
|
#endregion
|
|
namespace CSFrameworkV5.GSTEST {
|
public partial class Frmtest : frmBaseDataDictionary {
|
//protected UpdateType _UpdateType = UpdateType.None;
|
//private RepositoryItemButtonEdit riButtonEdit = new RepositoryItemButtonEdit(); //编辑按钮列
|
private blltest _BLLInstance;
|
|
// private DataBinder dataBinder;
|
private int a;
|
|
//子表名
|
private string ChilddataName;
|
|
public Frmtest() {
|
InitializeComponent();
|
}
|
|
#region 控件点选事件 2022-05-1
|
|
private void AdvButtonText1_ButtonClick(object sender, EventArgs e) {
|
//DataBinder dataBinder = new DataBinder();
|
if (_UpdateType == UpdateType.None) {
|
Msg.Warning("请先打开新增或修改状态!");
|
return;
|
}
|
|
//调用底层点选
|
var row = DataBinder.TTT(sender, e); //
|
}
|
|
#endregion
|
|
#region 子表新增事件
|
|
private void button1_Click(object sender, EventArgs e) {
|
//_UpdateType 底层页面状态字段 在增加情况下控件可以增加一列2022-5-1
|
if (_UpdateType == UpdateType.Add || _UpdateType == UpdateType.Modify) {
|
gridView2.AddNewRow();
|
}
|
}
|
|
#endregion
|
|
#region DELETE 子表列删除方法
|
|
private void button2_Click(object sender, EventArgs e) {
|
if (_UpdateType == UpdateType.Add || _UpdateType == UpdateType.Modify) {
|
gridView2.DeleteSelectedRows();
|
}
|
}
|
|
#endregion
|
|
#region 绑定子表的控件数据(控件命名规范txt+字段)
|
|
protected override void DoBindingSummaryEditor(DataTable summary) {
|
//重写方法,增加ChilddataName子表名称,获取子表数据
|
DoBindingEditorPanel(pcDetailEditor, summary, ChilddataName);
|
//在此可绑定其它自定义的输入框,参考frmCustomer的DoBindingSummaryEditor方法
|
}
|
|
#endregion
|
|
#region DELETE 重写删除方法
|
|
public override void DoDelete(IButtonInfo sender) {
|
var dv = gridView2.DataSource as DataView;
|
var Dr = dv.Table;
|
if (Dr.Rows.Count > 0) {
|
var F = _BLLInstance.QueryDelete(Dr, Dr.TableName, "DHB001");
|
if (!F) {
|
MessageBox.Show("删除失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
return;
|
}
|
}
|
|
base.DoDelete(sender);
|
}
|
|
#endregion
|
|
#region Save 重写保存方法
|
|
public override void DoSave(IButtonInfo sender) {
|
var dv = gridView2.DataSource as DataView;
|
//DataSet dc = this.gridControl2.DataSource as DataSet;
|
var Dr = dv.Table;
|
//重写底层,保存表 2022-5-1
|
if (txtDHA001.Text == "" || txtDHA001.Text == null) {
|
MessageBox.Show("到货单号不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
return;
|
}
|
|
if (_UpdateType == UpdateType.Add) {
|
var T = _BLLInstance.QuerySave(Dr, Dr.TableName);
|
if (!T) {
|
MessageBox.Show("保存失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
return;
|
}
|
}
|
|
if (_UpdateType == UpdateType.Modify) {
|
//
|
var F = _BLLInstance.QueryUpdata(Dr, Dr.TableName, "DHB001");
|
if (!F) {
|
MessageBox.Show("保存失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
return;
|
}
|
}
|
|
base.DoSave(sender);
|
a = 0;
|
Refresh();
|
}
|
|
#endregion
|
|
private void Frmtest_Load(object sender, EventArgs e) {
|
InitializeForm(); //自定义初始化操作
|
SetLanguage();
|
}
|
|
#region 子表新增行事件,新增列值
|
|
private void gridView2_InitNewRow(object sender, InitNewRowEventArgs e) {
|
a = a + 1; //自增序号
|
//为新增行插入值
|
var view = sender as GridView;
|
view.SetRowCellValue(e.RowHandle, view.Columns["DHB001"], txtDHA001.Text);
|
view.SetRowCellValue(e.RowHandle, view.Columns["DHB002"], a);
|
}
|
|
#endregion
|
|
#region 框架初始化 2022-05-1
|
|
protected override void InitializeForm() {
|
//string sql = "SELECT * FROM PURDHA WHERE 1=1;";
|
//this.DoBindingSummaryGrid(DatabaseProvider.SystemDatabase.GetTable(sql)); //绑定主表的Grid
|
//this.ShowSummaryPage(true); //显示Summary页面.
|
_SummaryView = new DevGridView(gridView1); //实例化数据主视图,此接口可支持不同的主视图,比如Grid,TreeList.
|
_DetailGroupControl = pcDetailEditor; //修改页面所有输入框的容器
|
_BLL = new blltest(); //实例化基类业务逻辑层
|
ChilddataName = "PURDHB"; //绑定子表
|
//DevStyle.SetGridControlLayout(gridControl2, true, true, true, true);控件下增加"+""-"号
|
//gridControl2.EmbeddedNavigator.ButtonClick += new NavigatorButtonClickEventHandler(this.OngridControl2ButtonClick);
|
_BLLInstance = _BLL as blltest; //本窗体的业务层对象引用
|
DoBindingSummaryGrid(_BLLInstance.QueryT()); //绑定主表的Grid
|
ShowSummaryPage(true); //显示Summary页面.
|
//注册子表列点击事件
|
repositoryItemButtonEdit1.ButtonClick += repositoryItemButtonEdit1_ButtonClick;
|
advButtonText1.ButtonClick += AdvButtonText1_ButtonClick; //点选控件事件增加
|
gridView2.OptionsView.ShowGroupPanel = true; //展开gridControl控件头部
|
gridView2.OptionsSelection.MultiSelect = true;
|
base.InitializeForm();
|
}
|
|
#endregion
|
|
#region 子表列点击事件 2022-05-1
|
|
private void repositoryItemButtonEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) {
|
var sql = "SELECT DHA001 到货单号 ,DHA002 序号 FROM PURDHA";
|
var filt = "1=1";
|
DataBinder.GetSelectT(sql, filt);
|
}
|
|
#endregion
|
}
|
}
|