1
yhj
2024-07-24 5e5d945e91568b973faa27d8ab0bcef99fc4a6c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#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
    }
}