📄 codemaker.cs
字号:
{
this.CreatDBScript();
}
}
private void CreatDBProc()
{
string text = this.txtProjectName.Text;
string text1 = this.txtNameSpace.Text;
string text2 = this.txtNameSpace2.Text;
string text3 = this.txtClassName.Text;
string str2 = this.txtProcPrefix.Text;
string str3 = this.txtTabname.Text;
bool maxid = this.chk_DB_GetMaxID.Checked;
bool ishas = this.chk_DB_Exists.Checked;
bool add = this.chk_DB_Add.Checked;
bool update = this.chk_DB_Update.Checked;
bool delete = this.chk_DB_Delete.Checked;
bool getModel = this.chk_DB_GetModel.Checked;
bool list = this.chk_DB_GetList.Checked;
IDbScriptBuilder builder = ObjHelper.CreatDsb(this.servername);
builder.DbName = this.dbname;
builder.TableName = str3;
builder.ProjectName = text;
builder.ProcPrefix = str2;
builder.Keys = this.GetKeyFields();
builder.Fieldlist = this.GetFieldlist();
string strContent = builder.GetPROCCode(maxid, ishas, add, update, delete, getModel, list);
this.SettxtContent("SQL", strContent);
}
private void CreatDBScript()
{
this.Cursor = Cursors.WaitCursor;
IDbScriptBuilder builder = ObjHelper.CreatDsb(this.servername);
builder.Fieldlist = this.GetFieldlist();
string strContent = builder.CreateTabScript(this.dbname, this.tablename);
this.SettxtContent("SQL", strContent);
this.Cursor = Cursors.Default;
}
private void CreatView()
{
this.listView1.Columns.Clear();
this.listView1.Items.Clear();
this.listView1.LargeImageList = this.imglistView;
this.listView1.SmallImageList = this.imglistView;
this.listView1.View = View.Details;
this.listView1.GridLines = true;
this.listView1.CheckBoxes = true;
this.listView1.FullRowSelect = true;
this.listView1.Columns.Add("序号", 60, HorizontalAlignment.Center);
this.listView1.Columns.Add("列名", 110, HorizontalAlignment.Left);
this.listView1.Columns.Add("数据类型", 80, HorizontalAlignment.Left);
this.listView1.Columns.Add("长度", 40, HorizontalAlignment.Left);
this.listView1.Columns.Add("小数", 40, HorizontalAlignment.Left);
this.listView1.Columns.Add("标识", 40, HorizontalAlignment.Center);
this.listView1.Columns.Add("主键", 40, HorizontalAlignment.Center);
this.listView1.Columns.Add("允许空", 60, HorizontalAlignment.Center);
this.listView1.Columns.Add("默认值", 100, HorizontalAlignment.Left);
}
private void CreatWeb()
{
string str = this.txtNameSpace.Text.Trim();
string str2 = this.txtNameSpace2.Text.Trim();
string text = this.txtClassName.Text;
if (text == "")
{
text = this.tablename;
}
string tabName = text;
text = this.namerule.GetModelClass(text);
tabName = this.namerule.GetBLLClass(tabName);
LTP.BuilderWeb.BuilderWeb web = new LTP.BuilderWeb.BuilderWeb();
web.NameSpace = str;
web.Fieldlist = this.GetFieldlist();
web.Keys = this.GetKeyFields();
web.ModelName = text;
web.BLLName = tabName;
web.Folder = str2;
if (this.radbtn_Web_Aspx.Checked)
{
string strContent = web.GetWebHtmlCode(this.chk_Web_HasKey.Checked, this.chk_Web_Add.Checked, this.chk_Web_Update.Checked, this.chk_Web_Show.Checked, true);
this.SettxtContent("Aspx", strContent);
}
else
{
string str6 = web.GetWebCode(this.chk_Web_HasKey.Checked, this.chk_Web_Add.Checked, this.chk_Web_Update.Checked, this.chk_Web_Show.Checked, true);
this.SettxtContent("CS", str6);
}
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private string GetBLLType()
{
string appGuid = "";
appGuid = this.cm_blltype.AppGuid;
if ((appGuid == "") && (appGuid == "System.Data.DataRowView"))
{
MessageBox.Show("选择的数据层类型有误,请关闭后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return "";
}
return appGuid;
}
private string GetDALType()
{
string appGuid = "";
appGuid = this.cm_daltype.AppGuid;
if ((appGuid == "") && (appGuid == "System.Data.DataRowView"))
{
MessageBox.Show("选择的数据层类型有误,请关闭后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return "";
}
return appGuid;
}
private List<LTP.CodeHelper.ColumnInfo> GetFieldlist()
{
List<LTP.CodeHelper.ColumnInfo> columnInfoList = this.dbobj.GetColumnInfoList(this.dbname, this.tablename);
List<LTP.CodeHelper.ColumnInfo> list2 = new List<LTP.CodeHelper.ColumnInfo>();
foreach (LTP.CodeHelper.ColumnInfo info in columnInfoList)
{
foreach (ListViewItem item in this.listView1.Items)
{
if (info.ColumnName == item.SubItems[1].Text)
{
if (item.Checked)
{
list2.Add(info);
}
break;
}
}
}
return list2;
}
private List<LTP.CodeHelper.ColumnInfo> GetKeyFields()
{
DataRow[] rowArray;
DataTable columnInfoDt = CodeCommon.GetColumnInfoDt(this.dbobj.GetColumnInfoList(this.dbname, this.tablename));
StringPlus plus = new StringPlus();
foreach (object obj2 in this.list_KeyField.Items)
{
plus.Append("'" + obj2.ToString() + "',");
}
plus.DelLastComma();
if (columnInfoDt == null)
{
return null;
}
if (plus.Value.Length > 0)
{
rowArray = columnInfoDt.Select("ColumnName in (" + plus.Value + ")", "colorder asc");
}
else
{
rowArray = columnInfoDt.Select();
}
List<LTP.CodeHelper.ColumnInfo> list2 = new List<LTP.CodeHelper.ColumnInfo>();
foreach (DataRow row in rowArray)
{
string str = row["Colorder"].ToString();
string str2 = row["ColumnName"].ToString();
string str3 = row["TypeName"].ToString();
string str4 = row["IsIdentity"].ToString();
string str5 = row["IsPK"].ToString();
string str6 = row["Length"].ToString();
string str7 = row["Preci"].ToString();
string str8 = row["Scale"].ToString();
string str9 = row["cisNull"].ToString();
string str10 = row["DefaultVal"].ToString();
string str11 = row["DeText"].ToString();
LTP.CodeHelper.ColumnInfo item = new LTP.CodeHelper.ColumnInfo();
item.Colorder = str;
item.ColumnName = str2;
item.TypeName = str3;
item.IsIdentity = str4 == "√";
item.IsPK = str5 == "√";
item.Length = str6;
item.Preci = str7;
item.Scale = str8;
item.cisNull = str9 == "√";
item.DefaultVal = str10;
item.DeText = str11;
list2.Add(item);
}
return list2;
}
private void InitializeComponent()
{
this.components = new Container();
ComponentResourceManager manager = new ComponentResourceManager(typeof(CodeMaker));
this.tabControl1 = new TabControl();
this.tabPage1 = new TabPage();
this.panel2 = new Panel();
this.btn_Ok = new Button();
this.groupBox_Web = new GroupBox();
this.chk_Web_Show = new CheckBox();
this.chk_Web_Update = new CheckBox();
this.chk_Web_HasKey = new CheckBox();
this.chk_Web_Add = new CheckBox();
this.radbtn_Web_AspxCS = new RadioButton();
this.radbtn_Web_Aspx = new RadioButton();
this.groupBox_AppType = new GroupBox();
this.radbtn_AppType_Winform = new RadioButton();
this.radbtn_AppType_Web = new RadioButton();
this.groupBox_Method = new GroupBox();
this.chk_CS_GetList = new CheckBox();
this.chk_CS_GetModel = new CheckBox();
this.chk_CS_Delete = new CheckBox();
this.chk_CS_Update = new CheckBox();
this.chk_CS_Add = new CheckBox();
this.chk_CS_Exists = new CheckBox();
this.chk_CS_GetMaxID = new CheckBox();
this.groupBox_DALType = new GroupBox();
this.groupBox_F3 = new GroupBox();
this.radbtn_F3_BLL = new RadioButton();
this.radbtn_F3_DALFactory = new RadioButton();
this.radbtn_F3_IDAL = new RadioButton();
this.radbtn_F3_DAL = new RadioButton();
this.radbtn_F3_Model = new RadioButton();
this.groupBox_FrameSel = new GroupBox();
this.radbtn_Frame_F3 = new RadioButton();
this.radbtn_Frame_S3 = new RadioButton();
this.radbtn_Frame_One = new RadioButton();
this.groupBox_DB = new GroupBox();
this.chk_DB_GetList = new CheckBox();
this.chk_DB_GetModel = new CheckBox();
this.chk_DB_Delete = new CheckBox();
this.chk_DB_Update = new CheckBox();
this.chk_DB_Add = new CheckBox();
this.chk_DB_Exists = new CheckBox();
this.chk_DB_GetMaxID = new CheckBox();
this.txtTabname = new TextBox();
this.txtProcPrefix = new TextBox();
this.lblkeycount = new Label();
this.label6 = new Label();
this.label7 = new Label();
this.label5 = new Label();
this.radbtn_DB_DDL = new RadioButton();
this.radbtn_DB_Proc = new RadioButton();
this.groupBox_Type = new GroupBox();
this.radbtn_Type_Web = new RadioButton();
this.radbtn_Type_CS = new RadioButton();
this.radbtn_Type_DB = new RadioButton();
this.groupBox_Parameter = new GroupBox();
this.txtClassName = new TextBox();
this.txtNameSpace2 = new TextBox();
this.txtNameSpace = new TextBox();
this.txtProjectName = new TextBox();
this.label3 = new Label();
this.label4 = new Label();
this.label2 = new Label();
this.label1 = new Label();
this.groupBox_Select = new GroupBox();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -