public string GetAddDesigner() { StringPlus stringPlus = new StringPlus(); stringPlus.AppendLine(); foreach (ColumnInfo current in this.Fieldlist) { string columnName = current.ColumnName; string typeName = current.TypeName; string arg_3B_0 = current.Description; bool arg_42_0 = current.IsPrimaryKey; if (!current.IsIdentity && !this.isFilterColume(columnName) && !("uniqueidentifier" == typeName.ToLower())) { string a; if ((a = CodeCommon.DbTypeToCS(typeName.Trim().ToLower()).ToLower()) != null) { if (a == "datetime" || a == "smalldatetime") { stringPlus.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";"); continue; } if (a == "bool") { stringPlus.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.CheckBox chk" + columnName + ";"); continue; } } stringPlus.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";"); } } stringPlus.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnSave;"); stringPlus.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnCancel;"); return(stringPlus.ToString()); }
/// <summary> /// 得到最大ID的方法代码 /// </summary> /// <param name="TabName"></param> /// <param name="ID"></param> /// <returns></returns> public string CreatGetMaxID() { StringPlus strclass = new StringPlus(); if (_keys.Count > 0) { string keyname = ""; foreach (ColumnInfo obj in _keys) { if (CodeCommon.DbTypeToCS(obj.TypeName) == "int") { keyname = obj.ColumnName; if (obj.IsPK) { strclass.AppendLine(""); strclass.AppendSpaceLine(2, "/// <summary>"); strclass.AppendSpaceLine(2, "/// 得到最大ID"); strclass.AppendSpaceLine(2, "/// </summary>"); strclass.AppendSpaceLine(2, "public int GetMaxId()"); strclass.AppendSpaceLine(2, "{"); strclass.AppendSpaceLine(2, "return " + DbHelperName + ".GetMaxID(\"" + keyname + "\", \"" + _tablename + "\"); "); strclass.AppendSpaceLine(2, "}"); break; } } } } return(strclass.ToString()); }
public BuilderDAL(IDbObject idbobj, string dbname, string tablename, string modelname, string dalName, List <ColumnInfo> fieldlist, List <ColumnInfo> keys, string namepace, string folder, string dbherlpername, string modelpath, string dalpath, string idalpath, string iclass) { this.dbobj = idbobj; this._dbname = dbname; this._tablename = tablename; this._modelname = modelname; this._dalname = dalName; this._namespace = namepace; this._folder = folder; this._dbhelperName = dbherlpername; this._modelpath = modelpath; this._dalpath = dalpath; this._idalpath = idalpath; this._iclass = iclass; this.Fieldlist = fieldlist; this.Keys = keys; foreach (ColumnInfo current in this._keys) { this._key = current.ColumnName; this._keyType = current.TypeName; if (current.IsIdentity) { this._key = current.ColumnName; this._keyType = CodeCommon.DbTypeToCS(current.TypeName); break; } } }
public string CreatGetMaxID() { StringPlus stringPlus = new StringPlus(); if (this._keys.Count > 0) { foreach (ColumnInfo current in this._keys) { if (CodeCommon.DbTypeToCS(current.TypeName) == "int") { string arg_50_0 = current.ColumnName; if (current.IsPrimaryKey) { stringPlus.AppendLine(""); stringPlus.AppendSpaceLine(2, "/// <summary>"); stringPlus.AppendSpaceLine(2, "/// " + this.Languagelist["summaryGetMaxId"].ToString()); stringPlus.AppendSpaceLine(2, "/// </summary>"); stringPlus.AppendSpaceLine(2, "public int GetMaxID()"); stringPlus.AppendSpaceLine(2, "{"); stringPlus.AppendSpaceLine(2, "return ExecuteGetMaxID(\"GetMaxID\"); "); stringPlus.AppendSpaceLine(2, "}"); break; } } } } return(stringPlus.ToString()); }
/// <summary> /// 显示窗体的html代码 /// </summary> public string GetShowDesigner() { StringPlus strclass = new StringPlus(); foreach (ColumnInfo field in Fieldlist) { string columnName = field.ColumnName; string columnType = field.TypeName; string deText = field.DeText; if (deText.Trim() == "") { deText = columnName; } switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower()) { case "bool": strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.CheckBox chk" + columnName + ";"); break; default: strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Label lbl" + columnName + ";"); break; } } return(strclass.ToString()); }
public BuilderFrameF3(IDbObject idbobj, string dbName, string tableName, string tableDescription, string modelName, string bllName, string dalName, List <ColumnInfo> fieldlist, List <ColumnInfo> keys, string nameSpace, string folder, string dbHelperName) { this.dbobj = idbobj; this._dbtype = idbobj.DbType; base.DbName = dbName; base.TableName = tableName; base.TableDescription = tableDescription; base.ModelName = modelName; base.BLLName = bllName; base.DALName = dalName; base.NameSpace = nameSpace; base.DbHelperName = dbHelperName; base.Folder = folder; base.Fieldlist = fieldlist; base.Keys = keys; foreach (ColumnInfo current in keys) { this._key = current.ColumnName; this._keyType = current.TypeName; if (current.IsIdentity) { this._key = current.ColumnName; this._keyType = CodeCommon.DbTypeToCS(current.TypeName); break; } } }
/// <summary> /// 得到最大ID的方法代码 /// </summary> /// <param name="TabName"></param> /// <param name="ID"></param> /// <returns></returns> public string CreatGetMaxID() { StringPlus strclass = new StringPlus(); if (_keys.Count > 0) { string keyname = ""; foreach (ColumnInfo obj in _keys) { if (CodeCommon.DbTypeToCS(obj.TypeName) == "int") { keyname = obj.ColumnName; if (obj.IsPrimaryKey) { strclass.AppendLine(""); strclass.AppendSpaceLine(2, "/// <summary>"); strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryGetMaxId"].ToString()); strclass.AppendSpaceLine(2, "/// </summary>"); strclass.AppendSpaceLine(2, "public int GetMaxID()"); strclass.AppendSpaceLine(2, "{"); strclass.AppendSpaceLine(2, "return ExecuteGetMaxID(\"GetMaxID\"); "); strclass.AppendSpaceLine(2, "}"); break; } } } } return(strclass.ToString()); }
public BuilderDAL(IDbObject idbobj, string dbname, string tablename, string modelname, string dalName, List <ColumnInfo> fieldlist, List <ColumnInfo> keys, string namepace, string folder, string dbherlpername, string modelpath, string dalpath, string idalpath, string iclass) { dbobj = idbobj; _dbname = dbname; _tablename = tablename; _modelname = modelname; _dalname = dalName; _namespace = namepace; _folder = folder; _dbhelperName = dbherlpername; _modelpath = modelpath; _dalpath = dalpath; _idalpath = idalpath; _iclass = iclass; Fieldlist = fieldlist; Keys = keys; foreach (ColumnInfo key in _keys) { _key = key.ColumnName; _keyType = key.TypeName; if (key.IsIdentity) { _key = key.ColumnName; _keyType = CodeCommon.DbTypeToCS(key.TypeName); break; } } }
public string CreatBLLGetMaxSortNo() { StringPlus strclass = new StringPlus(); if (_keys.Count > 0) { string keyname = ""; foreach (ColumnInfo obj in _keys) { if (CodeCommon.DbTypeToCS(obj.TypeName) == "int") { keyname = obj.ColumnName; if (obj.IsPrimaryKey) { strclass.AppendLine(""); strclass.AppendSpaceLine(2, "/// <summary>"); strclass.AppendSpaceLine(2, "/// 获取最大的排序号"); strclass.AppendSpaceLine(2, "/// </summary>"); strclass.AppendSpaceLine(2, "public int GetMaxSortNo()"); strclass.AppendSpaceLine(2, "{"); strclass.AppendSpaceLine(3, "return dal.GetMaxSortNo();"); strclass.AppendSpaceLine(2, "}"); break; } } } } return(strclass.ToString()); }
public string Model() { string strResult = string.Empty; StringBuilder strb = new StringBuilder(); DataTable dt = GetProperty.DataTable; foreach (DataRow dr in dt.Rows) { ColumnInfo cols = GetColumnInfo(dr); strb.Append(SummaryCode(cols.Remark)); strb.AppendLine("public " + CodeCommon.DbTypeToCS(cols.ColumnType) + " " + VarModel(cols.ColumnName) + "{get;set;}"); } strResult = GetProperty.ModuleCode; if (!string.IsNullOrEmpty(strResult)) { strResult = strResult.Replace("$Model$", strb.ToString()); } else { strResult = strb.ToString(); } return(strResult); }
private XmlDocument GetXml2() { string filename = "Template\\temp.xml"; XmlTextWriter xmlTextWriter = new XmlTextWriter(filename, Encoding.UTF8); xmlTextWriter.Formatting = Formatting.Indented; xmlTextWriter.WriteStartDocument(true); xmlTextWriter.WriteStartElement("Schema"); xmlTextWriter.WriteStartElement("TableName"); xmlTextWriter.WriteAttributeString("value", this.TableName); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteStartElement("FIELDS"); foreach (ColumnInfo current in this.Fieldlist) { string columnName = current.ColumnName; string typeName = current.TypeName; string arg_87_0 = current.Length; bool arg_8E_0 = current.IsIdentity; bool arg_95_0 = current.IsPrimaryKey; string description = current.Description; string defaultVal = current.DefaultVal; xmlTextWriter.WriteStartElement("FIELD"); xmlTextWriter.WriteAttributeString("Name", columnName); xmlTextWriter.WriteAttributeString("Type", CodeCommon.DbTypeToCS(typeName)); xmlTextWriter.WriteAttributeString("Desc", description); xmlTextWriter.WriteAttributeString("defaultVal", defaultVal); xmlTextWriter.WriteEndElement(); } xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteStartElement("PrimaryKeys"); foreach (ColumnInfo current2 in this.Keys) { string columnName2 = current2.ColumnName; string typeName2 = current2.TypeName; string arg_150_0 = current2.Length; bool arg_158_0 = current2.IsIdentity; bool arg_160_0 = current2.IsPrimaryKey; string description2 = current2.Description; string defaultVal2 = current2.DefaultVal; xmlTextWriter.WriteStartElement("FIELD"); xmlTextWriter.WriteAttributeString("Name", columnName2); xmlTextWriter.WriteAttributeString("Type", CodeCommon.DbTypeToCS(typeName2)); xmlTextWriter.WriteAttributeString("Desc", description2); xmlTextWriter.WriteAttributeString("defaultVal", defaultVal2); xmlTextWriter.WriteEndElement(); } xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndElement(); xmlTextWriter.Flush(); xmlTextWriter.Close(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(filename); return(xmlDocument); }
/// <summary> /// 得到表示层显示窗体的代码 /// </summary> public string GetShowAspxCs() { StringPlus strclass = new StringPlus(); strclass.AppendLine(); string key = Key; strclass.AppendSpaceLine(1, "private void ShowInfo(" + LTP.CodeHelper.CodeCommon.GetInParameter(Keys) + ")"); strclass.AppendSpaceLine(1, "{"); strclass.AppendSpaceLine(2, BLLSpace + " bll=new " + BLLSpace + "();"); strclass.AppendSpaceLine(2, ModelSpace + " model=bll.GetModel(" + LTP.CodeHelper.CodeCommon.GetFieldstrlist(Keys) + ");"); foreach (ColumnInfo field in Fieldlist) { string columnName = field.ColumnName; string columnType = field.TypeName; string deText = field.DeText; bool ispk = field.IsPK; bool IsIdentity = field.IsIdentity; if ((ispk) || (IsIdentity)) { continue; } switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower()) { case "int": case "smallint": case "float": case "numeric": case "decimal": case "datetime": case "smalldatetime": strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text=model." + columnName + ".ToString();"); break; case "bool": strclass.AppendSpaceLine(2, "this.chk" + columnName + ".Checked=model." + columnName + ";"); break; case "byte[]": strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text=model." + columnName + ".ToString();"); break; default: strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text=model." + columnName + ";"); break; } } strclass.AppendLine(); strclass.AppendSpaceLine(1, "}"); return(strclass.ToString()); }
public string GetkeyParalist(Hashtable Keys) { StringPlus stringPlus = new StringPlus(); foreach (DictionaryEntry dictionaryEntry in Keys) { stringPlus.Append(CodeCommon.DbTypeToCS(dictionaryEntry.Value.ToString()) + " " + dictionaryEntry.Key.ToString() + ","); } if (stringPlus.Value.IndexOf(",") > 0) { stringPlus.DelLastComma(); } return(stringPlus.Value); }
public string GetShowDesigner() { StringPlus stringPlus = new StringPlus(); foreach (ColumnInfo current in this.Fieldlist) { string columnName = current.ColumnName; string typeName = current.TypeName; string descText = current.Description; descText = CodeCommon.CutDescText(descText, 15, columnName); CodeCommon.DbTypeToCS(typeName.Trim().ToLower()).ToLower(); stringPlus.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Label lbl" + columnName + ";"); } return(stringPlus.ToString()); }
public BuilderBLL(List <ColumnInfo> keys, string modelspace) { _modelspace = modelspace; Keys = keys; foreach (ColumnInfo key in _keys) { _key = key.ColumnName; _keyType = key.TypeName; if (key.IsIdentity) { _key = key.ColumnName; _keyType = CodeCommon.DbTypeToCS(key.TypeName); break; } } }
public BuilderBLL(List <ColumnInfo> keys, string modelspace) { this._modelspace = modelspace; this.Keys = keys; foreach (ColumnInfo current in this._keys) { this._key = current.ColumnName; this._keyType = current.TypeName; if (current.IsIdentity) { this._key = current.ColumnName; this._keyType = CodeCommon.DbTypeToCS(current.TypeName); break; } } }
/// <summary> /// 修改窗体的html代码 /// </summary> public string GetUpdateDesigner() { StringPlus strclass = new StringPlus(); foreach (ColumnInfo field in Fieldlist) { string columnName = field.ColumnName; string columnType = field.TypeName; string deText = field.Description; bool ispk = field.IsPrimaryKey; bool IsIdentity = field.IsIdentity; deText = Maticsoft.CodeHelper.CodeCommon.CutDescText(deText, 15, columnName); if (isFilterColume(columnName)) { continue; } if ((ispk) || (IsIdentity) || (columnType.Trim().ToLower() == "uniqueidentifier")) { strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Label lbl" + columnName + ";"); } else { switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower()) { case "datetime": case "smalldatetime": strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";"); break; case "bool": strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.CheckBox chk" + columnName + ";"); break; default: strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";"); break; } } } //按钮 strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnSave;"); strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnCancel;"); return(strclass.Value); }
/// <summary> /// 修改窗体的html代码 /// </summary> public string GetUpdateDesigner() { StringPlus strclass = new StringPlus(); foreach (ColumnInfo field in Fieldlist) { string columnName = field.ColumnName; string columnType = field.TypeName; string deText = field.DeText; bool ispk = field.IsPK; bool IsIdentity = field.IsIdentity; if (deText.Trim() == "") { deText = columnName; } if ((ispk) || (IsIdentity)) { strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Label lbl" + columnName + ";"); } else { switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower()) { case "datetime": case "smalldatetime": strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";"); break; case "bool": strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.CheckBox chk" + columnName + ";"); break; default: strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";"); break; } } } //按钮 strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnAdd;"); strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnCancel;"); return(strclass.Value); }
/// <summary> /// 获取查询条件代码 /// </summary> /// <returns></returns> private string GetWhereCode() { StringBuilder strcode = new StringBuilder(); foreach (ColumnInfo field in eDALCode.Fieldlist) { if (field.Description.IndexOf("search") > -1) { string columnType = CodeCommon.DbTypeToCS(field.TypeName); string AttrType = BuilderTools.GetAttrType(columnType); //属性数据类型 string where = $"" + '"' + $"{field.ColumnName} = @{field.ColumnName}" + '"'; string description = field.Description.Replace(":search", ""); switch (AttrType) { case "int": strcode.Append(@" if (model." + field.ColumnName + " > 0) //" + description + @" { strWhere.AddWhere(" + where + @"); }"); break; case "string": strcode.Append(@" if (!string.IsNullOrEmpty(model." + field.ColumnName + ")) //" + description + @" { strWhere.AddWhere(" + where + @"); }"); break; case "DateTime": strcode.Append(@" if (model." + field.ColumnName + " != null) //" + description + @" { strWhere.AddWhere(" + where + @"); }"); break; } } } return(strcode.ToString()); }
public string GetUpdateDesigner() { StringPlus stringPlus = new StringPlus(); foreach (ColumnInfo current in this.Fieldlist) { string columnName = current.ColumnName; string typeName = current.TypeName; string descText = current.Description; bool isPrimaryKey = current.IsPrimaryKey; bool isIdentity = current.IsIdentity; descText = CodeCommon.CutDescText(descText, 15, columnName); if (!this.isFilterColume(columnName)) { if (isPrimaryKey || isIdentity || typeName.Trim().ToLower() == "uniqueidentifier") { stringPlus.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Label lbl" + columnName + ";"); } else { string a; if ((a = CodeCommon.DbTypeToCS(typeName.Trim().ToLower()).ToLower()) != null) { if (a == "datetime" || a == "smalldatetime") { stringPlus.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";"); continue; } if (a == "bool") { stringPlus.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.CheckBox chk" + columnName + ";"); continue; } } stringPlus.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";"); } } } stringPlus.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnSave;"); stringPlus.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnCancel;"); return(stringPlus.Value); }
public string CreatPROCGetMaxID() { StringPlus strclass = new StringPlus(); if (_keys.Count > 0) { string keyname = ""; foreach (ColumnInfo obj in _keys) { if (CodeCommon.DbTypeToCS(obj.TypeName) == "int") { keyname = obj.ColumnName; if (obj.IsPK) { //strclass.Append("if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].["); //strclass.Append("" + ProcPrefix + "" + _tablename + "_GetMaxId"); //strclass.AppendLine("]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)"); //strclass.AppendLine("drop procedure [dbo].[" + ProcPrefix + "" + _tablename + "_GetMaxId]"); //strclass.AppendLine("GO"); strclass.AppendLine("------------------------------------"); strclass.AppendLine("--用途:得到主键字段最大值 "); strclass.AppendLine("--项目名称:" + ProjectName); strclass.AppendLine("--说明:"); strclass.AppendLine("--时间:" + DateTime.Now.ToString()); strclass.AppendLine("------------------------------------"); strclass.AppendLine("CREATE PROCEDURE " + ProcPrefix + "" + _tablename + "_GetMaxId"); strclass.AppendLine("AS"); strclass.AppendSpaceLine(1, "DECLARE @TempID int"); strclass.AppendSpaceLine(1, "SELECT @TempID = max([" + keyname + "])+1 FROM " + _tablename); strclass.AppendSpaceLine(1, "IF @TempID IS NULL"); strclass.AppendSpaceLine(2, "RETURN 1"); strclass.AppendSpaceLine(1, "ELSE"); strclass.AppendSpaceLine(2, "RETURN @TempID"); strclass.AppendLine(""); strclass.AppendLine("GO"); break; } } } } return(strclass.ToString()); }
public string CreatGetMaxID() { StringPlus stringPlus = new StringPlus(); if (this.Keys.Count > 0) { foreach (ColumnInfo current in this.Keys) { if (CodeCommon.DbTypeToCS(current.TypeName) == "int" && current.IsPrimaryKey) { stringPlus.AppendSpaceLine(2, "/// <summary>"); stringPlus.AppendSpaceLine(2, "/// 得到最大ID"); stringPlus.AppendSpaceLine(2, "/// </summary>"); stringPlus.AppendLine("\t\tint GetMaxId();"); break; } } } return(stringPlus.ToString()); }
/// <summary> /// 生成实体类的属性 /// </summary> /// <returns></returns> public string CreatModelMethod() { StringPlus strclass = new StringPlus(); StringPlus strclass1 = new StringPlus(); StringPlus strclass2 = new StringPlus(); strclass.AppendSpaceLine(2, "#region Model"); foreach (ColumnInfo field in Fieldlist) { string columnName = field.ColumnName; string columnType = field.TypeName; bool IsIdentity = field.IsIdentity; bool ispk = field.IsPK; bool cisnull = field.cisNull; string deText = field.DeText; columnType = CodeCommon.DbTypeToCS(columnType); string isnull = ""; if (CodeCommon.isValueType(columnType)) { if ((!IsIdentity) && (!ispk) && (cisnull)) { isnull = "?";//代表可空类型 } } strclass1.AppendSpaceLine(2, "private " + columnType + isnull + " _" + columnName.ToLower() + ";");//私有变量 strclass2.AppendSpaceLine(2, "/// <summary>"); strclass2.AppendSpaceLine(2, "/// " + deText); strclass2.AppendSpaceLine(2, "/// </summary>"); strclass2.AppendSpaceLine(2, "public " + columnType + isnull + " " + columnName);//属性 strclass2.AppendSpaceLine(2, "{"); strclass2.AppendSpaceLine(3, "set{" + " _" + columnName.ToLower() + "=value;}"); strclass2.AppendSpaceLine(3, "get{return " + "_" + columnName.ToLower() + ";}"); strclass2.AppendSpaceLine(2, "}"); } strclass.Append(strclass1.Value); strclass.Append(strclass2.Value); strclass.AppendSpaceLine(2, "#endregion Model"); return(strclass.ToString()); }
public string CreatPROCGetMaxID() { StringPlus strclass = new StringPlus(); if (_keys.Count > 0) { string keyname = ""; foreach (ColumnInfo obj in _keys) { if (CodeCommon.DbTypeToCS(obj.TypeName) == "int") { keyname = obj.ColumnName; if (obj.IsPK) { strclass.AppendLine("------------------------------------"); strclass.AppendLine("--用途:得到主键字段最大值 "); strclass.AppendLine("--项目名称:" + ProjectName); strclass.AppendLine("--说明:"); strclass.AppendLine("--时间:" + DateTime.Now.ToString()); strclass.AppendLine("------------------------------------"); strclass.AppendLine("CREATE OR REPLACE PROCEDURE " + ProcPrefix + "" + _tablename + "_GetMaxId ("); strclass.AppendLine(")"); strclass.AppendLine("IS"); strclass.AppendLine("TempID Number;"); strclass.AppendLine("BEGIN"); strclass.AppendSpaceLine(1, "SELECT max(" + keyname + ") into TempID FROM " + _tablename); strclass.AppendSpaceLine(1, "IF NVL(TempID) then"); strclass.AppendSpaceLine(2, "RETURN 1;"); strclass.AppendSpaceLine(1, "ELSE"); strclass.AppendSpaceLine(2, "RETURN TempID;"); strclass.AppendSpaceLine(1, "end IF;"); strclass.AppendLine("END;"); break; } } } } return(strclass.ToString()); }
public string GetPROCCode(string dbname, string tablename) { this.dbobj.DbConnectStr = this._dbconnectStr; this.Fieldlist = this.dbobj.GetColumnInfoList(dbname, tablename); DataTable keyName = this.dbobj.GetKeyName(dbname, tablename); this.DbName = dbname; this.TableName = tablename; this.Keys = CodeCommon.GetColumnInfos(keyName); foreach (ColumnInfo current in this.Keys) { this._key = current.ColumnName; this._keyType = current.TypeName; if (current.IsIdentity) { this._key = current.ColumnName; this._keyType = CodeCommon.DbTypeToCS(current.TypeName); break; } } return(this.GetPROCCode(true, true, true, true, true, true, true)); }
public string CreatPROCGetMaxID() { StringPlus stringPlus = new StringPlus(); if (this._keys.Count > 0) { foreach (ColumnInfo current in this._keys) { if (CodeCommon.DbTypeToCS(current.TypeName) == "int") { string columnName = current.ColumnName; if (current.IsPrimaryKey) { stringPlus.AppendLine("------------------------------------"); stringPlus.AppendLine("--用途:得到主键字段最大值 "); stringPlus.AppendLine("--项目名称:" + this.ProjectName); stringPlus.AppendLine("--说明:"); stringPlus.AppendLine("--时间:" + DateTime.Now.ToString()); stringPlus.AppendLine("------------------------------------"); stringPlus.AppendLine("CREATE PROCEDURE " + this.ProcPrefix + this._tablename + "_GetMaxId ("); stringPlus.AppendLine(")"); stringPlus.AppendLine("IS"); stringPlus.AppendLine("TempID Number;"); stringPlus.AppendLine("BEGIN"); stringPlus.AppendSpaceLine(1, "SELECT max(" + columnName + ") into TempID FROM " + this._tablename); stringPlus.AppendSpaceLine(1, "IF NVL(TempID) then"); stringPlus.AppendSpaceLine(2, "RETURN 1;"); stringPlus.AppendSpaceLine(1, "ELSE"); stringPlus.AppendSpaceLine(2, "RETURN TempID;"); stringPlus.AppendSpaceLine(1, "end IF;"); stringPlus.AppendLine("END;"); break; } } } } return(stringPlus.ToString()); }
/// <summary> /// 得到某个表的存储过程 /// </summary> /// <param name="dbname">库名</param> /// <param name="tablename">表名</param> /// <returns></returns> public string GetPROCCode(string dbname, string tablename) { dbobj.DbConnectStr = _dbconnectStr; Fieldlist = dbobj.GetColumnInfoList(dbname, tablename); DataTable dtkey = dbobj.GetKeyName(dbname, tablename); DbName = dbname; TableName = tablename; //Fieldlist = LTP.CodeHelper.CodeCommon.GetColumnInfos(dt); Keys = LTP.CodeHelper.CodeCommon.GetColumnInfos(dtkey); foreach (ColumnInfo key in Keys) { _key = key.ColumnName; _keyType = key.TypeName; if (key.IsIdentity) { _key = key.ColumnName; _keyType = CodeCommon.DbTypeToCS(key.TypeName); break; } } return(GetPROCCode(true, true, true, true, true, true, true)); }
public string CreatGetMaxID() { StringPlus strclass = new StringPlus(); if (Keys.Count > 0) { foreach (ColumnInfo obj in Keys) { if (CodeCommon.DbTypeToCS(obj.TypeName) == "int") { if (obj.IsPrimaryKey) { strclass.AppendSpaceLine(2, "/// <summary>"); strclass.AppendSpaceLine(2, "/// 得到最大ID"); strclass.AppendSpaceLine(2, "/// </summary>"); strclass.AppendLine(" int GetMaxId();"); break; } } } } return(strclass.ToString()); }
/// <summary> /// 显示窗体的html代码 /// </summary> public string GetShowDesigner() { StringPlus strclass = new StringPlus(); foreach (ColumnInfo field in Fieldlist) { string columnName = field.ColumnName; string columnType = field.TypeName; string deText = field.Description; deText = Maticsoft.CodeHelper.CodeCommon.CutDescText(deText, 15, columnName); switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower()) { //case "bool": // strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.CheckBox chk" + columnName + ";"); // break; default: strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Label lbl" + columnName + ";"); break; } } return(strclass.ToString()); }
public string CreatGetMaxID() { StringPlus stringPlus = new StringPlus(); if (this._keys.Count > 0) { foreach (ColumnInfo current in this._keys) { if (CodeCommon.DbTypeToCS(current.TypeName) == "int") { string columnName = current.ColumnName; if (current.IsPrimaryKey) { stringPlus.AppendLine(""); stringPlus.AppendSpaceLine(2, "/// <summary>"); stringPlus.AppendSpaceLine(2, "/// " + this.Languagelist["summaryGetMaxId"].ToString()); stringPlus.AppendSpaceLine(2, "/// </summary>"); stringPlus.AppendSpaceLine(2, "public int GetMaxId()"); stringPlus.AppendSpaceLine(2, "{"); stringPlus.AppendSpaceLine(2, string.Concat(new string[] { "return ", this.DbHelperName, ".GetMaxID(\"", columnName, "\", \"", this._tablename, "\"); " })); stringPlus.AppendSpaceLine(2, "}"); break; } } } } return(stringPlus.ToString()); }