예제 #1
0
        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());
        }
예제 #2
0
        /// <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());
        }
예제 #3
0
        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());
        }
예제 #4
0
 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;
         }
     }
 }
예제 #5
0
        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);
        }
예제 #6
0
        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());
        }
예제 #7
0
        public string GetkeyWherelist(Hashtable Keys)
        {
            StringPlus stringPlus = new StringPlus();
            int        num        = 0;

            foreach (DictionaryEntry dictionaryEntry in Keys)
            {
                num++;
                if (CodeCommon.IsAddMark(dictionaryEntry.Value.ToString()))
                {
                    stringPlus.Append(dictionaryEntry.Key.ToString() + "='\"+" + dictionaryEntry.Key.ToString() + "+\"'\"");
                }
                else
                {
                    stringPlus.Append(dictionaryEntry.Key.ToString() + "=\"+" + dictionaryEntry.Key.ToString() + "+\"");
                    if (num == Keys.Count)
                    {
                        stringPlus.Append("\"");
                    }
                }
                stringPlus.Append(" and ");
            }
            if (stringPlus.Value.IndexOf("and") > 0)
            {
                stringPlus.DelLastChar("and");
            }
            return(stringPlus.Value);
        }
예제 #8
0
 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;
         }
     }
 }
예제 #9
0
        public DataTable GetKeyName(string DbName, string TableName)
        {
            DataTable         dataTable      = this.CreateColumnTable();
            List <ColumnInfo> columnInfoList = this.GetColumnInfoList(DbName, TableName);
            DataTable         columnInfoDt   = CodeCommon.GetColumnInfoDt(columnInfoList);

            DataRow[] array  = columnInfoDt.Select(" isPK='√' or IsIdentity='√' ");
            DataRow[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                DataRow dataRow  = array2[i];
                DataRow dataRow2 = dataTable.NewRow();
                dataRow2["colorder"]   = dataRow["colorder"];
                dataRow2["ColumnName"] = dataRow["ColumnName"];
                dataRow2["TypeName"]   = dataRow["TypeName"];
                dataRow2["Length"]     = dataRow["Length"];
                dataRow2["Preci"]      = dataRow["Preci"];
                dataRow2["Scale"]      = dataRow["Scale"];
                dataRow2["IsIdentity"] = dataRow["IsIdentity"];
                dataRow2["isPK"]       = dataRow["isPK"];
                dataRow2["cisNull"]    = dataRow["cisNull"];
                dataRow2["defaultVal"] = dataRow["defaultVal"].ToString().Replace("(", "").Replace(")", "");
                dataRow2["deText"]     = dataRow["deText"];
                dataTable.Rows.Add(dataRow2);
            }
            return(dataTable);
        }
예제 #10
0
        public string GetSQLInsert(string dbname, string tablename)
        {
            this.dbobj.DbConnectStr = this._dbconnectStr;
            List <ColumnInfo> columnList = this.dbobj.GetColumnList(dbname, tablename);

            this.DbName    = dbname;
            this.TableName = tablename;
            StringPlus stringPlus  = new StringPlus();
            StringPlus stringPlus2 = new StringPlus();

            stringPlus.AppendLine("INSERT INTO " + tablename + " ( ");
            if (columnList != null && columnList.Count > 0)
            {
                foreach (ColumnInfo current in columnList)
                {
                    stringPlus.AppendLine(current.ColumnName + " ,");
                    if (CodeCommon.IsAddMark(current.TypeName))
                    {
                        stringPlus2.Append("'" + current.ColumnName + "',");
                    }
                    else
                    {
                        stringPlus2.Append(current.ColumnName + ",");
                    }
                }
                stringPlus.DelLastComma();
                stringPlus2.DelLastComma();
            }
            stringPlus.Append(") VALUES (" + stringPlus2.Value + ")");
            return(stringPlus.Value);
        }
예제 #11
0
        /// <summary>
        /// 得到Add()的代码
        /// </summary>
        /// <param name="ExistsMaxId">是否有GetMaxId()生成主健</param>
        public string CreatAdd()
        {
            if (ModelSpace == "")
            {
                ModelSpace = "ModelClassName";;
            }
            StringPlus strclass  = new StringPlus();
            StringPlus strclass2 = new StringPlus();

            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "///  增加一条数据");
            strclass.AppendSpaceLine(2, "/// </summary>");
            string strretu = "void";

            if ((dbobj.DbType == "SQL2000" || dbobj.DbType == "SQL2005") && (IsHasIdentity))
            {
                strretu = "int";
            }
            //方法定义头
            string strFun = CodeCommon.Space(2) + "public " + strretu + " Add(" + ModelSpace + " model)";

            strclass.AppendLine(strFun);
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "int rowsAffected;");
            strclass.AppendSpaceLine(3, "" + DbParaHead + "Parameter[] parameters = {");
            int nkey = 0;
            int n    = 0;

            foreach (ColumnInfo field in Fieldlist)
            {
                string columnName = field.ColumnName;
                string columnType = field.TypeName;
                bool   IsIdentity = field.IsIdentity;
                string Length     = field.Length;

                strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + columnName + "\", " + DbParaDbType + "." + CodeCommon.DbTypeLength(dbobj.DbType, columnType, Length) + "),");

                if (field.IsIdentity)
                {
                    nkey = n;
                    strclass2.AppendSpaceLine(3, "parameters[" + n + "].Direction = ParameterDirection.Output;");
                    n++;
                    continue;
                }
                strclass2.AppendSpaceLine(3, "parameters[" + n + "].Value = model." + columnName + ";");
                n++;
            }

            strclass.DelLastComma();
            strclass.AppendLine("};");
            strclass.AppendLine(strclass2.Value);
            strclass.AppendSpaceLine(3, "" + DbHelperName + ".RunProcedure(\"" + ProcPrefix + _tablename + "_ADD" + "\",parameters,out rowsAffected);");
            //重新定义方法头
            if ((dbobj.DbType == "SQL2000" || dbobj.DbType == "SQL2005") && (IsHasIdentity))
            {
                strclass.AppendSpaceLine(3, "return (" + _keyType + ")parameters[" + nkey + "].Value;");
            }
            strclass.AppendSpaceLine(2, "}");
            return(strclass.Value);
        }
예제 #12
0
        /// <summary>
        /// 得到增加Add()的代码
        /// </summary>
        public string CreatAdd()
        {
            StringPlus strclass  = new StringPlus();
            StringPlus strclass1 = new StringPlus();
            StringPlus strclass2 = new StringPlus();
            StringPlus strclass3 = new StringPlus();
            StringPlus strclass4 = new StringPlus();

            strclass.AppendLine();
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// 增加一条数据");
            strclass.AppendSpaceLine(2, "/// </summary>");
            string strretu = "void";

            if ((dbobj.DbType == "SQL2000" || dbobj.DbType == "SQL2005" || dbobj.DbType == "SQL2008") && (IsHasIdentity))
            {
                strretu = "int";
            }
            //方法定义头
            string strFun = CodeCommon.Space(2) + "public " + strretu + " Add(" + ModelSpace + " model)";

            strclass.AppendLine(strFun);
            strclass.AppendSpaceLine(2, "{");
            //重新定义方法头
            if ((dbobj.DbType == "SQL2000" || dbobj.DbType == "SQL2005" || dbobj.DbType == "SQL2008") && (IsHasIdentity))
            {
                strclass.AppendSpaceLine(3, "return ExecuteInsert(\"Insert" + ModelName + "\", model);");
            }
            else
            {
                strclass.AppendSpaceLine(3, "ExecuteInsert(\"Insert" + ModelName + "\", model);");
            }
            strclass.AppendSpace(2, "}");
            return(strclass.ToString());
        }
예제 #13
0
        /// <summary>
        /// 生成INSERT查询语句
        /// </summary>
        /// <param name="dbname">库名</param>
        /// <param name="tablename">表名</param>
        /// <returns></returns>
        public string GetSQLInsert(string dbname, string tablename)
        {
            dbobj.DbConnectStr = _dbconnectStr;
            List <ColumnInfo> collist = dbobj.GetColumnList(dbname, tablename);

            this.DbName    = dbname;
            this.TableName = tablename;
            StringPlus strsql  = new StringPlus();
            StringPlus strsql2 = new StringPlus();

            strsql.AppendLine("INSERT INTO " + tablename + " ( ");

            if ((collist != null) && (collist.Count > 0))
            {
                foreach (ColumnInfo col in collist)
                {
                    string columnName = col.ColumnName;
                    string columnType = col.TypeName;
                    strsql.AppendLine("" + columnName + " ,");
                    if (CodeCommon.IsAddMark(columnType))
                    {
                        strsql2.Append("'" + columnName + "',");
                    }
                    else
                    {
                        strsql2.Append(columnName + ",");
                    }
                }
                strsql.DelLastComma();
                strsql2.DelLastComma();
            }
            strsql.Append(") VALUES (" + strsql2.Value + ")");
            return(strsql.Value);
        }
예제 #14
0
        /// <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());
        }
예제 #15
0
        /// <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());
        }
예제 #16
0
 public string GetBLLCode(string AssemblyGuid, bool Maxid, bool Exists, bool Add, bool Update, bool Delete, bool GetModel, bool GetModelByCache, bool List, bool ListProc)
 {
     this.ibll = BuilderFactory.CreateBLLObj(AssemblyGuid);
     if (this.ibll == null)
     {
         return("//请选择有效的业务层代码组件类型!");
     }
     this.ibll.Fieldlist        = base.Fieldlist;
     this.ibll.Keys             = base.Keys;
     this.ibll.NameSpace        = base.NameSpace;
     this.ibll.Folder           = base.Folder;
     this.ibll.Modelpath        = base.Modelpath;
     this.ibll.ModelName        = base.ModelName;
     this.ibll.TableDescription = CodeCommon.CutDescText(base.TableDescription, 10, base.BLLName);
     this.ibll.BLLpath          = base.BLLpath;
     this.ibll.BLLName          = base.BLLName;
     this.ibll.Factorypath      = base.Factorypath;
     this.ibll.IDALpath         = base.IDALpath;
     this.ibll.IClass           = base.IClass;
     this.ibll.DALpath          = base.DALpath;
     this.ibll.DALName          = base.DALName;
     this.ibll.IsHasIdentity    = base.IsHasIdentity;
     this.ibll.DbType           = this.dbobj.DbType;
     return(this.ibll.GetBLLCode(Maxid, Exists, Add, Update, Delete, GetModel, GetModelByCache, List));
 }
예제 #17
0
 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;
         }
     }
 }
예제 #18
0
        /// <summary>
        /// 得到Add()的代码
        /// </summary>
        /// <param name="ExistsMaxId">是否有GetMaxId()生成主健</param>
        public string CreatAdd()
        {
            //if (ModelSpace == "")
            //{
            //    ModelSpace = "ModelClassName"; ;
            //}
            StringPlus strclass  = new StringPlus();
            StringPlus strclass2 = new StringPlus();

            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "///  增加一条数据");
            strclass.AppendSpaceLine(2, "/// </summary>");
            string strretu = "void";

            if (IsHasIdentity)
            {
                strretu = "int";
            }
            //方法定义头
            string strFun = CodeCommon.Space(2) + "public " + strretu + " Add(" + ModelSpace + " model)";

            strclass.AppendLine(strFun);
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "Database db = DatabaseFactory.CreateDatabase();");
            strclass.AppendSpaceLine(3, "DbCommand dbCommand = db.GetStoredProcCommand(\"" + ProcPrefix + _tablename + "_ADD\");");

            string nkey = string.Empty;;

            foreach (ColumnInfo field in Fieldlist)
            {
                string columnName = field.ColumnName;
                string columnType = field.TypeName;
                bool   IsIdentity = field.IsIdentity;
                string Length     = field.Length;

                if (field.IsIdentity)
                {
                    strclass.AppendSpaceLine(3, "db.AddOutParameter(dbCommand, \"" + columnName + "\", DbType." + CSToProcType(columnType) + ", " + Length + ");");
                    nkey = columnName;
                }
                else
                {
                    strclass.AppendSpaceLine(3, "db.AddInParameter(dbCommand, \"" + columnName + "\", DbType." + CSToProcType(columnType) + ", model." + columnName + ");");
                }
            }

            strclass.AppendSpaceLine(3, "db.ExecuteNonQuery(dbCommand);");


            //重新定义方法头
            if (IsHasIdentity)
            {
                strclass.AppendSpaceLine(3, "return (" + _keyType + ")db.GetParameterValue(dbCommand, \"" + nkey + "\");");
            }
            strclass.AppendSpaceLine(2, "}");
            return(strclass.Value);
        }
