📄 codemakerm.cs
字号:
namespace Codematic
{
using Codematic.UserControls;
using LTP.BuilderWeb;
using LTP.CmConfig;
using LTP.CodeBuild;
using LTP.CodeHelper;
using LTP.IDBO;
using LTP.Utility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows.Forms;
public class CodeMakerM : Form
{
private Button btn_Next;
private Button btn_Ok;
private Button btn_SelAll;
private Button btn_SelAll2;
private Button btn_SelI;
private Button btn_SelI2;
private CheckBox chk_CS_Add;
private CheckBox chk_CS_Delete;
private CheckBox chk_CS_Exists;
private CheckBox chk_CS_GetList;
private CheckBox chk_CS_GetModel;
private CheckBox chk_CS_GetModelByCache;
private CheckBox chk_CS_Update;
private CheckBox chk_DB_Add;
private CheckBox chk_DB_Delete;
private CheckBox chk_DB_Exists;
private CheckBox chk_DB_GetList;
private CheckBox chk_DB_GetMaxID;
private CheckBox chk_DB_GetModel;
private CheckBox chk_DB_Update;
private CheckBox chk_Web_Add;
private CheckBox chk_Web_HasKey;
private CheckBox chk_Web_Show;
private CheckBox chk_Web_Update;
private DALTypeAddIn cm_blltype;
private DALTypeAddIn cm_daltype;
private ComboBox cmbox_PField;
private ComboBox cmbox_PTab;
private ComboBox cmbox_SField;
private ComboBox cmbox_STab;
private UcCodeView codeview;
private IContainer components;
private string dbname;
private IDbObject dbobj;
private GroupBox groupBox_AppType;
private GroupBox groupBox_DALType;
private GroupBox groupBox_DB;
private GroupBox groupBox_F3;
private GroupBox groupBox_FrameSel;
private GroupBox groupBox_Method;
private GroupBox groupBox_Parameter;
private GroupBox groupBox_Type;
private GroupBox groupBox_Web;
private GroupBox groupBox1;
private ImageList imglistDB;
private ImageList imgListTabpage;
private ImageList imglistView;
private Label label1;
private Label label10;
private Label label11;
private Label label12;
private Label label13;
private Label label14;
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private Label label6;
private Label label7;
private Label label8;
private Label label9;
private ListView listView1;
private ListView listView2;
private NameRule namerule = new NameRule();
private Panel panel1;
private Panel panel2;
private RadioButton radbtn_AppType_Web;
private RadioButton radbtn_AppType_Winform;
private RadioButton radbtn_DB_DDL;
private RadioButton radbtn_DB_Proc;
private RadioButton radbtn_F3_BLL;
private RadioButton radbtn_F3_DAL;
private RadioButton radbtn_F3_DALFactory;
private RadioButton radbtn_F3_IDAL;
private RadioButton radbtn_F3_Model;
private RadioButton radbtn_Frame_F3;
private RadioButton radbtn_Frame_One;
private RadioButton radbtn_Frame_S3;
private RadioButton radbtn_Type_CS;
private RadioButton radbtn_Type_DB;
private RadioButton radbtn_Type_Web;
private RadioButton radbtn_Web_Aspx;
private RadioButton radbtn_Web_AspxCS;
private string servername;
private ModuleSettings setting;
private TabControl tabControl1;
private string tablename;
private TabPage tabPage1;
private TabPage tabPage2;
private TabPage tabPage3;
private Thread thread;
private ToolStripButton toolStripButton2;
private ToolStripSeparator toolStripSeparator1;
private ToolStripSplitButton toolStripSplitButton1;
private TextBox txtClassName;
private TextBox txtClassName2;
private TextBox txtNameSpace;
private TextBox txtNameSpace2;
private TextBox txtProcPrefix;
private TextBox txtProjectName;
private TextBox txtTabname;
private ToolStripMenuItem 列表ToolStripMenuItem;
private ToolStripMenuItem 详细信息ToolStripMenuItem;
public CodeMakerM(string Dbname)
{
this.InitializeComponent();
this.dbname = Dbname;
this.codeview = new UcCodeView();
this.tabPage2.Controls.Add(this.codeview);
this.SetListViewMenu("colum");
this.CreatView();
this.SetFormConfig();
if (((DbView) Application.OpenForms["DbView"]) != null)
{
try
{
this.thread = new Thread(new ThreadStart(this.Showlistview));
this.thread.Start();
}
catch
{
}
}
}
private void BindlistViewCol1(string Dbname, string TableName)
{
List<LTP.CodeHelper.ColumnInfo> columnInfoList = this.dbobj.GetColumnInfoList(Dbname, TableName);
if ((columnInfoList != null) && (columnInfoList.Count > 0))
{
this.listView1.Items.Clear();
this.cmbox_PField.Items.Clear();
foreach (LTP.CodeHelper.ColumnInfo info in columnInfoList)
{
string colorder = info.Colorder;
string columnName = info.ColumnName;
string typeName = info.TypeName;
this.cmbox_PField.Items.Add(columnName);
ListViewItem item = new ListViewItem(colorder, 0);
item.Checked = true;
item.ImageIndex = -1;
item.SubItems.Add(columnName);
item.SubItems.Add(typeName);
this.listView1.Items.AddRange(new ListViewItem[] { item });
}
if (this.cmbox_PField.Items.Count > 0)
{
this.cmbox_PField.SelectedIndex = 0;
}
}
this.txtTabname.Text = TableName;
this.txtClassName.Text = TableName;
}
private void BindlistViewCol2(string Dbname, string TableName)
{
List<LTP.CodeHelper.ColumnInfo> columnInfoList = this.dbobj.GetColumnInfoList(Dbname, TableName);
if ((columnInfoList != null) && (columnInfoList.Count > 0))
{
this.listView2.Items.Clear();
this.cmbox_SField.Items.Clear();
foreach (LTP.CodeHelper.ColumnInfo info in columnInfoList)
{
string colorder = info.Colorder;
string columnName = info.ColumnName;
string typeName = info.TypeName;
this.cmbox_SField.Items.Add(columnName);
ListViewItem item = new ListViewItem(colorder, 0);
item.Checked = true;
item.ImageIndex = -1;
item.SubItems.Add(columnName);
item.SubItems.Add(typeName);
this.listView2.Items.AddRange(new ListViewItem[] { item });
}
if (this.cmbox_SField.Items.Count > 0)
{
this.cmbox_SField.SelectedIndex = 0;
}
}
this.txtTabname.Text = TableName;
this.txtClassName2.Text = TableName;
}
private void BindTablist(string Dbname)
{
List<TableInfo> tablesInfo = this.dbobj.GetTablesInfo(Dbname);
if ((tablesInfo != null) && (tablesInfo.Count > 0))
{
foreach (TableInfo info in tablesInfo)
{
string tabName = info.TabName;
this.cmbox_PTab.Items.Add(tabName);
this.cmbox_STab.Items.Add(tabName);
}
}
}
private void btn_Next_Click(object sender, EventArgs e)
{
this.tabControl1.SelectedIndex = 1;
}
private void btn_Ok_Click(object sender, EventArgs e)
{
if (this.listView1.CheckedItems.Count < 1)
{
MessageBox.Show("没有任何可以生成的项!", "请选择", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else
{
try
{
if (this.radbtn_Type_DB.Checked)
{
this.CreatDB();
}
if (this.radbtn_Type_CS.Checked)
{
this.CreatCS();
}
if (this.radbtn_Type_Web.Checked)
{
this.CreatWeb();
}
}
catch
{
MessageBox.Show("代码生成失败,请关闭后重新打开再试。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
if (this.radbtn_Frame_One.Checked)
{
this.setting.AppFrame = "One";
}
if (this.radbtn_Frame_S3.Checked)
{
this.setting.AppFrame = "S3";
}
if (this.radbtn_Frame_F3.Checked)
{
this.setting.AppFrame = "F3";
}
this.setting.DALType = this.GetDALType();
this.setting.BLLType = this.GetBLLType();
this.setting.ProjectName = this.txtProjectName.Text;
this.setting.Namepace = this.txtNameSpace.Text;
this.setting.Folder = this.txtNameSpace2.Text;
this.setting.ProcPrefix = this.txtProcPrefix.Text;
ModuleConfig.SaveSettings(this.setting);
}
}
private void btn_SelAll_Click(object sender, EventArgs e)
{
foreach (ListViewItem item in this.listView1.Items)
{
if (!item.Checked)
{
item.Checked = true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -