Beispiel #1
0
        public string CreatBLLGetMaxID()
        {
            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 static int GetMaxId()");
                            strclass.AppendSpaceLine(2, "{");
                            strclass.AppendSpaceLine(3, "return " + DALName + ".Instance.GetMaxID(\"\");");
                            strclass.AppendSpaceLine(2, "}");
                            strclass.AppendSpaceLine(2, "public static int GetMaxId(SQLPara para)");
                            strclass.AppendSpaceLine(2, "{");
                            strclass.AppendSpaceLine(3, "return " + DALName + ".Instance.GetMaxID(para);");
                            strclass.AppendSpaceLine(2, "}");
                            strclass.AppendSpaceLine(2, "public static int GetMaxId(string strWhere)");
                            strclass.AppendSpaceLine(2, "{");
                            strclass.AppendSpaceLine(3, "return " + DALName + ".Instance.GetMaxID(strWhere);");
                            strclass.AppendSpaceLine(2, "}");
                            break;
                        }
                    }
                }
            }


            return(strclass.Value);
        }
Beispiel #2
0
        /// <summary>
        /// 生成实体类的属性
        /// </summary>
        /// <returns></returns>
        public string CreatModelMethod(List <ColumnInfo> fieldlist)
        {
            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  = "";
                string devalue = "";
                //if (CodeCommon.isValueType(columnType))
                //{
                //    if ((!IsIdentity) && (!ispk) && (cisnull))
                //    {
                //        isnull = "?";//代表可空类型
                //    }
                //}
                switch (columnType.ToLower())
                {
                case "int":
                    devalue = "0";
                    break;

                case "longint":
                    devalue = "0";
                    break;

                case "string":
                    devalue = "\"\"";
                    break;

                case "datetime":
                    devalue = "DateTime.Now";
                    break;

                case "bool":
                    devalue = "false";
                    break;

                case "decimal":
                    devalue = "0";
                    break;
                }

                strclass1.AppendSpaceLine(2, "private " + columnType + isnull + " _" + columnName.ToLower() + "=" + devalue + ";");//私有变量
                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.Value);
        }
Beispiel #3
0
        public void CreatBLL(string path)
        {
            string str = GetBLLCodeStr();

            CodeCommon.CreatFile(path, BLLName + ".cs", str);
        }
Beispiel #4
0
        /// <summary>
        /// 生成实体
        /// </summary>
        /// <param name="fieldlist"></param>
        /// <param name="path"></param>
        /// <param name="filename"></param>
        public void CreatModel(List <ColumnInfo> fieldlist, string path)
        {
            string str = CreatModelStr(fieldlist);

            CodeCommon.CreatFile(path, _modelname + ".cs", str);
        }