예제 #19
0
        /// <summary>
        /// 得到主键的对象信息
        /// </summary>
        /// <returns></returns>
        private List <ColumnInfo> GetKeyFields()
        {
            List <ColumnInfo> columnInfoList = this.dbobj.GetColumnInfoList(this.dbname, this.tablename);
            DataTable         columnInfoDt   = CodeCommon.GetColumnInfoDt(columnInfoList);
            StringPlus        stringPlus     = new StringPlus();

            foreach (object current in this.list_KeyField.Items)
            {
                stringPlus.Append("'" + current.ToString() + "',");
            }
            stringPlus.DelLastComma();
            if (columnInfoDt != null)
            {
                DataRow[] array;
                if (stringPlus.Value.Length > 0)
                {
                    array = columnInfoDt.Select("ColumnName in (" + stringPlus.Value + ")", "colorder asc");
                }
                else
                {
                    array = columnInfoDt.Select();
                }
                List <ColumnInfo> list   = new List <ColumnInfo>();
                DataRow[]         array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    DataRow dataRow     = array2[i];
                    string  columnOrder = dataRow["Colorder"].ToString();
                    string  columnName  = dataRow["ColumnName"].ToString();
                    string  typeName    = dataRow["TypeName"].ToString();
                    string  a           = dataRow["IsIdentity"].ToString();
                    string  a2          = dataRow["IsPK"].ToString();
                    string  length      = dataRow["Length"].ToString();
                    string  precision   = dataRow["Preci"].ToString();
                    string  scale       = dataRow["Scale"].ToString();
                    string  a3          = dataRow["cisNull"].ToString();
                    string  defaultVal  = dataRow["DefaultVal"].ToString();
                    string  description = dataRow["DeText"].ToString();
                    list.Add(new ColumnInfo
                    {
                        ColumnOrder  = columnOrder,
                        ColumnName   = columnName,
                        TypeName     = typeName,
                        IsIdentity   = a == "√",
                        IsPrimaryKey = a2 == "√",
                        Length       = length,
                        Precision    = precision,
                        Scale        = scale,
                        Nullable     = a3 == "√",
                        DefaultVal   = defaultVal,
                        Description  = description
                    });
                }
                return(list);
            }
            return(null);
        }
예제 #20
0
        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);
        }
예제 #21
0
        public string CreatGetModel()
        {
            StringPlus stringPlus = new StringPlus();

            stringPlus.AppendSpaceLine(2, "/// <summary>");
            stringPlus.AppendSpaceLine(2, "/// 得到一个对象实体");
            stringPlus.AppendSpaceLine(2, "/// </summary>");
            stringPlus.AppendSpaceLine(2, this.ModelSpace + " GetModel(" + CodeCommon.GetInParameter(this.Keys, true) + ");");
            stringPlus.AppendSpaceLine(2, this.ModelSpace + " DataRowToModel(DataRow row);");
            return(stringPlus.ToString());
        }
예제 #22
0
        public string CreatBLLDelete()
        {
            StringPlus stringPlus = new StringPlus();

            stringPlus.AppendSpaceLine(2, "/// <summary>");
            stringPlus.AppendSpaceLine(2, "/// " + this.Languagelist["summaryDelete"].ToString());
            stringPlus.AppendSpaceLine(2, "/// </summary>");
            stringPlus.AppendSpaceLine(2, "public bool Delete(" + CodeCommon.GetInParameter(this.Keys, true) + ")");
            stringPlus.AppendSpaceLine(2, "{");
            stringPlus.AppendSpaceLine(3, this.KeysNullTip);
            stringPlus.AppendSpaceLine(3, "return dal.Delete(" + CodeCommon.GetFieldstrlist(this.Keys, true) + ");");
            stringPlus.AppendSpaceLine(2, "}");
            if (CodeCommon.HasNoIdentityKey(this.Keys) && CodeCommon.GetIdentityKey(this.Keys) != null)
            {
                stringPlus.AppendSpaceLine(2, "/// <summary>");
                stringPlus.AppendSpaceLine(2, "/// " + this.Languagelist["summaryDelete"].ToString());
                stringPlus.AppendSpaceLine(2, "/// </summary>");
                stringPlus.AppendSpaceLine(2, "public bool Delete(" + CodeCommon.GetInParameter(this.Keys, false) + ")");
                stringPlus.AppendSpaceLine(2, "{");
                stringPlus.AppendSpaceLine(3, this.KeysNullTip);
                stringPlus.AppendSpaceLine(3, "return dal.Delete(" + CodeCommon.GetFieldstrlist(this.Keys, false) + ");");
                stringPlus.AppendSpaceLine(2, "}");
            }
            string text = "";

            if (this.Keys.Count == 1)
            {
                text = this.Keys[0].ColumnName;
            }
            else
            {
                foreach (ColumnInfo current in this.Keys)
                {
                    if (current.IsIdentity)
                    {
                        text = current.ColumnName;
                        break;
                    }
                }
            }
            if (text.Trim().Length > 0)
            {
                stringPlus.AppendSpaceLine(2, "/// <summary>");
                stringPlus.AppendSpaceLine(2, "/// " + this.Languagelist["summaryDelete"].ToString());
                stringPlus.AppendSpaceLine(2, "/// </summary>");
                stringPlus.AppendSpaceLine(2, "public bool DeleteList(string " + text + "list )");
                stringPlus.AppendSpaceLine(2, "{");
                stringPlus.AppendSpaceLine(3, "return dal.DeleteList(Maticsoft.Common.PageValidate.SafeLongFilter(" + text + "list,0) );");
                stringPlus.AppendSpaceLine(2, "}");
            }
            return(stringPlus.ToString());
        }
