遊龍代码生成器

     为了提高开发效率,选择一些方便于开发的手段,对于开发者自己,开发一个适合自己,并且能节省工作量及工作时间的有力工具是多么有意义的一件事。同时,自己动手开发适合提高自己工作效率的工具同时不但提高对需求提出审核同时也能提高自己对怎么的需求如何设计,如何理解并应用,如何对自己提出需求,并实现之。当然兴趣也是很重要的。

    这只是一种开发中的思路,在此,虽针对的为Winform,但同样适合于其他框架及结构,更重要的是学会“偷懒”,“偷懒”有时同样能推进自己的发展及生产力的提高。^_^

代码生成配置设置:

  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.IO;
  7 using System.Linq;
  8 using System.Text;
  9 using System.Threading.Tasks;
 10 using System.Windows.Forms;
 11 
 12 namespace DataStudio
 13 {
 14     public partial class FormGenConfig : Form
 15     {
 16         ToolTip _tip;
 17         private const int DefWidth = 107;
 18         private const int DefHeight = 23;
 19         private const int DefFirstLeft = 95;
 20         private const int DefFirstTop = 29;
 21 
 22         private ConfigInfo _config;
 23         public FormGenConfig()
 24         {
 25             InitializeComponent();
 26             FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
 27             StartPosition = FormStartPosition.CenterParent;
 28             MaximizeBox = false;
 29             Text = "遊龍代码类型配置";
 30 
 31             _config = new ConfigInfo
 32             {
 33                 Label = "WMS.Win.MyLabel",
 34                 TextBox = "StyleForm.Win.Controls.MyStyleTextBox",
 35                 ComboBox = "WMS.Win.MyComboBox",
 36                 DateTimePicker = "WMS.Win.MyDateTimePicker",
 37                 Width = DefWidth,
 38                 Height = DefHeight
 39             };
 40 
 41             txtLabel.Text = _config.Label;
 42             txtTextBox.Text = _config.TextBox;
 43             txtComboBox.Text = _config.ComboBox;
 44             txtDateTimePicker.Text = _config.DateTimePicker;
 45             txtWidth.Text = "107";
 46             txtHeight.Text = "23";
 47             txtFirstLeft.Text = "95";
 48             txtFirstTop.Text = "29";
 49             AcceptButton = btnOK;
 50 
 51             _config = new ConfigInfo();
 52         }
 53 
 54         private bool Check()
 55         {
 56             if (txtLabel.Text.Trim().Length == 0)
 57             {
 58                 MessageBox.Show("标签类型不能为空,请输入");
 59                 return false;
 60             }
 61             if (txtTextBox.Text.Trim().Length == 0)
 62             {
 63                 MessageBox.Show("文本类型不能为空,请输入");
 64                 return false;
 65             }
 66             if (txtWidth.Text.Trim().Length == 0)
 67             {
 68                 MessageBox.Show("宽度不能为空,请输入");
 69                 return false;
 70             }
 71             if (txtHeight.Text.Trim().Length == 0)
 72             {
 73                 MessageBox.Show("高度不能为空,请输入");
 74                 return false;
 75             }
 76             if (txtFirstLeft.Text.Trim().Length == 0)
 77             {
 78                 MessageBox.Show("首控制左位置不能为空,请输入");
 79                 return false;
 80             }
 81             if (txtFirstTop.Text.Trim().Length == 0)
 82             {
 83                 MessageBox.Show("首控制顶位置不能为空,请输入");
 84                 return false;
 85             }
 86 
 87             return true;
 88         }
 89 
 90         private ConfigInfo CollectData()
 91         {
 92             if (!Check())
 93                 return null;
 94             string label = txtLabel.Text.Trim();
 95             string textBox = txtTextBox.Text.Trim();
 96             string comboBox = txtComboBox.Text.Trim();
 97             string dateTimePicker = txtDateTimePicker.Text.Trim();
 98             int width, height, firstLeft, firstTop;
 99             if (!int.TryParse(txtWidth.Text, out width))
100                 width = DefWidth;
101             if (!int.TryParse(txtHeight.Text, out height))
102                 height = DefHeight;
103             if (!int.TryParse(txtFirstLeft.Text, out firstLeft))
104                 height = DefFirstLeft;
105             if (!int.TryParse(txtFirstTop.Text, out firstTop))
106                 height = DefFirstTop;
107             comboBox = comboBox.Length == 0 ? textBox : comboBox;
108             dateTimePicker = dateTimePicker.Length == 0 ? textBox : dateTimePicker;
109             ConfigInfo config = new ConfigInfo
110             {
111                 Label = label,
112                 TextBox = textBox,
113                 ComboBox = comboBox,
114                 DateTimePicker = dateTimePicker,
115                 Width = width,
116                 Height = height,
117                 FirstLeft = firstLeft,
118                 FirstTop = firstTop
119             };
120             return config;
121         }
122 
123         /// <summary>
124         /// 结果
125         /// </summary>
126         public ConfigInfo Result { get { return _config; } }
127 
128         private void btnOK_Click(object sender, EventArgs e)
129         {
130             ConfigInfo config = CollectData();
131             if (config != null)
132             {
133                 _config = config;
134             }
135             DialogResult = DialogResult.OK;
136             Close();
137         }
138     }
139 
140     public class ConfigInfo
141     {
142         public string Label { get; set; }
143         public string TextBox { get; set; }
144         public string ComboBox { get; set; }
145         public string DateTimePicker { get; set; }
146         public int Width { get; set; }
147         public int Height { get; set; }
148         public int FirstLeft { get; set; }
149         public int FirstTop { get; set; }
150     }
151 
152     class LabelString
153     {
154         public const string NewLine = "\r\n";
155         public const string LineTab = "\t\t\t";
156         public string Name { get; set; }
157         public int Width { get; set; }
158         public int Height { get; set; }
159         public int TabIndex { get; set; }
160         public string Text { get; set; }
161         public int Left { get; set; }
162         public int Top { get; set; }
163         public override string ToString()
164         {
165             StringBuilder sb = new StringBuilder();
166             sb.AppendFormat("{4}//{1} {4}// lbl{0}{1} {4}// {1} {4}this.lbl{0}.AutoSize = true;{1}{4}this.lbl{0}.CanReadOnly = false;{1}{4}this.lbl{0}.Location = new System.Drawing.Point({2}, {3});{1}", Name, NewLine, Left, Top, LineTab);
167             sb.AppendFormat("{2}this.lbl{0}.Name = \"{0}\";{1}", Name, NewLine, LineTab);
168             sb.AppendFormat("{4}this.lbl{0}.Size = new System.Drawing.Size({1}, {2});{3}", Name, Width, Height, NewLine, LineTab);
169             sb.AppendFormat("{3}this.lbl{0}.TabIndex = {1};{2}", Name, TabIndex, NewLine, LineTab);
170             sb.AppendFormat("{3}this.lbl{0}.Text = \"{1}\";{2}", Name, Text.Length == 0 ? Name : Text, NewLine, LineTab);
171             return sb.ToString();
172         }
173     }
174 
175     class TextBoxString : LabelString
176     {
177         public string TableName { get; set; }
178         public override string ToString()
179         {
180             StringBuilder sb = new StringBuilder();
181             sb.AppendFormat("{2}// {1} {2}// txt{0}{1} {2}//{1} ", Name, NewLine, LineTab);
182             sb.AppendFormat("{2}this.txt{0}.BindColumnName = \"{0}\";{1} ", Name, NewLine, LineTab);
183             sb.AppendFormat("{3}this.txt{0}.BindTableName = \"{1}\";{2} ", Name, TableName, NewLine, LineTab);
184             sb.AppendFormat(@"{2}this.txt{0}.BorderColorFocus = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(160)))), ((int)(((byte)(160)))));
185             this.txt{0}.BorderColorNormal = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(160)))), ((int)(((byte)(160)))));{1} ", Name, NewLine, LineTab);
186             sb.AppendFormat("{2}this.txt{0}.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;{1} ", Name, NewLine, LineTab);
187             sb.AppendFormat("{2}this.txt{0}.EmptyTextTip = \"\";{1}", Name, NewLine, LineTab);
188             sb.AppendFormat("{2}this.txt{0}.EmptyTextTipColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(160)))), ((int)(((byte)(160)))));{1} ", Name, NewLine, LineTab);
189             sb.AppendFormat("{2}this.txt{0}.Font = new System.Drawing.Font(\"微软雅黑\", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));{1} ", Name, NewLine, LineTab);
190             sb.AppendFormat("{4}this.txt{0}.Location = new System.Drawing.Point({2}, {3});{1} ", Name, NewLine, Left, Top, LineTab);
191             sb.AppendFormat("{2}this.txt{0}.MouseState = StyleForm.Win.MouseStateEnumeration.Normal;{1} ", Name, NewLine, LineTab);
192             sb.AppendFormat("{2}this.txt{0}.Name = \"txt{0}\";{1} ", Name, NewLine, LineTab);
193             sb.AppendFormat("{2}this.txt{0}.Size = new System.Drawing.Size(106, 23);{1} ", Name, NewLine, LineTab);
194             sb.AppendFormat("{3}this.txt{0}.TabIndex = {1};{2} ", Name, TabIndex, NewLine, LineTab);
195             return sb.ToString();
196         }
197     }
198 
199     class ComboBoxString : TextBoxString
200     {
201         public override string ToString()
202         {
203             StringBuilder sb = new StringBuilder();
204             sb.AppendFormat("{2}{2}// {1} {2}// cmb{0}{1} {2}// {1} ", Name, NewLine, LineTab);
205             sb.AppendFormat("{2}this.cmb{0}.BindColumnName = \"{0}\";{1} ", Name, NewLine, LineTab);
206             sb.AppendFormat("{3}this.cmb{0}.BindTableName = \"{1}\";{2} ", Name, TableName, NewLine, LineTab);
207             sb.AppendFormat("{2}this.cmb{0}.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;{1} ", Name, NewLine, LineTab);
208             sb.AppendFormat("{2}this.cmb{0}.Enabled = false;{1} ", Name, NewLine, LineTab);
209             sb.AppendFormat("{2}this.cmb{0}.FlatStyle = System.Windows.Forms.FlatStyle.Flat;{1} ", Name, NewLine, LineTab);
210             sb.AppendFormat("{2}this.cmb{0}.Font = new System.Drawing.Font(\"微软雅黑\", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));{1} ", Name, NewLine, LineTab);
211             sb.AppendFormat("{4}this.cmb{0}.Location = new System.Drawing.Point({2}, {3});{1} ", Name, NewLine, Left, Top, LineTab);
212             sb.AppendFormat("{2}this.cmb{0}.Name = \"cmb{0}\";{1} ", Name, NewLine, LineTab);
213             sb.AppendFormat("{2}this.cmb{0}.Size = new System.Drawing.Size(105, 25);{1} ", Name, NewLine, LineTab);
214             sb.AppendFormat("{3}this.cmb{0}.TabIndex = {1};{2} ", Name, TabIndex, NewLine, LineTab);
215             return sb.ToString();
216         }
217     }
218 
219     class DateTimePickerString : TextBoxString
220     {
221         public override string ToString()
222         {
223             StringBuilder sb = new StringBuilder();
224             sb.AppendFormat("{2}// {1}{2}// dtp{0}{1}{2}//{1} ", Name, NewLine, LineTab);
225             sb.AppendFormat("{2}this.dtp{0}.BindColumnName = \"{0}\";{1} ", Name, NewLine, LineTab);
226             sb.AppendFormat("{3}this.dtp{0}.BindTableName = \"{1}\";{2} ", Name, TableName, NewLine, LineTab);
227             sb.AppendFormat("{2}this.dtp{0}.CustomFormat = \"yyyy-MM-dd\";{1} ", Name, NewLine, LineTab);
228             sb.AppendFormat("{2}this.dtp{0}.Format = System.Windows.Forms.DateTimePickerFormat.Custom;{1} ", Name, NewLine, LineTab);
229             sb.AppendFormat("{4}this.dtp{0}.Location = new System.Drawing.Point({2}, {3});{1} ", Name, NewLine, Left, Top, LineTab);
230             sb.AppendFormat("{2}this.dtp{0}.Name = \"dtp{0}\";{1} ", Name, NewLine, LineTab);
231             sb.AppendFormat("{2}this.dtp{0}.Size = new System.Drawing.Size(107, 21);{1} ", Name, NewLine, LineTab);
232             sb.AppendFormat("{3}this.dtp{0}.TabIndex = {1};{2} ", Name, TabIndex, NewLine, LineTab);
233             return sb.ToString();
234         }
235     }
236 }
View Code

代码生成器界面:

  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.IO;
  7 using System.Linq;
  8 using System.Text;
  9 using System.Threading.Tasks;
 10 using System.Windows.Forms;
 11 
 12 namespace DataStudio
 13 {
 14     public partial class FormGenerator : Form
 15     {
 16         ToolTip _tip;
 17         DataTable _table;
 18         private string _strDefine, _strNew, _strAddRange, _strAddSubRange, _strAddItems;
 19         private string _strHeadItems, _strAddHeadItems;
 20         private string _columnType, _namespace;
 21         private const string CLASSNAME = "@ClassName";
 22         private const string CLASSTEXT = "@ClassText";
 23         private const string CLASSBASE = "@ClassBase";
 24         private const string NAMESPACE = "@Namespace";
 25         private const string DEFINE_ITEM = "@DefineItem";
 26         private const string NEW_ITEM = "@NewItem";
 27         private const string ADD_RANGE = "@AddRange";
 28         private const string ADD_SUBRANGE = "@AddSubRange";
 29         private const string ADD_ITEMS = "@AddItems";
 30         private const string TABLE_NAME = "@TableName";
 31 
 32         private const string HeadItems = "@HeadItemControls";
 33         private const string HeadItemBegin = "@HeadItemBegin";
 34         private const string HeadItem = "@HeadControlItem";
 35         private const string HeadItemEnd = "@HeadItemEnd";
 36 
 37         private delegate string AddHeadItemHandle(string content, string ctrlName);
 38         /// <summary>
 39         /// 添加头控件
 40         /// </summary>
 41         private AddHeadItemHandle AddHeadItem = (content, ctrlName) =>
 42         {
 43             int left = content.IndexOf(HeadItemBegin);
 44             int right = content.IndexOf(HeadItemEnd);
 45             if (right <= left)
 46                 return string.Empty;
 47             string addString = content.Substring(left, right - left);
 48             return addString.Replace(HeadItem, ctrlName);
 49         };
 50         //this.myPanel1.Controls.Add(@HeadItem);@HeadItemEnd;
 51         private ConfigInfo _config;
 52 
 53         private string GetAddItemTemplate(string content)
 54         {
 55             int left = content.IndexOf(HeadItemBegin);
 56             int right = content.IndexOf(HeadItemEnd);
 57             if (right <= left)
 58                 return string.Empty;
 59             return content.Substring(left, right - left);
 60         }
 61 
 62         public FormGenerator(DataTable dt)
 63         {
 64             _table = dt;
 65             InitializeComponent();
 66             txtSheet1.DoubleClick += txt_DoubleClick;
 67             txtSheet2.DoubleClick += txt_DoubleClick;
 68             txtTarget.DoubleClick += txt_DoubleClick;
 69             FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
 70             StartPosition = FormStartPosition.CenterParent;
 71             MaximizeBox = false;
 72             Text = "遊龍代码生成";
 73 
 74             _tip = new ToolTip();
 75             _tip.SetToolTip(txtSheet1, "双击选择");
 76             _tip.SetToolTip(txtSheet2, "双击选择");
 77             _tip.SetToolTip(txtTarget, "双击选择,默认产生到程序根目录");
 78             rbSheet1.Checked = true;
 79             rbSheet1.Click += rbSheet_Click;
 80             rbSheet2.Click += rbSheet_Click;
 81             rbSheet1All.Click += rbSheet_Click;
 82 
 83             txtBaseClass.Text = "MyStyleSheet1";
 84             txtSheet1.Text = "Template\\Template1";
 85             txtSheet2.Text = "Template\\Template2";
 86             rbSheet1.Checked = true;
 87             txtColumnType.Text = "WMS.Win.MyDataGridViewTextBoxColumn";
 88             txtNamespace.Text = "KYWMS.Com.Basic";
 89             txtFileName.Text = "FRM_@TableName";
 90         }
 91         void rbSheet_Click(object sender, EventArgs e)
 92         {
 93             string baseClass = txtBaseClass.Text.Trim();
 94             if (rbSheet1.Checked)
 95             {
 96                 txtBaseClass.Text = baseClass.Replace(rbSheet2.Text, rbSheet1.Text);
 97             }
 98             else if (rbSheet2.Checked)
 99             {
100                 txtBaseClass.Text = baseClass.Replace(rbSheet1.Text, rbSheet2.Text);
101             }
102             else
103             {
104                 txtBaseClass.Text = baseClass.Replace(rbSheet2.Text, rbSheet1.Text);
105                 using (FormGenConfig fgc = new FormGenConfig())
106                 {
107                     fgc.ShowDialog();
108                     _config = fgc.Result;
109                     _left = _config.FirstLeft;
110                     _top = _config.FirstTop;
111                 }
112             }
113         }
114 
115         void rbSheet1_CheckedChanged(object sender, EventArgs e)
116         {
117             string baseClass = txtBaseClass.Text.Trim();
118             if (rbSheet1.Checked)
119             {
120                 txtBaseClass.Text = baseClass.Replace(rbSheet2.Text, rbSheet1.Text);
121             }
122             else if (rbSheet2.Checked)
123             {
124                 txtBaseClass.Text = baseClass.Replace(rbSheet1.Text, rbSheet2.Text);
125             }
126             else
127             {
128                 txtBaseClass.Text = baseClass.Replace(rbSheet2.Text, rbSheet1.Text);
129                 using (FormGenConfig fgc = new FormGenConfig())
130                 {
131                     fgc.ShowDialog();
132                     _config = fgc.Result;
133                     _left = _config.FirstLeft;
134                     _top = _config.FirstTop;
135                 }
136             }
137         }
138 
139         void txt_DoubleClick(object sender, EventArgs e)
140         {
141             TextBox txt = sender as TextBox;
142             if (txt == null)
143                 return;
144             if (txt == txtTarget)
145             {
146                 FolderBrowserDialog fbd = new FolderBrowserDialog();
147                 fbd.Description = "选择生成路径";
148                 if (DialogResult.OK == fbd.ShowDialog())
149                 {
150                     txtTarget.Text = fbd.SelectedPath;
151                 }
152             }
153             else
154             {
155                 OpenFileDialog ofd = new OpenFileDialog();
156                 ofd.Title = "选择模板";
157                 if (DialogResult.OK == ofd.ShowDialog())
158                 {
159                     txt.Text = ofd.FileName;
160                 }
161             }
162         }
163 
164         private bool Check()
165         {
166             if (rbSheet1.Checked && txtSheet1.Text.Trim().Length == 0)
167             {
168                 MessageBox.Show("Sheet1模板不能为空,请选择");
169                 return false;
170             }
171             if (rbSheet2.Checked && txtSheet2.Text.Trim().Length == 0)
172             {
173                 MessageBox.Show("Sheet2模板不能为空,请选择");
174                 return false;
175             }
176             if (txtColumnType.Text.Trim().Length == 0)
177             {
178                 MessageBox.Show("列类型不能为空,请输入");
179                 return false;
180             }
181             if (txtNamespace.Text.Trim().Length == 0)
182             {
183                 MessageBox.Show("命名空间不能为空,请输入");
184                 return false;
185             }
186             if (txtBaseClass.Text.Trim().Length == 0)
187             {
188                 MessageBox.Show("基类型名不能为空,请输入");
189                 return false;
190             }
191             if (txtFileName.Text.Trim().Length == 0)
192             {
193                 MessageBox.Show("窗体名不能为空,请输入");
194                 return false;
195             }
196             _strAddItems = string.Empty;
197             _strAddRange = string.Empty;
198             _strAddSubRange = string.Empty;
199             _strDefine = string.Empty;
200             _strNew = string.Empty;
201             return true;
202         }
203 
204         private void btnGenerate_Click(object sender, EventArgs e)
205         {
206             if (!Check())
207                 return;
208             string template = rbSheet1.Checked || rbSheet1All.Checked ? txtSheet1.Text.Trim() : txtSheet2.Text.Trim();
209             if (!File.Exists(template))
210             {
211                 MessageBox.Show("模板" + template + "不存在");
212                 return;
213             }
214             string templateDesigner = template + ".Designer";
215             if (!File.Exists(templateDesigner))
216             {
217                 MessageBox.Show("模板" + templateDesigner + "不存在");
218                 return;
219             }
220             string content = File.ReadAllText(template);
221             string contentDesigner = File.ReadAllText(templateDesigner);
222 
223             _columnType = txtColumnType.Text.Trim();
224             _namespace = txtNamespace.Text.Trim();
225             string fileName = txtFileName.Text.Trim();
226             string classBase = txtBaseClass.Text.Trim();
227             fileName = fileName.Replace(TABLE_NAME, _table.TableName).Replace(NAMESPACE, _namespace);
228             contentDesigner = contentDesigner.Replace(CLASSNAME, fileName).Replace(NAMESPACE, _namespace)
229                 .Replace(TABLE_NAME, _table.TableName);
230             if (_table.ExtendedProperties.ContainsKey("_caption"))
231             {
232                 contentDesigner = contentDesigner.Replace(CLASSTEXT, _table.ExtendedProperties["_caption"].ToString());
233             }
234             ResolveItems();
235             string addHeadItemString = GetAddItemTemplate(contentDesigner);
236             ResolveHeadItems(addHeadItemString);
237             contentDesigner = contentDesigner.Replace(DEFINE_ITEM, _strDefine).Replace(NEW_ITEM, _strNew).Replace(ADD_RANGE, _strAddRange)
238                 .Replace(ADD_ITEMS, _strAddItems).Replace(ADD_SUBRANGE, _strAddSubRange);
239             contentDesigner = contentDesigner.Replace(HeadItems, _strHeadItems).Replace(addHeadItemString + HeadItemEnd, _strAddHeadItems);
240             string target = txtTarget.Text.Trim();
241             string file = Path.Combine(target, fileName + ".Designer.cs");
242             if (!Write(file, contentDesigner)) return;
243 
244             file = Path.Combine(target, fileName + ".cs");
245             content = content.Replace(CLASSNAME, fileName).Replace(NAMESPACE, _namespace).Replace(CLASSBASE, classBase)
246                 .Replace(TABLE_NAME, _table.TableName);
247             if (!Write(file, content)) return;
248             MessageBox.Show("生成成功");
249         }
250 
251         private bool Write(string file, string content)
252         {
253             try
254             {
255                 if (File.Exists(file))
256                 {
257                     if (DialogResult.Yes == MessageBox.Show(file + "已存在,是否替换?", "温馨提示", MessageBoxButtons.YesNo))
258                     {
259                         File.WriteAllText(file, content);
260                         return true;
261                     }
262                     return false;
263                 }
264                 else
265                 {
266                     File.WriteAllText(file, content);
267                     return true;
268                 }
269             }
270             catch (Exception ex)
271             {
272                 MessageBox.Show("生成文件失败:" + ex.Message);
273                 return false;
274             }
275         }
276 
277         /// <summary>
278         /// 解析
279         /// </summary>
280         private void ResolveItems()
281         {
282             _strDefine = "\r\n";
283             _strNew = _strDefine;
284             _strAddItems = _strDefine;
285             GenColumns(_table);
286             if (_table.ChildRelations.Count > 0)
287             {
288                 _strDefine += "\r\n";
289                 _strNew += "\r\n";
290                 _strAddRange += "\r\n";
291                 _strAddItems += "\r\n";
292                 DataTable dt = _table.ChildRelations[0].ChildTable;
293                 GenColumns(dt, "L");
294             }
295         }
296 
297         private int _tableIndex = 0, _tabLabelIndex = 100;
298         private int _left = 95, _top = 29;
299 
300         // 5个一排
301         private void ResolveHeadItems(string addHeadItemString)
302         {
303             if (_config == null)
304                 return;
305             string controlName = string.Empty, lblName = string.Empty;
306             int n = 0;
307             foreach (DataColumn dc in _table.Columns)
308             {
309                 if (dc.DataType == typeof(DateTime))
310                 {
311                     controlName = string.Format("dtp{0}", dc.ColumnName);
312                     lblName = string.Format("lbl{0}", dc.ColumnName);
313                     _strDefine += string.Format("\r\n\t\tprivate {0} {1};", _config.Label, lblName);
314                     _strDefine += string.Format("\r\n\t\tprivate {0} {1};", _config.DateTimePicker, controlName);
315                     _strNew += string.Format("\r\n\t\t\tthis.{0} = new {1}();", lblName, _config.Label);
316                     _strNew += string.Format("\r\n\t\t\tthis.{0} = new {1}();", controlName, _config.DateTimePicker);
317                     _strHeadItems += string.Format("{0}", new LabelString() { Name = dc.ColumnName, TabIndex = _tabLabelIndex++, Text = dc.Caption, Width = _config.Width, Height = _config.Height, Left = _left - 80, Top = _top });
318                     _strHeadItems += string.Format("{0}", new DateTimePickerString() { Name = dc.ColumnName, TableName = _table.TableName, TabIndex = _tableIndex++, Text = dc.Caption, Width = _config.Width, Height = _config.Height, Left = _left, Top = _top });
319                 }
320                 else
321                 {
322                     controlName = string.Format("txt{0}", dc.ColumnName);
323                     lblName = string.Format("lbl{0}", dc.ColumnName);
324                     _strDefine += string.Format("\r\n\t\tprivate {0} {1};", _config.Label, lblName);
325                     _strDefine += string.Format("\r\n\t\tprivate {0} {1};", _config.TextBox, controlName);
326                     _strNew += string.Format("\r\n\t\t\tthis.{0} = new {1}();", lblName, _config.Label);
327                     _strNew += string.Format("\r\n\t\t\tthis.{0} = new {1}();", controlName, _config.TextBox);
328                     _strHeadItems += string.Format("{0}", new LabelString() { Name = dc.ColumnName, TabIndex = _tabLabelIndex++, Text = dc.Caption, Width = _config.Width, Height = _config.Height, Left = _left - 80, Top = _top });
329                     _strHeadItems += string.Format("{0}", new TextBoxString() { Name = dc.ColumnName, TableName = _table.TableName, TabIndex = _tableIndex++, Text = dc.Caption, Width = _config.Width, Height = _config.Height, Left = _left, Top = _top });
330                 }
331                 _left += _config.Width * 2;
332                 if (++n % 5 == 0)
333                 {
334                     _left = _config.FirstLeft;
335                     _top += _config.Height + 9;
336                 }
337                 _strAddHeadItems += string.Format("{0}", addHeadItemString.Replace(HeadItemBegin, "").Replace(HeadItem, lblName));
338                 _strAddHeadItems += string.Format("{0}", addHeadItemString.Replace(HeadItemBegin, "").Replace(HeadItem, controlName));
339             }
340         }
341 
342         private void GenColumns(DataTable dt, string pre = "")
343         {
344             bool bFirst = true;
345             foreach (DataColumn dc in dt.Columns)
346             {
347                 bFirst = false;
348                 _strDefine += string.Format("{2}private {0} {3}{1};\r\n", _columnType, dc.ColumnName, bFirst ? "\r\n" : "\t\t", pre);
349                 _strNew += string.Format("{2}this.{3}{0} = new {1}();\r\n", dc.ColumnName, _columnType, bFirst ? "\r\n" : "\t\t\t", pre);
350                 if (pre.Length > 0)
351                     _strAddSubRange += string.Format("this.{1}{0},", dc.ColumnName, pre);
352                 else
353                     _strAddRange += string.Format("this.{1}{0},", dc.ColumnName, pre);
354                 _strAddItems += string.Format("{1}//\r\n\t\t\t// {2}{0}\r\n\t\t\t//\r\n", dc.ColumnName, bFirst ? "\r\n" : "\t\t\t", pre);
355                 _strAddItems += string.Format("\t\t\tthis.{1}{0}.DataPropertyName = \"{0}\";\r\n", dc.ColumnName, pre);
356                 _strAddItems += string.Format("\t\t\tthis.{2}{0}.HeaderText = \"{1}\";\r\n", dc.ColumnName, dc.Caption, pre);
357                 _strAddItems += string.Format("\t\t\tthis.{1}{0}.HeadImage = null;\r\n", dc.ColumnName, pre);
358                 _strAddItems += string.Format("\t\t\tthis.{1}{0}.Name = \"{1}{0}\";\r\n", dc.ColumnName, pre);
359                 if (string.IsNullOrEmpty(dc.Caption) || (dc.ExtendedProperties.ContainsKey("_ispk") && Convert.ToBoolean(dc.ExtendedProperties["_ispk"])))
360                 {
361                     _strAddItems += string.Format("\t\t\tthis.{1}{0}.Visible = false;\r\n", dc.ColumnName, pre);
362                 }
363                 _strAddRange.TrimEnd(',');
364             }
365         }
366     }
367 }
View Code

 