예제 #23
0
        /// <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());
        }
예제 #24
0
        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);
        }
예제 #25
0
        public string CreatBLLGetModelByCache(string ModelName)
        {
            StringPlus stringPlus = new StringPlus();

            stringPlus.AppendSpaceLine(2, "/// <summary>");
            stringPlus.AppendSpaceLine(2, "/// " + this.Languagelist["summaryGetModelByCache"].ToString());
            stringPlus.AppendSpaceLine(2, "/// </summary>");
            stringPlus.AppendSpaceLine(2, string.Concat(new string[]
            {
                "public ",
                this.ModelSpace,
                " GetModelByCache(",
                CodeCommon.GetInParameter(this.Keys, true),
                ")"
            }));
            stringPlus.AppendSpaceLine(2, "{");
            stringPlus.AppendSpaceLine(3, this.KeysNullTip);
            string text = "";

            if (this.Keys.Count > 0)
            {
                text = "+ " + CodeCommon.GetFieldstrlistAdd(this.Keys, true);
            }
            stringPlus.AppendSpaceLine(3, string.Concat(new string[]
            {
                "string CacheKey = \"",
                ModelName,
                "Model-\" ",
                text,
                ";"
            }));
            stringPlus.AppendSpaceLine(3, "object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);");
            stringPlus.AppendSpaceLine(3, "if (objModel == null)");
            stringPlus.AppendSpaceLine(3, "{");
            stringPlus.AppendSpaceLine(4, "try");
            stringPlus.AppendSpaceLine(4, "{");
            stringPlus.AppendSpaceLine(5, "objModel = dal.GetModel(" + CodeCommon.GetFieldstrlist(this.Keys, true) + ");");
            stringPlus.AppendSpaceLine(5, "if (objModel != null)");
            stringPlus.AppendSpaceLine(5, "{");
            stringPlus.AppendSpaceLine(6, "int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt(\"ModelCache\");");
            stringPlus.AppendSpaceLine(6, "Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);");
            stringPlus.AppendSpaceLine(5, "}");
            stringPlus.AppendSpaceLine(4, "}");
            stringPlus.AppendSpaceLine(4, "catch{}");
            stringPlus.AppendSpaceLine(3, "}");
            stringPlus.AppendSpaceLine(3, "return (" + this.ModelSpace + ")objModel;");
            stringPlus.AppendSpaceLine(2, "}");
            return(stringPlus.Value);
        }
예제 #26
0
        /// <summary>
        /// 得到方法输入参数的列表 (例如:用于Exists  Delete  GetModel 的参数传入)
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        public string GetInParameter(List <ColumnInfo> fieldlist, bool output)
        {
            StringPlus strclass = new StringPlus();

            foreach (ColumnInfo field in fieldlist)
            {
                string columnName = field.ColumnName;
                string columnType = field.TypeName;
                bool   IsIdentity = field.IsIdentity;
                bool   IsPK       = field.IsPK;
                string Length     = field.Length;
                string Preci      = field.Preci;
                string Scale      = field.Scale;
                //if (Length.Trim() == "-1")
                //{
                //    Length = "MAX";
                //}
                switch (columnType.ToLower())
                {
                case "decimal":
                case "numeric":
                    strclass.Append("@" + columnName + " " + columnType + "(" + Preci + "," + Scale + ")");
                    break;

                case "char":
                case "varchar":
                case "varbinary":
                case "binary":
                case "nchar":
                case "nvarchar":
                {
                    strclass.Append("@" + columnName + " " + columnType + "(" + CodeCommon.GetDataTypeLenVal(columnType.ToLower(), Length) + ")");
                }
                break;

                default:
                    strclass.Append("@" + columnName + " " + columnType);
                    break;
                }
                if ((IsIdentity) && (output))
                {
                    strclass.AppendLine(" output,");
                    continue;
                }
                strclass.AppendLine(",");
            }
            strclass.DelLastComma();
            return(strclass.Value);
        }
예제 #27
0
        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());
        }
예제 #28
0
 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;
         }
     }
 }
예제 #29
0
 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;
         }
     }
 }
예제 #30
0
        /// <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);
        }