模板:

模板文件说明:
Template1:双页面代码模板
Template1.Designer:双页面设计模板(含明细表)
Template1_1:双页面代码模板
Template1_1.Designer:双页面设计模板,含主表控件排列(含明细表)
Template1_2:双页面代码模板
Template1_2.Designer:双页面设计模板(不含明细表)
Template2:单页面代码模板
Template2.Designer:单页面设计模板
   1 ReadMe.txt
   2 ======================================================================
   3 模板文件说明:
   4 Template1:双页面代码模板
   5 Template1.Designer:双页面设计模板(含明细表)
   6 Template1_2:双页面代码模板
   7 Template1_2.Designer:双页面设计模板(不含明细表)
   8 Template2:单页面代码模板
   9 Template2.Designer:单页面设计模板
  10 
  11 Template
  12 ======================================================================
  13   14 using KYWMS.Util;
  15 using StyleForm.Win;
  16 using System;
  17 using System.Collections.Generic;
  18 using System.ComponentModel;
  19 using System.Data;
  20 using System.Drawing;
  21 using System.Linq;
  22 using System.Text;
  23 using System.Threading;
  24 using System.Windows.Forms;
  25 using WMS.Common;
  26 using WMS.Win;
  27 
  28 namespace @Namespace
  29 {
  30     public partial class @ClassName : @ClassBase
  31     {
  32         #region    窗体级变量定义区
  33         private bool _Falg = false;
  34         #endregion
  35 
  36         #region 初始化
  37         public @ClassName()
  38         {
  39             InitializeComponent();
  40             Load += @ClassName_Load;
  41         }
  42 
  43         void @ClassName_Load(object sender, EventArgs e)
  44         {
  45             FormUtil.hiddenShee2QueryBtn(this);
  46             btnRefresh.CanReadOnly = false;
  47             btnRefresh.Visible = true;
  48             this.BindData();
  49             this.LoadDataMaster("1=1", strUserPopedom);
  50         }
  51         #endregion
  52 
  53         #region 父类重写处理
  54         protected override void OnPreLoad(EventArgs e)
  55         {
  56             /*
  57             IniControlRight(btnQueryS, "btn001", "查询");
  58             IniControlRight(btnReport, "btn002", "导出");
  59             this.IniControlRight(this.btnQuery, "btnQuery", "通用查询");
  60             this.IniControlRight(this.btnRefresh, "btnRefresh", "刷新数据");
  61             this.IniControlRight(this.btnReport, "btnReport", "导出数据");
  62             this.IniControlRight(this.btnAddNew, "btnAddNew", "新增数据");
  63             this.IniControlRight(this.btnModify, "btnModify", "修改数据");
  64             this.IniControlRight(this.btnQueryS, "btnQueryS", "小查询");
  65             this.IniControlRight(this.btnDelete, "btnDelete", "删除");
  66             this.blnLock.CanReadOnly = false;
  67             this.blnLock.Visible = false;
  68             this.blnUnLock.CanReadOnly = false;
  69             this.blnUnLock.Visible = false;
  70              */
  71             
  72             //MyToolStripButton btnImport = new MyToolStripButton();
  73             //btnImport.Text = "导入";
  74             //btnImport.Image = Util.Properties.Resources.Report2;
  75             //btnImport.Click += new EventHandler(btnImport_Click);
  76             //btnImport.RightEnabled = true;
  77             //btnImport.RightName = "导入";
  78             //btnImport.RightCode = "btnImport";
  79             //toolMain.Items.Insert(24, btnImport);
  80 
  81             base.OnPreLoad(e);
  82         }
  83 
  84         private void btnImport_Click(object sender, EventArgs e)
  85         {
  86             ThreadPool.QueueUserWorkItem((obj) =>
  87             {
  88                 if (InvokeRequired && IsHandleCreated)
  89                 {
  90                     this.BeginInvoke(new Action<object>(delegate(object arg)
  91                     {
  92                         DoImport();
  93                     }), new object[] { null });
  94                 }
  95             });
  96         }
  97 
  98         //导出
  99         protected override bool OnWmsExport(object sender)
 100         {
 101             ExcelUtil.ToExcel(AppDataSet.Tables[0], dgvExpressQuote);
 102             return true;
 103         }
 104         protected override bool OnWmsNew(object sender, DataRow dataRow)
 105         {
 106 
 107             return base.OnWmsNew(sender, dataRow);
 108         }
 109         protected override bool OnWmsSave(object sender, DataRow dataRow)
 110         {
 111             if (dataRow.RowState != DataRowState.Deleted && !Check(dataRow))
 112             {
 113                 return false;
 114             }
 115             if (dataRow.RowState == DataRowState.Modified)
 116             {
 117                 //dataRow["ModifiedBy"] = SessionAuth.UserName;
 118                 //dataRow["ModifiedOn"] = WinSrv.ServerDateTime;
 119             }
 120             return base.OnWmsSave(sender, dataRow);
 121         }
 122 
 123         private bool Check(DataRow dataRow)
 124         {
 125             /*
 126             if (!CheckItem("中文列名", dataRow["ColumnName"].ToString()))
 127                 return false;
 128             */
 129             return true;
 130         }
 131 
 132         private bool CheckItem(string name, string value)
 133         {
 134             if (string.IsNullOrEmpty(value))
 135             {
 136                 MessageBoxShow(string.Format("{0}不能为空,请录入", name));
 137                 return false;
 138             }
 139             return true;
 140         }
 141 
 142         protected override void OnWmsCommanded(object sender, WMS.Common.CommandName commandName, params object[] commandArg)
 143         {
 144             base.OnWmsCommanded(sender, commandName, commandArg);
 145             if (commandName == WMS.Common.CommandName.Save)
 146                 OnWmsCommand(btnRefresh, CommandName.Refresh, true);
 147         }
 148 
 149         /// <summary>
 150         /// 执行导入
 151         /// </summary>
 152         private void DoImport()
 153         {
 154         }
 155         #endregion
 156     }
 157 }
 158 
 159 
 160 Template.Designer
 161 ======================================================================
 162 namespace @Namespace
 163 {
 164     partial class @ClassName
 165     {
 166         /// <summary>
 167         /// Required designer variable.
 168         /// </summary>
 169         private System.ComponentModel.IContainer components = null;
 170 
 171         /// <summary>
 172         /// Clean up any resources being used.
 173         /// </summary>
 174         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 175         protected override void Dispose(bool disposing)
 176         {
 177             if (disposing && (components != null))
 178             {
 179                 components.Dispose();
 180             }
 181             base.Dispose(disposing);
 182         }
 183 
 184         #region Windows Form Designer generated code
 185 
 186         /// <summary>
 187         /// Required method for Designer support - do not modify
 188         /// the contents of this method with the code editor.
 189         /// </summary>
 190         private void InitializeComponent()
 191         {
 192             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
 193             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FRM_TB_WMS_ExpressQuote));
 194             this.groupBox1 = new System.Windows.Forms.GroupBox();
 195             this.dgvExpressQuote = new WMS.Win.MyDataGridView();
 196             @NewItem
 197             this.myLabel1 = new WMS.Win.MyLabel();
 198             this.panel1 = new System.Windows.Forms.Panel();
 199             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).BeginInit();
 200             this.groupBox1.SuspendLayout();
 201             ((System.ComponentModel.ISupportInitialize)(this.dgvExpressQuote)).BeginInit();
 202             this.panel1.SuspendLayout();
 203             this.SuspendLayout();
 204             // 
 205             // pContainer
 206             // 
 207             this.pContainer.Size = new System.Drawing.Size(1076, 482);
 208             // 
 209             // groupLine
 210             // 
 211             this.groupLine.Location = new System.Drawing.Point(-3, 29);
 212             this.groupLine.Size = new System.Drawing.Size(1425, 2);
 213             // 
 214             // lblTitle1
 215             // 
 216             this.lblTitle1.Size = new System.Drawing.Size(153, 22);
 217             this.lblTitle1.Text = "B2B快递费报价";
 218             // 
 219             // groupBox1
 220             // 
 221             this.groupBox1.Controls.Add(this.dgvExpressQuote);
 222             this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
 223             this.groupBox1.Location = new System.Drawing.Point(8, 139);
 224             this.groupBox1.Name = "groupBox1";
 225             this.groupBox1.Size = new System.Drawing.Size(1076, 402);
 226             this.groupBox1.TabIndex = 6;
 227             this.groupBox1.TabStop = false;
 228             // 
 229             // dgvExpressQuote
 230             // 
 231             this.dgvExpressQuote.AllowUserToAddRows = false;
 232             this.dgvExpressQuote.AllowUserToOrderColumns = true;
 233             this.dgvExpressQuote.BackgroundColor = System.Drawing.Color.White;
 234             this.dgvExpressQuote.BindTableName = "TB_WMS_ExpressQuote";
 235             this.dgvExpressQuote.BorderStyle = System.Windows.Forms.BorderStyle.None;
 236             this.dgvExpressQuote.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
 237             this.dgvExpressQuote.ColumnHeadersHeight = 24;
 238             this.dgvExpressQuote.ColumnImageList = null;
 239             this.dgvExpressQuote.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
 240             @AddRange});
 241             this.dgvExpressQuote.DisplayRowNumber = true;
 242             this.dgvExpressQuote.Dock = System.Windows.Forms.DockStyle.Fill;
 243             this.dgvExpressQuote.EnableHeadersVisualStyles = false;
 244             this.dgvExpressQuote.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153)))));
 245             this.dgvExpressQuote.Location = new System.Drawing.Point(3, 17);
 246             this.dgvExpressQuote.Name = "dgvExpressQuote";
 247             dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
 248             dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
 249             dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134)));
 250             dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
 251             dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
 252             dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
 253             this.dgvExpressQuote.RowHeadersDefaultCellStyle = dataGridViewCellStyle1;
 254             this.dgvExpressQuote.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(226)))), ((int)(((byte)(240)))), ((int)(((byte)(246)))));
 255             this.dgvExpressQuote.RowTemplate.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.Black;
 256             this.dgvExpressQuote.RowTemplate.Height = 18;
 257             this.dgvExpressQuote.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
 258             this.dgvExpressQuote.Size = new System.Drawing.Size(1070, 382);
 259             this.dgvExpressQuote.TabIndex = 23;
 260             @AddItems
 261             // 
 262             // myLabel1
 263             // 
 264             this.myLabel1.AutoSize = true;
 265             this.myLabel1.BackColor = System.Drawing.Color.Transparent;
 266             this.myLabel1.CanReadOnly = false;
 267             this.myLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
 268             this.myLabel1.Location = new System.Drawing.Point(228, 24);
 269             this.myLabel1.Name = "myLabel1";
 270             this.myLabel1.Size = new System.Drawing.Size(155, 36);
 271             this.myLabel1.TabIndex = 8;
 272             this.myLabel1.Text = "①快递费均为JIT模式快递费\r\n\r\n②单位:元/KG";
 273             // 
 274             // panel1
 275             // 
 276             this.panel1.Controls.Add(this.myLabel1);
 277             this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
 278             this.panel1.Location = new System.Drawing.Point(8, 59);
 279             this.panel1.Name = "panel1";
 280             this.panel1.Size = new System.Drawing.Size(1076, 80);
 281             this.panel1.TabIndex = 9;
 282             // 
 283             // FRM_TB_WMS_ExpressQuote
 284             // 
 285             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
 286             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
 287             this.ClientSize = new System.Drawing.Size(1092, 549);
 288             this.Controls.Add(this.groupBox1);
 289             this.Controls.Add(this.panel1);
 290             this.Name = "FRM_TB_WMS_ExpressQuote";
 291             this.Text = "B2B快递费报价";
 292             this.Controls.SetChildIndex(this.pContainer, 0);
 293             this.Controls.SetChildIndex(this.groupLine, 0);
 294             this.Controls.SetChildIndex(this.panel1, 0);
 295             this.Controls.SetChildIndex(this.groupBox1, 0);
 296             this.Controls.SetChildIndex(this.pictTitle1, 0);
 297             this.Controls.SetChildIndex(this.lblTitle1, 0);
 298             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).EndInit();
 299             this.groupBox1.ResumeLayout(false);
 300             ((System.ComponentModel.ISupportInitialize)(this.dgvExpressQuote)).EndInit();
 301             this.panel1.ResumeLayout(false);
 302             this.panel1.PerformLayout();
 303             this.ResumeLayout(false);
 304             this.PerformLayout();
 305 
 306         }
 307 
 308         #endregion
 309 
 310         private System.Windows.Forms.GroupBox groupBox1;
 311         private WMS.Win.MyDataGridView dgvExpressQuote;
 312         private WMS.Win.MyLabel myLabel1;        
 313         private System.Windows.Forms.Panel panel1;
 314         @DefineItem
 315 
 316     }
 317 }
 318 
 319 Template1
 320 ======================================================================
 321 using KYWMS.Util;
 322 using StyleForm.Win;
 323 using System;
 324 using System.Collections.Generic;
 325 using System.ComponentModel;
 326 using System.Data;
 327 using System.Drawing;
 328 using System.Linq;
 329 using System.Text;
 330 using System.Windows.Forms;
 331 using WMS.Common;
 332 using WMS.Win;
 333 
 334 namespace @Namespace
 335 {
 336     public partial class @ClassName : @ClassBase
 337     {
 338         #region 窗体级变量定义区域
 339         private string strWhereM = string.Empty;
 340 
 341         #endregion
 342 
 343         #region 窗体级事件区域
 344         public @ClassName()
 345         {
 346             InitializeComponent();
 347         }
 348 
 349         protected override void OnPreLoad(EventArgs e)
 350         {
 351             /*
 352             this.btnAddNew.CanReadOnly = false;
 353             this.btnAddNew.Visible = false;
 354             this.btnDelete.CanReadOnly = false;
 355             this.btnDelete.Visible = false;
 356             blnLock.CanReadOnly = false;
 357             blnLock.Visible = false;
 358             blnUnLock.CanReadOnly = false;
 359             blnUnLock.Visible = false;
 360             this.IniControlRight(this.btnQuery, "btnQuery", "通用查询");
 361             this.IniControlRight(this.btnRefresh, "btnRefresh", "刷新数据");
 362             this.IniControlRight(this.btnReport, "btnReport", "导出数据");
 363             this.IniControlRight(this.btnAddNew, "btnAddNew", "新增数据");
 364             this.IniControlRight(this.btnModify, "btnModify", "修改数据");
 365             this.IniControlRight(btnQueryQ, "btnQueryQ", "查询(Q)");
 366             this.IniControlRight(this.btnQueryS, "btnQueryS", "小查询");*/
 367             base.OnPreLoad(e);
 368         }
 369         private void @ClassName_Load(object sender, EventArgs e)
 370         {
 371             //labOrderNo.Text = "箱号";
 372             SetUserPopedomString();
 373             this.BindData();
 374             strWhereM = " 1=1 ";
 375             this.LoadDataMaster(strWhereM, strUserPopedom);
 376         }
 377 
 378         #endregion
 379 
 380         #region 函数及过程区域
 381         /// <summary>
 382         /// 权限设置
 383         /// </summary>
 384         private void SetUserPopedomString()
 385         {
 386 
 387         }
 388 
 389         /// <summary>
 390         /// 数据检查
 391         /// </summary>
 392         /// <param name="dataRow"></param>
 393         /// <returns></returns>
 394         private bool CheckData(DataRow dataRow)
 395         {
 396             return true;
 397         }
 398 
 399         #endregion
 400 
 401         #region 窗体按钮功能代码区域
 402         /// <summary>
 403         /// 查询
 404         /// </summary>
 405         /// <param name="sender"></param>
 406         /// <param name="e"></param>
 407         private void btnQueryQ_Click(object sender, EventArgs e)
 408         {
 409             /*
 410             try
 411             {
 412                 this.Cursor = Cursors.WaitCursor;
 413                 string strWh = txtOutWhQ.Text.Trim();
 414                 string strBoxNo = txtBoxNoQ.Text.Trim();
 415 
 416                 StringBuilder mSQL = new StringBuilder();
 417                 mSQL.Append(" 1 = 1 ");
 418                 if (!string.IsNullOrEmpty(strWh))
 419                 {
 420                     mSQL.AppendFormat("AND OutWh like N'{0}%'", strWh);
 421                 }
 422                 if (!string.IsNullOrEmpty(strBoxNo))
 423                 {
 424                     mSQL.AppendFormat("AND BoxNo like N'{0}%'", strBoxNo);
 425                 }
 426                 this.LoadDataMaster(mSQL.ToString(), strUserPopedom);
 427             }
 428             catch (Exception ex)
 429             {
 430                 MessageBox.Show(ex.Message);
 431             }
 432             finally
 433             {
 434                 this.Cursor = Cursors.Default;
 435             }
 436              */
 437         }
 438 
 439         #endregion
 440 
 441         #region 控件业务逻辑
 442         protected override bool OnWmsCommanding(object sender, CommandName commandName, params object[] commandArgs)
 443         {
 444             return base.OnWmsCommanding(sender, commandName, commandArgs);
 445         }
 446 
 447         protected override bool OnWmsCommand(object sender, CommandName commandName, params object[] commandArgs)
 448         {
 449             if (commandName == CommandName.FillComplete)
 450             {
 451 
 452             }
 453             return base.OnWmsCommand(sender, commandName, commandArgs);
 454         }
 455 
 456         protected override void OnWmsCommanded(object sender, CommandName commandName, params object[] commandArg)
 457         {
 458             if (commandName == CommandName.Save)
 459             {
 460 
 461             }
 462             base.OnWmsCommanded(sender, commandName, commandArg);
 463         }
 464 
 465         protected override bool OnWmsColumnChang(object sender, DataRow dataRow, DataColumn dataColumn, object proposedValue)
 466         {
 467 
 468             return base.OnWmsColumnChang(sender, dataRow, dataColumn, proposedValue);
 469         }
 470 
 471         protected override bool OnWmsDelete(object sender, DataRow dataRow)
 472         {
 473             return base.OnWmsDelete(sender, dataRow);
 474         }
 475 
 476         protected override bool OnWmsSave(object sender, DataRow dataRow)
 477         {
 478             try
 479             {
 480                 if (dataRow.RowState != DataRowState.Deleted && !CheckData(dataRow))
 481                 {
 482                     return false;
 483                 }
 484 
 485             }
 486             catch (Exception ex)
 487             {
 488                 MessageBoxShow(ex.Message);
 489                 return false;
 490             }
 491             return base.OnWmsSave(sender, dataRow);
 492         }
 493 
 494         protected override bool OnWmsNew(object sender, DataRow dataRow)
 495         {
 496             return base.OnWmsNew(sender, dataRow);
 497         }
 498 
 499         protected override bool OnWmsQuerys(object sender, string value)
 500         {
 501             //strWhereM = " BoxNo = N'" + value + "' ";
 502             //this.LoadDataMaster(strWhereM, strUserPopedom);
 503             return true;
 504         }
 505 
 506         protected override bool OnWmsExport(object sender)
 507         {
 508             ExcelUtil.ToExcel(AppDataSet.Tables[0], dgv@TableName);
 509             return base.OnWmsExport(sender);
 510         }
 511         #endregion
 512 
 513     }
 514 }
 515 
 516 
 517 Template1.Designer
 518 ======================================================================
 519 namespace @Namespace
 520 {
 521     partial class @ClassName
 522     {
 523         /// <summary>
 524         /// Required designer variable.
 525         /// </summary>
 526         private System.ComponentModel.IContainer components = null;
 527 
 528         /// <summary>
 529         /// Clean up any resources being used.
 530         /// </summary>
 531         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 532         protected override void Dispose(bool disposing)
 533         {
 534             if (disposing && (components != null))
 535             {
 536                 components.Dispose();
 537             }
 538             base.Dispose(disposing);
 539         }
 540 
 541         #region Windows Form Designer generated code
 542 
 543         /// <summary>
 544         /// Required method for Designer support - do not modify
 545         /// the contents of this method with the code editor.
 546         /// </summary>
 547         private void InitializeComponent()
 548         {
 549             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(@ClassName));
 550             this.myPanel1 = new WMS.Win.MyPanel();
 551             this.dgv@TableName = new WMS.Win.MyDataGridView();
 552             @NewItem
 553             this.panel1 = new System.Windows.Forms.Panel();
 554             this.myPanel2 = new WMS.Win.MyPanel();
 555             this.myGroupBox1 = new WMS.Win.MyGroupBox();
 556             this.myTabControl1 = new WMS.Win.MyTabControl();
 557             this.tabPage3 = new System.Windows.Forms.TabPage();
 558             this.dgv@TableNameDetail = new WMS.Win.MyDataGridView();
 559             this.tabPage1.SuspendLayout();
 560             this.tabMain.SuspendLayout();
 561             this.tabPage2.SuspendLayout();
 562             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).BeginInit();
 563             ((System.ComponentModel.ISupportInitialize)(this.pictTitle2)).BeginInit();
 564             this.myPanel1.SuspendLayout();
 565             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableName)).BeginInit();
 566             this.myPanel2.SuspendLayout();
 567             this.myGroupBox1.SuspendLayout();
 568             this.myTabControl1.SuspendLayout();
 569             this.tabPage3.SuspendLayout();
 570             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableNameDetail)).BeginInit();
 571             this.SuspendLayout();
 572             // 
 573             // groupLine
 574             // 
 575             this.groupLine.Location = new System.Drawing.Point(-3, 29);
 576             this.groupLine.Size = new System.Drawing.Size(1517, 2);
 577             // 
 578             // tabPage1
 579             // 
 580             this.tabPage1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(242)))));
 581             this.tabPage1.BackgroundImage = null;
 582             this.tabPage1.Controls.Add(this.myPanel1);
 583             this.tabPage1.Size = new System.Drawing.Size(1160, 615);
 584             this.tabPage1.UseVisualStyleBackColor = false;
 585             this.tabPage1.Controls.SetChildIndex(this.myPanel1, 0);
 586             this.tabPage1.Controls.SetChildIndex(this.pictTitle1, 0);
 587             this.tabPage1.Controls.SetChildIndex(this.lblTitle1, 0);
 588             // 
 589             // tabMain
 590             // 
 591             this.tabMain.Size = new System.Drawing.Size(1168, 641);
 592             // 
 593             // tabPage2
 594             // 
 595             this.tabPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(242)))));
 596             this.tabPage2.BackgroundImage = null;
 597             this.tabPage2.Controls.Add(this.myPanel2);
 598             this.tabPage2.Size = new System.Drawing.Size(1160, 615);
 599             this.tabPage2.UseVisualStyleBackColor = false;
 600             this.tabPage2.Controls.SetChildIndex(this.myPanel2, 0);
 601             this.tabPage2.Controls.SetChildIndex(this.pictTitle2, 0);
 602             this.tabPage2.Controls.SetChildIndex(this.lblTitle2, 0);
 603             // 
 604             // lblTitle1
 605             // 
 606             this.lblTitle1.Text = "@ClassText";
 607             // 
 608             // lblTitle2
 609             // 
 610             this.lblTitle2.Font = new System.Drawing.Font("隶书", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
 611             this.lblTitle2.Size = new System.Drawing.Size(98, 22);
 612             this.lblTitle2.Text = "@ClassText";
 613             // 
 614             // myPanel1
 615             // 
 616             this.myPanel1.BorderColor = System.Drawing.Color.White;
 617             this.myPanel1.Controls.Add(this.dgv@TableName);
 618             this.myPanel1.Controls.Add(this.panel1);
 619             this.myPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
 620             this.myPanel1.Location = new System.Drawing.Point(3, 3);
 621             this.myPanel1.MouseDownImage = null;
 622             this.myPanel1.MouseEnterImage = null;
 623             this.myPanel1.Name = "myPanel1";
 624             this.myPanel1.Size = new System.Drawing.Size(1154, 609);
 625             this.myPanel1.TabIndex = 6;
 626             this.myPanel1.TransparentColor = System.Drawing.Color.Transparent;
 627             // 
 628             // dgv@TableName
 629             // 
 630             this.dgv@TableName.AllowUserToAddRows = false;
 631             this.dgv@TableName.AllowUserToDeleteRows = false;
 632             this.dgv@TableName.AllowUserToOrderColumns = true;
 633             this.dgv@TableName.BackgroundColor = System.Drawing.Color.White;
 634             this.dgv@TableName.BindTableName = "@TableName";
 635             this.dgv@TableName.BorderStyle = System.Windows.Forms.BorderStyle.None;
 636             this.dgv@TableName.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
 637             this.dgv@TableName.ColumnHeadersHeight = 24;
 638             this.dgv@TableName.ColumnImageList = null;
 639             this.dgv@TableName.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
 640             @AddRange});
 641             this.dgv@TableName.DisplayRowNumber = true;
 642             this.dgv@TableName.Dock = System.Windows.Forms.DockStyle.Fill;
 643             this.dgv@TableName.EnableHeadersVisualStyles = false;
 644             this.dgv@TableName.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153)))));
 645             this.dgv@TableName.Location = new System.Drawing.Point(0, 80);
 646             this.dgv@TableName.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
 647             this.dgv@TableName.Name = "dgv@TableName";
 648             this.dgv@TableName.ReadOnly = true;
 649             this.dgv@TableName.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(226)))), ((int)(((byte)(240)))), ((int)(((byte)(246)))));
 650             this.dgv@TableName.RowTemplate.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.Black;
 651             this.dgv@TableName.RowTemplate.Height = 18;
 652             this.dgv@TableName.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
 653             this.dgv@TableName.Size = new System.Drawing.Size(1154, 529);
 654             this.dgv@TableName.TabIndex = 127;
 655             @AddItems
 656             // 
 657             // panel1
 658             // 
 659             this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
 660             this.panel1.Location = new System.Drawing.Point(0, 0);
 661             this.panel1.Name = "panel1";
 662             this.panel1.Size = new System.Drawing.Size(1154, 80);
 663             this.panel1.TabIndex = 128;
 664             // 
 665             // myPanel2
 666             // 
 667             this.myPanel2.BorderColor = System.Drawing.Color.White;
 668             this.myPanel2.Controls.Add(this.myGroupBox1);
 669             this.myPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
 670             this.myPanel2.Location = new System.Drawing.Point(3, 3);
 671             this.myPanel2.MouseDownImage = null;
 672             this.myPanel2.MouseEnterImage = null;
 673             this.myPanel2.Name = "myPanel2";
 674             this.myPanel2.Size = new System.Drawing.Size(1154, 609);
 675             this.myPanel2.TabIndex = 8;
 676             this.myPanel2.TransparentColor = System.Drawing.Color.Transparent;
 677             // 
 678             // myGroupBox1
 679             // 
 680             this.myGroupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
 681             | System.Windows.Forms.AnchorStyles.Left) 
 682             | System.Windows.Forms.AnchorStyles.Right)));
 683             this.myGroupBox1.Controls.Add(this.myTabControl1);
 684             this.myGroupBox1.Location = new System.Drawing.Point(5, 50);
 685             this.myGroupBox1.Name = "myGroupBox1";
 686             this.myGroupBox1.Size = new System.Drawing.Size(1144, 556);
 687             this.myGroupBox1.TabIndex = 9;
 688             this.myGroupBox1.TabStop = false;
 689             // 
 690             // myTabControl1
 691             // 
 692             this.myTabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
 693             | System.Windows.Forms.AnchorStyles.Left) 
 694             | System.Windows.Forms.AnchorStyles.Right)));
 695             this.myTabControl1.Controls.Add(this.tabPage3);
 696             this.myTabControl1.Location = new System.Drawing.Point(0, 134);
 697             this.myTabControl1.Name = "myTabControl1";
 698             this.myTabControl1.SelectedIndex = 0;
 699             this.myTabControl1.Size = new System.Drawing.Size(841, 420);
 700             this.myTabControl1.TabIndex = 25;
 701             // 
 702             // tabPage3
 703             // 
 704             this.tabPage3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(242)))));
 705             this.tabPage3.Controls.Add(this.dgv@TableNameDetail);
 706             this.tabPage3.Location = new System.Drawing.Point(4, 22);
 707             this.tabPage3.Name = "tabPage3";
 708             this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
 709             this.tabPage3.Size = new System.Drawing.Size(833, 394);
 710             this.tabPage3.TabIndex = 0;
 711             this.tabPage3.Text = "@ClassText明细";
 712             // 
 713             // dgv@TableNameDetail
 714             // 
 715             this.dgv@TableNameDetail.AllowUserToAddRows = false;
 716             this.dgv@TableNameDetail.AllowUserToDeleteRows = false;
 717             this.dgv@TableNameDetail.AllowUserToOrderColumns = true;
 718             this.dgv@TableNameDetail.BackgroundColor = System.Drawing.Color.White;
 719             this.dgv@TableNameDetail.BorderStyle = System.Windows.Forms.BorderStyle.None;
 720             this.dgv@TableNameDetail.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
 721             this.dgv@TableNameDetail.ColumnHeadersHeight = 24;
 722             this.dgv@TableNameDetail.ColumnImageList = null;
 723             this.dgv@TableNameDetail.DisplayRowNumber = true;
 724             this.dgv@TableNameDetail.Dock = System.Windows.Forms.DockStyle.Fill;
 725             this.dgv@TableNameDetail.EnableHeadersVisualStyles = false;
 726             this.dgv@TableNameDetail.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153)))));
 727             this.dgv@TableNameDetail.Location = new System.Drawing.Point(3, 3);
 728             this.dgv@TableNameDetail.Name = "dgv@TableNameDetail";
 729             this.dgv@TableNameDetail.ReadOnly = true;
 730             this.dgv@TableNameDetail.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(226)))), ((int)(((byte)(240)))), ((int)(((byte)(246)))));
 731             this.dgv@TableNameDetail.RowTemplate.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.Black;
 732             this.dgv@TableNameDetail.RowTemplate.Height = 18;
 733             this.dgv@TableNameDetail.Size = new System.Drawing.Size(827, 388);
 734             this.dgv@TableNameDetail.TabIndex = 12;
 735             this.dgv@TableNameDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
 736             @AddSubRange});
 737             // 
 738             // FRM_TA_BIZ_BoxDelivery
 739             // 
 740             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
 741             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
 742             this.ClientSize = new System.Drawing.Size(1184, 685);
 743             this.Name = "@ClassName";
 744             this.Text = "@ClassText";
 745             this.Load += new System.EventHandler(this.@ClassName_Load);
 746             this.tabPage1.ResumeLayout(false);
 747             this.tabPage1.PerformLayout();
 748             this.tabMain.ResumeLayout(false);
 749             this.tabPage2.ResumeLayout(false);
 750             this.tabPage2.PerformLayout();
 751             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).EndInit();
 752             ((System.ComponentModel.ISupportInitialize)(this.pictTitle2)).EndInit();
 753             this.myPanel1.ResumeLayout(false);
 754             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableName)).EndInit();
 755             this.myPanel2.ResumeLayout(false);
 756             this.myGroupBox1.ResumeLayout(false);
 757             this.myTabControl1.ResumeLayout(false);
 758             this.tabPage3.ResumeLayout(false);
 759             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableNameDetail)).EndInit();
 760             this.ResumeLayout(false);
 761             this.PerformLayout();
 762 
 763         }
 764 
 765         #endregion
 766 
 767         private WMS.Win.MyPanel myPanel1;
 768         private WMS.Win.MyPanel myPanel2;
 769         private WMS.Win.MyGroupBox myGroupBox1;
 770         private WMS.Win.MyTabControl myTabControl1;
 771         private System.Windows.Forms.TabPage tabPage3;
 772         private WMS.Win.MyDataGridView dgv@TableNameDetail;
 773         private System.Windows.Forms.Panel panel1;
 774         private WMS.Win.MyDataGridView dgv@TableName;
 775         @DefineItem
 776     }
 777 }
 778 
 779 Template1_1
 780 ======================================================================
 781 using KYWMS.Util;
 782 using StyleForm.Win;
 783 using System;
 784 using System.Collections.Generic;
 785 using System.ComponentModel;
 786 using System.Data;
 787 using System.Drawing;
 788 using System.Linq;
 789 using System.Text;
 790 using System.Windows.Forms;
 791 using WMS.Common;
 792 using WMS.Win;
 793 
 794 namespace @Namespace
 795 {
 796     public partial class @ClassName : @ClassBase
 797     {
 798         #region 窗体级变量定义区域
 799         private string strWhereM = string.Empty;
 800 
 801         #endregion
 802 
 803         #region 窗体级事件区域
 804         public @ClassName()
 805         {
 806             InitializeComponent();
 807         }
 808 
 809         protected override void OnPreLoad(EventArgs e)
 810         {
 811             /*
 812             this.btnAddNew.CanReadOnly = false;
 813             this.btnAddNew.Visible = false;
 814             this.btnDelete.CanReadOnly = false;
 815             this.btnDelete.Visible = false;
 816             blnLock.CanReadOnly = false;
 817             blnLock.Visible = false;
 818             blnUnLock.CanReadOnly = false;
 819             blnUnLock.Visible = false;
 820             this.IniControlRight(this.btnQuery, "btnQuery", "通用查询");
 821             this.IniControlRight(this.btnRefresh, "btnRefresh", "刷新数据");
 822             this.IniControlRight(this.btnReport, "btnReport", "导出数据");
 823             this.IniControlRight(this.btnAddNew, "btnAddNew", "新增数据");
 824             this.IniControlRight(this.btnModify, "btnModify", "修改数据");
 825             this.IniControlRight(btnQueryQ, "btnQueryQ", "查询(Q)");
 826             this.IniControlRight(this.btnQueryS, "btnQueryS", "小查询");*/
 827             base.OnPreLoad(e);
 828         }
 829         private void @ClassName_Load(object sender, EventArgs e)
 830         {
 831             //labOrderNo.Text = "箱号";
 832             SetUserPopedomString();
 833             this.BindData();
 834             strWhereM = " 1=1 ";
 835             this.LoadDataMaster(strWhereM, strUserPopedom);
 836         }
 837 
 838         #endregion
 839 
 840         #region 函数及过程区域
 841         /// <summary>
 842         /// 权限设置
 843         /// </summary>
 844         private void SetUserPopedomString()
 845         {
 846 
 847         }
 848 
 849         /// <summary>
 850         /// 数据检查
 851         /// </summary>
 852         /// <param name="dataRow"></param>
 853         /// <returns></returns>
 854         private bool CheckData(DataRow dataRow)
 855         {
 856             this.SetDefaultValue(dataRow);
 857             return true;
 858         }
 859 
 860         #endregion
 861 
 862         #region 窗体按钮功能代码区域
 863         /// <summary>
 864         /// 查询
 865         /// </summary>
 866         /// <param name="sender"></param>
 867         /// <param name="e"></param>
 868         private void btnQueryQ_Click(object sender, EventArgs e)
 869         {
 870             /*
 871             try
 872             {
 873                 this.Cursor = Cursors.WaitCursor;
 874                 string strWh = txtOutWhQ.Text.Trim();
 875                 string strBoxNo = txtBoxNoQ.Text.Trim();
 876 
 877                 StringBuilder mSQL = new StringBuilder();
 878                 mSQL.Append(" 1 = 1 ");
 879                 if (!string.IsNullOrEmpty(strWh))
 880                 {
 881                     mSQL.AppendFormat("AND OutWh like N'{0}%'", strWh);
 882                 }
 883                 if (!string.IsNullOrEmpty(strBoxNo))
 884                 {
 885                     mSQL.AppendFormat("AND BoxNo like N'{0}%'", strBoxNo);
 886                 }
 887                 this.LoadDataMaster(mSQL.ToString(), strUserPopedom);
 888             }
 889             catch (Exception ex)
 890             {
 891                 MessageBox.Show(ex.Message);
 892             }
 893             finally
 894             {
 895                 this.Cursor = Cursors.Default;
 896             }
 897              */
 898         }
 899 
 900         #endregion
 901 
 902         #region 控件业务逻辑
 903         protected override bool OnWmsCommanding(object sender, CommandName commandName, params object[] commandArgs)
 904         {
 905             return base.OnWmsCommanding(sender, commandName, commandArgs);
 906         }
 907 
 908         protected override bool OnWmsCommand(object sender, CommandName commandName, params object[] commandArgs)
 909         {
 910             if (commandName == CommandName.FillComplete)
 911             {
 912 
 913             }
 914             return base.OnWmsCommand(sender, commandName, commandArgs);
 915         }
 916 
 917         protected override void OnWmsCommanded(object sender, CommandName commandName, params object[] commandArg)
 918         {
 919             if (commandName == CommandName.Save)
 920             {
 921 
 922             }
 923             base.OnWmsCommanded(sender, commandName, commandArg);
 924         }
 925 
 926         protected override bool OnWmsColumnChang(object sender, DataRow dataRow, DataColumn dataColumn, object proposedValue)
 927         {
 928 
 929             return base.OnWmsColumnChang(sender, dataRow, dataColumn, proposedValue);
 930         }
 931 
 932         protected override bool OnWmsDelete(object sender, DataRow dataRow)
 933         {
 934             return base.OnWmsDelete(sender, dataRow);
 935         }
 936 
 937         protected override bool OnWmsSave(object sender, DataRow dataRow)
 938         {
 939             try
 940             {
 941                 if (dataRow.RowState != DataRowState.Deleted && !CheckData(dataRow))
 942                 {
 943                     return false;
 944                 }
 945 
 946             }
 947             catch (Exception ex)
 948             {
 949                 MessageBoxShow(ex.Message);
 950                 return false;
 951             }
 952             return base.OnWmsSave(sender, dataRow);
 953         }
 954 
 955         protected override bool OnWmsNew(object sender, DataRow dataRow)
 956         {
 957             return base.OnWmsNew(sender, dataRow);
 958         }
 959 
 960         protected override bool OnWmsQuerys(object sender, string value)
 961         {
 962             //strWhereM = " BoxNo = N'" + value + "' ";
 963             //this.LoadDataMaster(strWhereM, strUserPopedom);
 964             return true;
 965         }
 966 
 967         protected override bool OnWmsExport(object sender)
 968         {
 969             ExcelUtil.ToExcel(AppDataSet.Tables[0], dgv@TableName);
 970             return base.OnWmsExport(sender);
 971         }
 972         #endregion
 973 
 974     }
 975 }
 976 
 977 
 978 Template1_1.Designer
 979 ======================================================================
 980 namespace @Namespace
 981 {
 982     partial class @ClassName
 983     {
 984         /// <summary>
 985         /// Required designer variable.
 986         /// </summary>
 987         private System.ComponentModel.IContainer components = null;
 988 
 989         /// <summary>
 990         /// Clean up any resources being used.
 991         /// </summary>
 992         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 993         protected override void Dispose(bool disposing)
 994         {
 995             if (disposing && (components != null))
 996             {
 997                 components.Dispose();
 998             }
 999             base.Dispose(disposing);
1000         }
1001 
1002         #region Windows Form Designer generated code
1003 
1004         /// <summary>
1005         /// Required method for Designer support - do not modify
1006         /// the contents of this method with the code editor.
1007         /// </summary>
1008         private void InitializeComponent()
1009         {
1010             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(@ClassName));
1011             this.myPanel1 = new WMS.Win.MyPanel();
1012             this.myGroupBox2 = new WMS.Win.MyGroupBox();
1013             this.dgv@TableName = new WMS.Win.MyDataGridView();
1014             @NewItem
1015             this.panel1 = new System.Windows.Forms.Panel();
1016             this.myPanel2 = new WMS.Win.MyPanel();
1017             this.myGroupBox1 = new WMS.Win.MyGroupBox();
1018             this.myTabControl1 = new WMS.Win.MyTabControl();
1019             this.tabPage3 = new System.Windows.Forms.TabPage();
1020             this.dgv@TableNameDetail = new WMS.Win.MyDataGridView();
1021             this.tabPage1.SuspendLayout();
1022             this.tabMain.SuspendLayout();
1023             this.tabPage2.SuspendLayout();
1024             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).BeginInit();
1025             ((System.ComponentModel.ISupportInitialize)(this.pictTitle2)).BeginInit();
1026             this.myPanel1.SuspendLayout();
1027             this.myGroupBox2.SuspendLayout();
1028             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableName)).BeginInit();
1029             this.myPanel2.SuspendLayout();
1030             this.myGroupBox1.SuspendLayout();
1031             this.myTabControl1.SuspendLayout();
1032             this.tabPage3.SuspendLayout();
1033             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableNameDetail)).BeginInit();
1034             this.SuspendLayout();
1035             // 
1036             // groupLine
1037             // 
1038             this.groupLine.Location = new System.Drawing.Point(-3, 29);
1039             this.groupLine.Size = new System.Drawing.Size(1517, 2);
1040             // 
1041             // tabPage1
1042             // 
1043             this.tabPage1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(242)))));
1044             this.tabPage1.BackgroundImage = null;
1045             this.tabPage1.Controls.Add(this.myPanel1);
1046             this.tabPage1.Size = new System.Drawing.Size(1160, 615);
1047             this.tabPage1.UseVisualStyleBackColor = false;
1048             this.tabPage1.Controls.SetChildIndex(this.myPanel1, 0);
1049             this.tabPage1.Controls.SetChildIndex(this.pictTitle1, 0);
1050             this.tabPage1.Controls.SetChildIndex(this.lblTitle1, 0);
1051             // 
1052             // tabMain
1053             // 
1054             this.tabMain.Size = new System.Drawing.Size(1168, 641);
1055             // 
1056             // tabPage2
1057             // 
1058             this.tabPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(242)))));
1059             this.tabPage2.BackgroundImage = null;
1060             this.tabPage2.Controls.Add(this.myPanel2);
1061             this.tabPage2.Size = new System.Drawing.Size(1160, 615);
1062             this.tabPage2.UseVisualStyleBackColor = false;
1063             this.tabPage2.Controls.SetChildIndex(this.myPanel2, 0);
1064             this.tabPage2.Controls.SetChildIndex(this.pictTitle2, 0);
1065             this.tabPage2.Controls.SetChildIndex(this.lblTitle2, 0);
1066             // 
1067             // lblTitle1
1068             // 
1069             this.lblTitle1.Text = "@ClassText";
1070             // 
1071             // lblTitle2
1072             // 
1073             this.lblTitle2.Font = new System.Drawing.Font("隶书", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
1074             this.lblTitle2.Size = new System.Drawing.Size(98, 22);
1075             this.lblTitle2.Text = "@ClassText";
1076             // 
1077             // myPanel1
1078             // 
1079             this.myPanel1.BorderColor = System.Drawing.Color.White;
1080             this.myPanel1.Controls.Add(this.myGroupBox2);
1081             this.myPanel1.Controls.Add(this.panel1);
1082             this.myPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
1083             this.myPanel1.Location = new System.Drawing.Point(3, 3);
1084             this.myPanel1.MouseDownImage = null;
1085             this.myPanel1.MouseEnterImage = null;
1086             this.myPanel1.Name = "myPanel1";
1087             this.myPanel1.Size = new System.Drawing.Size(1154, 609);
1088             this.myPanel1.TabIndex = 6;
1089             this.myPanel1.TransparentColor = System.Drawing.Color.Transparent;
1090             // 
1091             // myGroupBox2
1092             // 
1093             this.myGroupBox2.Controls.Add(this.dgv@TableName);
1094             this.myGroupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
1095             this.myGroupBox2.Location = new System.Drawing.Point(0, 80);
1096             this.myGroupBox2.Name = "myGroupBox2";
1097             this.myGroupBox2.Size = new System.Drawing.Size(1154, 529);
1098             this.myGroupBox2.TabIndex = 129;
1099             this.myGroupBox2.TabStop = false;
1100             @HeadItemControls
1101             // 
1102             // dgv@TableName
1103             // 
1104             this.dgv@TableName.AllowUserToAddRows = false;
1105             this.dgv@TableName.AllowUserToDeleteRows = false;
1106             this.dgv@TableName.AllowUserToOrderColumns = true;
1107             this.dgv@TableName.BackgroundColor = System.Drawing.Color.White;
1108             this.dgv@TableName.BindTableName = "@TableName";
1109             this.dgv@TableName.BorderStyle = System.Windows.Forms.BorderStyle.None;
1110             this.dgv@TableName.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
1111             this.dgv@TableName.ColumnHeadersHeight = 24;
1112             this.dgv@TableName.ColumnImageList = null;
1113             this.dgv@TableName.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
1114             @AddRange});
1115             this.dgv@TableName.DisplayRowNumber = true;
1116             this.dgv@TableName.Dock = System.Windows.Forms.DockStyle.Fill;
1117             this.dgv@TableName.EnableHeadersVisualStyles = false;
1118             this.dgv@TableName.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153)))));
1119             this.dgv@TableName.Location = new System.Drawing.Point(0, 80);
1120             this.dgv@TableName.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
1121             this.dgv@TableName.Name = "dgv@TableName";
1122             this.dgv@TableName.ReadOnly = true;
1123             this.dgv@TableName.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(226)))), ((int)(((byte)(240)))), ((int)(((byte)(246)))));
1124             this.dgv@TableName.RowTemplate.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.Black;
1125             this.dgv@TableName.RowTemplate.Height = 18;
1126             this.dgv@TableName.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
1127             this.dgv@TableName.Size = new System.Drawing.Size(1154, 529);
1128             this.dgv@TableName.TabIndex = 127;
1129             @AddItems
1130             // 
1131             // panel1
1132             // 
1133             this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
1134             this.panel1.Location = new System.Drawing.Point(0, 0);
1135             this.panel1.Name = "panel1";
1136             this.panel1.Size = new System.Drawing.Size(1154, 80);
1137             this.panel1.TabIndex = 128;
1138             // 
1139             // myPanel2
1140             // 
1141             this.myPanel2.BorderColor = System.Drawing.Color.White;
1142             this.myPanel2.Controls.Add(this.myGroupBox1);
1143             this.myPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
1144             this.myPanel2.Location = new System.Drawing.Point(3, 3);
1145             this.myPanel2.MouseDownImage = null;
1146             this.myPanel2.MouseEnterImage = null;
1147             this.myPanel2.Name = "myPanel2";
1148             this.myPanel2.Size = new System.Drawing.Size(1154, 609);
1149             this.myPanel2.TabIndex = 8;
1150             this.myPanel2.TransparentColor = System.Drawing.Color.Transparent;
1151             // 
1152             // myGroupBox1
1153             // 
1154             this.myGroupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
1155             | System.Windows.Forms.AnchorStyles.Left) 
1156             | System.Windows.Forms.AnchorStyles.Right)));
1157             @HeadItemBeginthis.myGroupBox1.Controls.Add(@HeadControlItem);@HeadItemEnd
1158             this.myGroupBox1.Controls.Add(this.myTabControl1);
1159             this.myGroupBox1.Location = new System.Drawing.Point(5, 50);
1160             this.myGroupBox1.Name = "myGroupBox1";
1161             this.myGroupBox1.Size = new System.Drawing.Size(1144, 556);
1162             this.myGroupBox1.TabIndex = 9;
1163             this.myGroupBox1.TabStop = false;
1164             // 
1165             // myTabControl1
1166             // 
1167             this.myTabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
1168             | System.Windows.Forms.AnchorStyles.Left) 
1169             | System.Windows.Forms.AnchorStyles.Right)));
1170             this.myTabControl1.Controls.Add(this.tabPage3);
1171             this.myTabControl1.Location = new System.Drawing.Point(0, 134);
1172             this.myTabControl1.Name = "myTabControl1";
1173             this.myTabControl1.SelectedIndex = 0;
1174             this.myTabControl1.Size = new System.Drawing.Size(841, 420);
1175             this.myTabControl1.TabIndex = 25;
1176             // 
1177             // tabPage3
1178             // 
1179             this.tabPage3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(242)))));
1180             this.tabPage3.Controls.Add(this.dgv@TableNameDetail);
1181             this.tabPage3.Location = new System.Drawing.Point(4, 22);
1182             this.tabPage3.Name = "tabPage3";
1183             this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
1184             this.tabPage3.Size = new System.Drawing.Size(833, 394);
1185             this.tabPage3.TabIndex = 0;
1186             this.tabPage3.Text = "@ClassText明细";
1187             // 
1188             // dgv@TableNameDetail
1189             // 
1190             this.dgv@TableNameDetail.AllowUserToAddRows = false;
1191             this.dgv@TableNameDetail.AllowUserToDeleteRows = false;
1192             this.dgv@TableNameDetail.AllowUserToOrderColumns = true;
1193             this.dgv@TableNameDetail.BackgroundColor = System.Drawing.Color.White;
1194             this.dgv@TableNameDetail.BorderStyle = System.Windows.Forms.BorderStyle.None;
1195             this.dgv@TableNameDetail.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
1196             this.dgv@TableNameDetail.ColumnHeadersHeight = 24;
1197             this.dgv@TableNameDetail.ColumnImageList = null;
1198             this.dgv@TableNameDetail.DisplayRowNumber = true;
1199             this.dgv@TableNameDetail.Dock = System.Windows.Forms.DockStyle.Fill;
1200             this.dgv@TableNameDetail.EnableHeadersVisualStyles = false;
1201             this.dgv@TableNameDetail.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153)))));
1202             this.dgv@TableNameDetail.Location = new System.Drawing.Point(3, 3);
1203             this.dgv@TableNameDetail.Name = "dgv@TableNameDetail";
1204             this.dgv@TableNameDetail.ReadOnly = true;
1205             this.dgv@TableNameDetail.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(226)))), ((int)(((byte)(240)))), ((int)(((byte)(246)))));
1206             this.dgv@TableNameDetail.RowTemplate.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.Black;
1207             this.dgv@TableNameDetail.RowTemplate.Height = 18;
1208             this.dgv@TableNameDetail.Size = new System.Drawing.Size(827, 388);
1209             this.dgv@TableNameDetail.TabIndex = 12;
1210             this.dgv@TableNameDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
1211             @AddSubRange});
1212             // 
1213             // FRM_TA_BIZ_BoxDelivery
1214             // 
1215             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
1216             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
1217             this.ClientSize = new System.Drawing.Size(1184, 685);
1218             this.Name = "@ClassName";
1219             this.Text = "@ClassText";
1220             this.Load += new System.EventHandler(this.@ClassName_Load);
1221             this.tabPage1.ResumeLayout(false);
1222             this.tabPage1.PerformLayout();
1223             this.tabMain.ResumeLayout(false);
1224             this.tabPage2.ResumeLayout(false);
1225             this.tabPage2.PerformLayout();
1226             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).EndInit();
1227             ((System.ComponentModel.ISupportInitialize)(this.pictTitle2)).EndInit();
1228             this.myPanel1.ResumeLayout(false);
1229             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableName)).EndInit();
1230             this.myPanel2.ResumeLayout(false);
1231             this.myGroupBox1.ResumeLayout(false);
1232             this.myTabControl1.ResumeLayout(false);
1233             this.tabPage3.ResumeLayout(false);
1234             this.myGroupBox2.ResumeLayout(false);
1235             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableNameDetail)).EndInit();
1236             this.ResumeLayout(false);
1237             this.PerformLayout();
1238 
1239         }
1240 
1241         #endregion
1242 
1243         private WMS.Win.MyPanel myPanel1;
1244         private WMS.Win.MyPanel myPanel2;
1245         private WMS.Win.MyGroupBox myGroupBox2;
1246         private WMS.Win.MyGroupBox myGroupBox1;
1247         private WMS.Win.MyTabControl myTabControl1;
1248         private System.Windows.Forms.TabPage tabPage3;
1249         private WMS.Win.MyDataGridView dgv@TableNameDetail;
1250         private System.Windows.Forms.Panel panel1;
1251         private WMS.Win.MyDataGridView dgv@TableName;
1252         @DefineItem
1253     }
1254 }
1255 
1256 Template1_2
1257 ======================================================================
1258 using KYWMS.Util;
1259 using StyleForm.Win;
1260 using System;
1261 using System.Collections.Generic;
1262 using System.ComponentModel;
1263 using System.Data;
1264 using System.Drawing;
1265 using System.Linq;
1266 using System.Text;
1267 using System.Windows.Forms;
1268 using WMS.Common;
1269 using WMS.Win;
1270 
1271 namespace @Namespace
1272 {
1273     public partial class @ClassName : @ClassBase
1274     {
1275         #region 窗体级变量定义区域
1276         private string strWhereM = string.Empty;
1277 
1278         #endregion
1279 
1280         #region 窗体级事件区域
1281         public @ClassName()
1282         {
1283             InitializeComponent();
1284         }
1285 
1286         protected override void OnPreLoad(EventArgs e)
1287         {
1288             /*
1289             this.btnAddNew.CanReadOnly = false;
1290             this.btnAddNew.Visible = false;
1291             this.btnDelete.CanReadOnly = false;
1292             this.btnDelete.Visible = false;
1293             blnLock.CanReadOnly = false;
1294             blnLock.Visible = false;
1295             blnUnLock.CanReadOnly = false;
1296             blnUnLock.Visible = false;
1297             this.IniControlRight(this.btnQuery, "btnQuery", "通用查询");
1298             this.IniControlRight(this.btnRefresh, "btnRefresh", "刷新数据");
1299             this.IniControlRight(this.btnReport, "btnReport", "导出数据");
1300             this.IniControlRight(this.btnAddNew, "btnAddNew", "新增数据");
1301             this.IniControlRight(this.btnModify, "btnModify", "修改数据");
1302             this.IniControlRight(btnQueryQ, "btnQueryQ", "查询(Q)");
1303             this.IniControlRight(this.btnQueryS, "btnQueryS", "小查询");*/
1304             base.OnPreLoad(e);
1305         }
1306         private void @ClassName_Load(object sender, EventArgs e)
1307         {
1308             //labOrderNo.Text = "箱号";
1309             SetUserPopedomString();
1310             this.BindData();
1311             strWhereM = " 1=1 ";
1312             this.LoadDataMaster(strWhereM, strUserPopedom);
1313         }
1314 
1315         #endregion
1316 
1317         #region 函数及过程区域
1318         /// <summary>
1319         /// 权限设置
1320         /// </summary>
1321         private void SetUserPopedomString()
1322         {
1323 
1324         }
1325 
1326         /// <summary>
1327         /// 数据检查
1328         /// </summary>
1329         /// <param name="dataRow"></param>
1330         /// <returns></returns>
1331         private bool CheckData(DataRow dataRow)
1332         {
1333             return true;
1334         }
1335 
1336         #endregion
1337 
1338         #region 窗体按钮功能代码区域
1339         /// <summary>
1340         /// 查询
1341         /// </summary>
1342         /// <param name="sender"></param>
1343         /// <param name="e"></param>
1344         private void btnQueryQ_Click(object sender, EventArgs e)
1345         {
1346             /*
1347             try
1348             {
1349                 this.Cursor = Cursors.WaitCursor;
1350                 string strWh = txtOutWhQ.Text.Trim();
1351                 string strBoxNo = txtBoxNoQ.Text.Trim();
1352 
1353                 StringBuilder mSQL = new StringBuilder();
1354                 mSQL.Append(" 1 = 1 ");
1355                 if (!string.IsNullOrEmpty(strWh))
1356                 {
1357                     mSQL.AppendFormat("AND OutWh like N'{0}%'", strWh);
1358                 }
1359                 if (!string.IsNullOrEmpty(strBoxNo))
1360                 {
1361                     mSQL.AppendFormat("AND BoxNo like N'{0}%'", strBoxNo);
1362                 }
1363                 this.LoadDataMaster(mSQL.ToString(), strUserPopedom);
1364             }
1365             catch (Exception ex)
1366             {
1367                 MessageBox.Show(ex.Message);
1368             }
1369             finally
1370             {
1371                 this.Cursor = Cursors.Default;
1372             }
1373              */
1374         }
1375 
1376         #endregion
1377 
1378         #region 控件业务逻辑
1379         protected override bool OnWmsCommanding(object sender, CommandName commandName, params object[] commandArgs)
1380         {
1381             return base.OnWmsCommanding(sender, commandName, commandArgs);
1382         }
1383 
1384         protected override bool OnWmsCommand(object sender, CommandName commandName, params object[] commandArgs)
1385         {
1386             if (commandName == CommandName.FillComplete)
1387             {
1388 
1389             }
1390             return base.OnWmsCommand(sender, commandName, commandArgs);
1391         }
1392 
1393         protected override void OnWmsCommanded(object sender, CommandName commandName, params object[] commandArg)
1394         {
1395             if (commandName == CommandName.Save)
1396             {
1397 
1398             }
1399             base.OnWmsCommanded(sender, commandName, commandArg);
1400         }
1401 
1402         protected override bool OnWmsColumnChang(object sender, DataRow dataRow, DataColumn dataColumn, object proposedValue)
1403         {
1404 
1405             return base.OnWmsColumnChang(sender, dataRow, dataColumn, proposedValue);
1406         }
1407 
1408         protected override bool OnWmsDelete(object sender, DataRow dataRow)
1409         {
1410             return base.OnWmsDelete(sender, dataRow);
1411         }
1412 
1413         protected override bool OnWmsSave(object sender, DataRow dataRow)
1414         {
1415             try
1416             {
1417                 if (dataRow.RowState != DataRowState.Deleted && !CheckData(dataRow))
1418                 {
1419                     return false;
1420                 }
1421 
1422             }
1423             catch (Exception ex)
1424             {
1425                 MessageBoxShow(ex.Message);
1426                 return false;
1427             }
1428             return base.OnWmsSave(sender, dataRow);
1429         }
1430 
1431         protected override bool OnWmsNew(object sender, DataRow dataRow)
1432         {
1433             return base.OnWmsNew(sender, dataRow);
1434         }
1435 
1436         protected override bool OnWmsQuerys(object sender, string value)
1437         {
1438             //strWhereM = " BoxNo = N'" + value + "' ";
1439             //this.LoadDataMaster(strWhereM, strUserPopedom);
1440             return true;
1441         }
1442 
1443         protected override bool OnWmsExport(object sender)
1444         {
1445             ExcelUtil.ToExcel(AppDataSet.Tables[0], dgv@TableName);
1446             return base.OnWmsExport(sender);
1447         }
1448         #endregion
1449 
1450     }
1451 }
1452 
1453 
1454 Template1_2.Designer
1455 ======================================================================
1456 namespace @Namespace
1457 {
1458     partial class @ClassName
1459     {
1460         /// <summary>
1461         /// Required designer variable.
1462         /// </summary>
1463         private System.ComponentModel.IContainer components = null;
1464 
1465         /// <summary>
1466         /// Clean up any resources being used.
1467         /// </summary>
1468         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
1469         protected override void Dispose(bool disposing)
1470         {
1471             if (disposing && (components != null))
1472             {
1473                 components.Dispose();
1474             }
1475             base.Dispose(disposing);
1476         }
1477 
1478         #region Windows Form Designer generated code
1479 
1480         /// <summary>
1481         /// Required method for Designer support - do not modify
1482         /// the contents of this method with the code editor.
1483         /// </summary>
1484         private void InitializeComponent()
1485         {
1486             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(@ClassName));
1487             this.myPanel1 = new WMS.Win.MyPanel();
1488             this.dgv@TableName = new WMS.Win.MyDataGridView();
1489             @NewItem
1490             this.panel1 = new System.Windows.Forms.Panel();
1491             this.myPanel2 = new WMS.Win.MyPanel();
1492             this.myGroupBox1 = new WMS.Win.MyGroupBox();
1493             this.myTabControl1 = new WMS.Win.MyTabControl();
1494             this.tabPage3 = new System.Windows.Forms.TabPage();
1495             this.tabPage1.SuspendLayout();
1496             this.tabMain.SuspendLayout();
1497             this.tabPage2.SuspendLayout();
1498             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).BeginInit();
1499             ((System.ComponentModel.ISupportInitialize)(this.pictTitle2)).BeginInit();
1500             this.myPanel1.SuspendLayout();
1501             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableName)).BeginInit();
1502             this.myPanel2.SuspendLayout();
1503             this.myGroupBox1.SuspendLayout();
1504             this.myTabControl1.SuspendLayout();
1505             this.tabPage3.SuspendLayout();
1506             this.SuspendLayout();
1507             // 
1508             // groupLine
1509             // 
1510             this.groupLine.Location = new System.Drawing.Point(-3, 29);
1511             this.groupLine.Size = new System.Drawing.Size(1517, 2);
1512             // 
1513             // tabPage1
1514             // 
1515             this.tabPage1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(242)))));
1516             this.tabPage1.BackgroundImage = null;
1517             this.tabPage1.Controls.Add(this.myPanel1);
1518             this.tabPage1.Size = new System.Drawing.Size(1160, 615);
1519             this.tabPage1.UseVisualStyleBackColor = false;
1520             this.tabPage1.Controls.SetChildIndex(this.myPanel1, 0);
1521             this.tabPage1.Controls.SetChildIndex(this.pictTitle1, 0);
1522             this.tabPage1.Controls.SetChildIndex(this.lblTitle1, 0);
1523             // 
1524             // tabMain
1525             // 
1526             this.tabMain.Size = new System.Drawing.Size(1168, 641);
1527             // 
1528             // tabPage2
1529             // 
1530             this.tabPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(242)))));
1531             this.tabPage2.BackgroundImage = null;
1532             this.tabPage2.Controls.Add(this.myPanel2);
1533             this.tabPage2.Size = new System.Drawing.Size(1160, 615);
1534             this.tabPage2.UseVisualStyleBackColor = false;
1535             this.tabPage2.Controls.SetChildIndex(this.myPanel2, 0);
1536             this.tabPage2.Controls.SetChildIndex(this.pictTitle2, 0);
1537             this.tabPage2.Controls.SetChildIndex(this.lblTitle2, 0);
1538             // 
1539             // lblTitle1
1540             // 
1541             this.lblTitle1.Text = "@ClassText";
1542             // 
1543             // lblTitle2
1544             // 
1545             this.lblTitle2.Font = new System.Drawing.Font("隶书", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
1546             this.lblTitle2.Size = new System.Drawing.Size(98, 22);
1547             this.lblTitle2.Text = "@ClassText";
1548             // 
1549             // myPanel1
1550             // 
1551             this.myPanel1.BorderColor = System.Drawing.Color.White;
1552             this.myPanel1.Controls.Add(this.dgv@TableName);
1553             this.myPanel1.Controls.Add(this.panel1);
1554             this.myPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
1555             this.myPanel1.Location = new System.Drawing.Point(3, 3);
1556             this.myPanel1.MouseDownImage = null;
1557             this.myPanel1.MouseEnterImage = null;
1558             this.myPanel1.Name = "myPanel1";
1559             this.myPanel1.Size = new System.Drawing.Size(1154, 609);
1560             this.myPanel1.TabIndex = 6;
1561             this.myPanel1.TransparentColor = System.Drawing.Color.Transparent;
1562             // 
1563             // dgv@TableName
1564             // 
1565             this.dgv@TableName.AllowUserToAddRows = false;
1566             this.dgv@TableName.AllowUserToDeleteRows = false;
1567             this.dgv@TableName.AllowUserToOrderColumns = true;
1568             this.dgv@TableName.BackgroundColor = System.Drawing.Color.White;
1569             this.dgv@TableName.BindTableName = "@TableName";
1570             this.dgv@TableName.BorderStyle = System.Windows.Forms.BorderStyle.None;
1571             this.dgv@TableName.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
1572             this.dgv@TableName.ColumnHeadersHeight = 24;
1573             this.dgv@TableName.ColumnImageList = null;
1574             this.dgv@TableName.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
1575             @AddRange});
1576             this.dgv@TableName.DisplayRowNumber = true;
1577             this.dgv@TableName.Dock = System.Windows.Forms.DockStyle.Fill;
1578             this.dgv@TableName.EnableHeadersVisualStyles = false;
1579             this.dgv@TableName.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153)))));
1580             this.dgv@TableName.Location = new System.Drawing.Point(0, 80);
1581             this.dgv@TableName.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
1582             this.dgv@TableName.Name = "dgv@TableName";
1583             this.dgv@TableName.ReadOnly = true;
1584             this.dgv@TableName.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(226)))), ((int)(((byte)(240)))), ((int)(((byte)(246)))));
1585             this.dgv@TableName.RowTemplate.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.Black;
1586             this.dgv@TableName.RowTemplate.Height = 18;
1587             this.dgv@TableName.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
1588             this.dgv@TableName.Size = new System.Drawing.Size(1154, 529);
1589             this.dgv@TableName.TabIndex = 127;
1590             @AddItems
1591             // 
1592             // panel1
1593             // 
1594             this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
1595             this.panel1.Location = new System.Drawing.Point(0, 0);
1596             this.panel1.Name = "panel1";
1597             this.panel1.Size = new System.Drawing.Size(1154, 80);
1598             this.panel1.TabIndex = 128;
1599             // 
1600             // myPanel2
1601             // 
1602             this.myPanel2.BorderColor = System.Drawing.Color.White;
1603             this.myPanel2.Controls.Add(this.myGroupBox1);
1604             this.myPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
1605             this.myPanel2.Location = new System.Drawing.Point(3, 3);
1606             this.myPanel2.MouseDownImage = null;
1607             this.myPanel2.MouseEnterImage = null;
1608             this.myPanel2.Name = "myPanel2";
1609             this.myPanel2.Size = new System.Drawing.Size(1154, 609);
1610             this.myPanel2.TabIndex = 8;
1611             this.myPanel2.TransparentColor = System.Drawing.Color.Transparent;
1612             // 
1613             // myGroupBox1
1614             // 
1615             this.myGroupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
1616             | System.Windows.Forms.AnchorStyles.Left) 
1617             | System.Windows.Forms.AnchorStyles.Right)));
1618             this.myGroupBox1.Controls.Add(this.myTabControl1);
1619             this.myGroupBox1.Location = new System.Drawing.Point(5, 50);
1620             this.myGroupBox1.Name = "myGroupBox1";
1621             this.myGroupBox1.Size = new System.Drawing.Size(1144, 556);
1622             this.myGroupBox1.TabIndex = 9;
1623             this.myGroupBox1.TabStop = false;
1624             // 
1625             // myTabControl1
1626             // 
1627             this.myTabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
1628             | System.Windows.Forms.AnchorStyles.Left) 
1629             | System.Windows.Forms.AnchorStyles.Right)));
1630             this.myTabControl1.Controls.Add(this.tabPage3);
1631             this.myTabControl1.Location = new System.Drawing.Point(0, 134);
1632             this.myTabControl1.Name = "myTabControl1";
1633             this.myTabControl1.SelectedIndex = 0;
1634             this.myTabControl1.Size = new System.Drawing.Size(841, 420);
1635             this.myTabControl1.TabIndex = 25;
1636             // 
1637             // tabPage3
1638             // 
1639             this.tabPage3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(242)))));
1640             this.tabPage3.Location = new System.Drawing.Point(4, 22);
1641             this.tabPage3.Name = "tabPage3";
1642             this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
1643             this.tabPage3.Size = new System.Drawing.Size(833, 394);
1644             this.tabPage3.TabIndex = 0;
1645             this.tabPage3.Text = "@ClassText明细";
1646             // 
1647             // FRM_TA_BIZ_BoxDelivery
1648             // 
1649             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
1650             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
1651             this.ClientSize = new System.Drawing.Size(1184, 685);
1652             this.Name = "@ClassName";
1653             this.Text = "@ClassText";
1654             this.Load += new System.EventHandler(this.@ClassName_Load);
1655             this.tabPage1.ResumeLayout(false);
1656             this.tabPage1.PerformLayout();
1657             this.tabMain.ResumeLayout(false);
1658             this.tabPage2.ResumeLayout(false);
1659             this.tabPage2.PerformLayout();
1660             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).EndInit();
1661             ((System.ComponentModel.ISupportInitialize)(this.pictTitle2)).EndInit();
1662             this.myPanel1.ResumeLayout(false);
1663             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableName)).EndInit();
1664             this.myPanel2.ResumeLayout(false);
1665             this.myGroupBox1.ResumeLayout(false);
1666             this.myTabControl1.ResumeLayout(false);
1667             this.tabPage3.ResumeLayout(false);
1668             this.ResumeLayout(false);
1669             this.PerformLayout();
1670 
1671         }
1672 
1673         #endregion
1674 
1675         private WMS.Win.MyPanel myPanel1;
1676         private WMS.Win.MyPanel myPanel2;
1677         private WMS.Win.MyGroupBox myGroupBox1;
1678         private WMS.Win.MyTabControl myTabControl1;
1679         private System.Windows.Forms.TabPage tabPage3;
1680         private System.Windows.Forms.Panel panel1;
1681         private WMS.Win.MyDataGridView dgv@TableName;
1682         @DefineItem
1683     }
1684 }
1685 
1686 Template2
1687 ======================================================================
1688 1689 using KYWMS.Util;
1690 using StyleForm.Win;
1691 using System;
1692 using System.Collections.Generic;
1693 using System.ComponentModel;
1694 using System.Data;
1695 using System.Drawing;
1696 using System.Linq;
1697 using System.Text;
1698 using System.Threading;
1699 using System.Windows.Forms;
1700 using WMS.Common;
1701 using WMS.Win;
1702 
1703 namespace @Namespace
1704 {
1705     public partial class @ClassName : @ClassBase
1706     {
1707         #region    窗体级变量定义区
1708         private bool _Falg = false;
1709         #endregion
1710 
1711         #region 初始化
1712         public @ClassName()
1713         {
1714             InitializeComponent();
1715             Load += @ClassName_Load;
1716         }
1717 
1718         void @ClassName_Load(object sender, EventArgs e)
1719         {
1720             //FormUtil.hiddenShee2QueryBtn(this);
1721             btnRefresh.CanReadOnly = false;
1722             btnRefresh.Visible = true;
1723             this.BindData();
1724             this.LoadDataMaster("1=1", strUserPopedom);
1725         }
1726         #endregion
1727 
1728         #region 父类重写处理
1729         protected override void OnPreLoad(EventArgs e)
1730         {
1731             /*
1732             IniControlRight(btnQueryS, "btnQueryS", "查询");
1733             IniControlRight(btnReport, "btnReport", "导出");
1734             this.IniControlRight(this.btnQuery, "btnQuery", "通用查询");
1735             this.IniControlRight(this.btnRefresh, "btnRefresh", "刷新数据");
1736             this.IniControlRight(this.btnReport, "btnReport", "导出数据");
1737             this.IniControlRight(this.btnAddNew, "btnAddNew", "新增数据");
1738             this.IniControlRight(this.btnModify, "btnModify", "修改数据");
1739             this.IniControlRight(this.btnQueryS, "btnQueryS", "小查询");
1740             this.IniControlRight(this.btnDelete, "btnDelete", "删除");
1741             this.blnLock.CanReadOnly = false;
1742             this.blnLock.Visible = false;
1743             this.blnUnLock.CanReadOnly = false;
1744             this.blnUnLock.Visible = false;
1745              */
1746             
1747             //MyToolStripButton btnImport = new MyToolStripButton();
1748             //btnImport.Text = "导入";
1749             //btnImport.Image = Util.Properties.Resources.Report2;
1750             //btnImport.Click += new EventHandler(btnImport_Click);
1751             //btnImport.RightEnabled = true;
1752             //btnImport.RightName = "导入";
1753             //btnImport.RightCode = "btnImport";
1754             //toolMain.Items.Insert(24, btnImport);
1755 
1756             base.OnPreLoad(e);
1757         }
1758 
1759         private void btnImport_Click(object sender, EventArgs e)
1760         {
1761             ThreadPool.QueueUserWorkItem((obj) =>
1762             {
1763                 if (InvokeRequired && IsHandleCreated)
1764                 {
1765                     this.BeginInvoke(new Action<object>(delegate(object arg)
1766                     {
1767                         DoImport();
1768                     }), new object[0]);
1769                 }
1770             });
1771         }
1772 
1773         //导出
1774         protected override bool OnWmsExport(object sender)
1775         {
1776             ExcelUtil.ToExcel(AppDataSet.Tables[0], dgv@TableName);
1777             return true;
1778         }
1779         protected override bool OnWmsNew(object sender, DataRow dataRow)
1780         {
1781 
1782             return base.OnWmsNew(sender, dataRow);
1783         }
1784         protected override bool OnWmsSave(object sender, DataRow dataRow)
1785         {
1786             if (dataRow.RowState != DataRowState.Deleted && !Check(dataRow))
1787             {
1788                 return false;
1789             }
1790             if (dataRow.RowState == DataRowState.Modified)
1791             {
1792                 //dataRow["ModifiedBy"] = SessionAuth.UserName;
1793                 //dataRow["ModifiedOn"] = WinSrv.ServerDateTime;
1794             }
1795             return base.OnWmsSave(sender, dataRow);
1796         }
1797 
1798         private bool Check(DataRow dataRow)
1799         {
1800             /*
1801             if (!CheckItem("中文列名", dataRow["ColumnName"].ToString()))
1802                 return false;
1803             */
1804             return true;
1805         }
1806 
1807         private bool CheckItem(string name, string value)
1808         {
1809             if (string.IsNullOrEmpty(value))
1810             {
1811                 MessageBoxShow(string.Format("{0}不能为空,请录入", name));
1812                 return false;
1813             }
1814             return true;
1815         }
1816 
1817         protected override void OnWmsCommanded(object sender, WMS.Common.CommandName commandName, params object[] commandArg)
1818         {
1819             base.OnWmsCommanded(sender, commandName, commandArg);
1820             if (commandName == WMS.Common.CommandName.Save)
1821                 OnWmsCommand(btnRefresh, CommandName.Refresh, true);
1822         }
1823 
1824         /// <summary>
1825         /// 执行导入
1826         /// </summary>
1827         private void DoImport()
1828         {
1829         }
1830         #endregion
1831     }
1832 }
1833 
1834 
1835 Template2.Designer
1836 ======================================================================
1837 namespace @Namespace
1838 {
1839     partial class @ClassName
1840     {
1841         /// <summary>
1842         /// Required designer variable.
1843         /// </summary>
1844         private System.ComponentModel.IContainer components = null;
1845 
1846         /// <summary>
1847         /// Clean up any resources being used.
1848         /// </summary>
1849         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
1850         protected override void Dispose(bool disposing)
1851         {
1852             if (disposing && (components != null))
1853             {
1854                 components.Dispose();
1855             }
1856             base.Dispose(disposing);
1857         }
1858 
1859         #region Windows Form Designer generated code
1860 
1861         /// <summary>
1862         /// Required method for Designer support - do not modify
1863         /// the contents of this method with the code editor.
1864         /// </summary>
1865         private void InitializeComponent()
1866         {
1867             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
1868             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(@ClassName));
1869             this.groupBox1 = new System.Windows.Forms.GroupBox();
1870             this.dgv@TableName = new WMS.Win.MyDataGridView();
1871             @NewItem
1872             this.myLabel1 = new WMS.Win.MyLabel();
1873             this.panel1 = new System.Windows.Forms.Panel();
1874             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).BeginInit();
1875             this.groupBox1.SuspendLayout();
1876             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableName)).BeginInit();
1877             this.panel1.SuspendLayout();
1878             this.SuspendLayout();
1879             // 
1880             // pContainer
1881             // 
1882             this.pContainer.Size = new System.Drawing.Size(1076, 482);
1883             // 
1884             // groupLine
1885             // 
1886             this.groupLine.Location = new System.Drawing.Point(-3, 29);
1887             this.groupLine.Size = new System.Drawing.Size(1425, 2);
1888             // 
1889             // lblTitle1
1890             // 
1891             this.lblTitle1.Size = new System.Drawing.Size(153, 22);
1892             this.lblTitle1.Text = "@ClassText";
1893             // 
1894             // groupBox1
1895             // 
1896             this.groupBox1.Controls.Add(this.dgv@TableName);
1897             this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
1898             this.groupBox1.Location = new System.Drawing.Point(8, 139);
1899             this.groupBox1.Name = "groupBox1";
1900             this.groupBox1.Size = new System.Drawing.Size(1076, 402);
1901             this.groupBox1.TabIndex = 6;
1902             this.groupBox1.TabStop = false;
1903             // 
1904             // dgv@TableName
1905             // 
1906             this.dgv@TableName.AllowUserToAddRows = false;
1907             this.dgv@TableName.AllowUserToOrderColumns = true;
1908             this.dgv@TableName.BackgroundColor = System.Drawing.Color.White;
1909             this.dgv@TableName.BindTableName = "@TableName";
1910             this.dgv@TableName.BorderStyle = System.Windows.Forms.BorderStyle.None;
1911             this.dgv@TableName.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
1912             this.dgv@TableName.ColumnHeadersHeight = 24;
1913             this.dgv@TableName.ColumnImageList = null;
1914             this.dgv@TableName.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
1915             @AddRange});
1916             this.dgv@TableName.DisplayRowNumber = true;
1917             this.dgv@TableName.Dock = System.Windows.Forms.DockStyle.Fill;
1918             this.dgv@TableName.EnableHeadersVisualStyles = false;
1919             this.dgv@TableName.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153)))));
1920             this.dgv@TableName.Location = new System.Drawing.Point(3, 17);
1921             this.dgv@TableName.Name = "dgv@TableName";
1922             dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
1923             dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
1924             dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134)));
1925             dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
1926             dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
1927             dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
1928             this.dgv@TableName.RowHeadersDefaultCellStyle = dataGridViewCellStyle1;
1929             this.dgv@TableName.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(226)))), ((int)(((byte)(240)))), ((int)(((byte)(246)))));
1930             this.dgv@TableName.RowTemplate.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.Black;
1931             this.dgv@TableName.RowTemplate.Height = 18;
1932             this.dgv@TableName.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
1933             this.dgv@TableName.Size = new System.Drawing.Size(1070, 382);
1934             this.dgv@TableName.TabIndex = 23;
1935             @AddItems
1936             // 
1937             // myLabel1
1938             // 
1939             this.myLabel1.AutoSize = true;
1940             this.myLabel1.BackColor = System.Drawing.Color.Transparent;
1941             this.myLabel1.CanReadOnly = false;
1942             this.myLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
1943             this.myLabel1.Location = new System.Drawing.Point(228, 24);
1944             this.myLabel1.Name = "myLabel1";
1945             this.myLabel1.Size = new System.Drawing.Size(155, 36);
1946             this.myLabel1.TabIndex = 8;
1947             this.myLabel1.Text = "①备注信息…………";
1948             // 
1949             // panel1
1950             // 
1951             this.panel1.Controls.Add(this.myLabel1);
1952             this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
1953             this.panel1.Location = new System.Drawing.Point(8, 59);
1954             this.panel1.Name = "panel1";
1955             this.panel1.Size = new System.Drawing.Size(1076, 80);
1956             this.panel1.TabIndex = 9;
1957             // 
1958             // @ClassName
1959             // 
1960             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
1961             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
1962             this.ClientSize = new System.Drawing.Size(1092, 549);
1963             this.Controls.Add(this.groupBox1);
1964             this.Controls.Add(this.panel1);
1965             this.Name = "@ClassName";
1966             this.Text = "@ClassText";
1967             this.Controls.SetChildIndex(this.pContainer, 0);
1968             this.Controls.SetChildIndex(this.groupLine, 0);
1969             this.Controls.SetChildIndex(this.panel1, 0);
1970             this.Controls.SetChildIndex(this.groupBox1, 0);
1971             this.Controls.SetChildIndex(this.pictTitle1, 0);
1972             this.Controls.SetChildIndex(this.lblTitle1, 0);
1973             ((System.ComponentModel.ISupportInitialize)(this.pictTitle1)).EndInit();
1974             this.groupBox1.ResumeLayout(false);
1975             ((System.ComponentModel.ISupportInitialize)(this.dgv@TableName)).EndInit();
1976             this.panel1.ResumeLayout(false);
1977             this.panel1.PerformLayout();
1978             this.ResumeLayout(false);
1979             this.PerformLayout();
1980 
1981         }
1982 
1983         #endregion
1984 
1985         private System.Windows.Forms.GroupBox groupBox1;
1986         private WMS.Win.MyDataGridView dgv@TableName;
1987         private WMS.Win.MyLabel myLabel1;        
1988         private System.Windows.Forms.Panel panel1;
1989         @DefineItem
1990 
1991     }
1992 }
View Code

界面:

 

posted @ 2016-10-13 19:48  遊龍  阅读(449)  评论(0编辑  收藏  举报