Exemple #1
0
 /// <summary>
 /// ��������Model��
 /// </summary>		
 public string CreatModelMethodT()
 {
     StringPlus strclass = new StringPlus();
     strclass.AppendLine(CreatModelMethod());
     strclass.AppendSpaceLine(2, "private List<" + ModelNameSon + "> _" + ModelNameSon.ToLower() + "s;");//˽�б���
     strclass.AppendSpaceLine(2, "/// <summary>");
     strclass.AppendSpaceLine(2, "/// ���� ");
     strclass.AppendSpaceLine(2, "/// </summary>");
     //strclass.AppendSpaceLine(2, "[Serializable]");
     strclass.AppendSpaceLine(2, "public List<" + ModelNameSon + "> " + ModelNameSon + "s");//����
     strclass.AppendSpaceLine(2, "{");
     strclass.AppendSpaceLine(3, "set{" + " _" + ModelNameSon.ToLower() + "s=value;}");
     strclass.AppendSpaceLine(3, "get{return " + "_" + ModelNameSon.ToLower() + "s;}");
     strclass.AppendSpaceLine(2, "}");
     return strclass.ToString();
 }
Exemple #2
0
        protected override void OnLoad(EventArgs e)
        {
            InitValidationRules();
            this.ParentForm.AcceptButton = btnLogin;
            this.ParentForm.CancelButton = btnCancel;
            this.ParentForm.FormClosing += ParentForm_FormClosing;

            string uidmd5 = StringPlus.DecompressString(ConfigHelper.GetConfigString("u"));
            string pwdmd5 = StringPlus.DecompressString(ConfigHelper.GetConfigString("p"));

            if (string.IsNullOrWhiteSpace(uidmd5) || string.IsNullOrWhiteSpace(pwdmd5))
            {
                chkAutoLogin.Checked = false;
            }
            else
            {
                chkAutoLogin.Checked = true;
                txtUid.EditValue     = DESEncrypt.Decrypt(uidmd5);
                txtPwd.EditValue     = DESEncrypt.Decrypt(pwdmd5);
                btnLogin_Click(btnLogin, e);
            }

            base.OnLoad(e);
        }
        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("AS");
                            stringPlus.AppendSpaceLine(1, "DECLARE @TempID int");
                            stringPlus.AppendSpaceLine(1, "SELECT @TempID = max([" + columnName + "])+1 FROM " + this._tablename);
                            stringPlus.AppendSpaceLine(1, "IF @TempID IS NULL");
                            stringPlus.AppendSpaceLine(2, "RETURN 1");
                            stringPlus.AppendSpaceLine(1, "ELSE");
                            stringPlus.AppendSpaceLine(2, "RETURN @TempID");
                            stringPlus.AppendLine("");
                            stringPlus.AppendLine("GO");
                            break;
                        }
                    }
                }
            }
            return(stringPlus.ToString());
        }
Exemple #4
0
        public string GetWebCode(bool ExistsKey, bool AddForm, bool UpdateForm, bool ShowForm, bool SearchForm)
        {
            StringPlus stringPlus = new StringPlus();

            if (AddForm)
            {
                stringPlus.AppendLine("  /******************************增加窗体代码********************************/");
                stringPlus.AppendLine(this.GetAddAspxCs());
            }
            if (UpdateForm)
            {
                stringPlus.AppendLine("  /******************************修改窗体代码********************************/");
                stringPlus.AppendLine("  /*修改代码-显示 */");
                stringPlus.AppendLine(this.GetUpdateShowAspxCs());
                stringPlus.AppendLine("  /*修改代码-提交更新 */");
                stringPlus.AppendLine(this.GetUpdateAspxCs());
            }
            if (ShowForm)
            {
                stringPlus.AppendLine("  /******************************显示窗体代码********************************/");
                stringPlus.AppendLine(this.GetShowAspxCs());
            }
            return(stringPlus.Value);
        }
Exemple #5
0
        public string GetShowAspx()
        {
            StringPlus stringPlus = new StringPlus();

            stringPlus.AppendLine();
            stringPlus.AppendLine("<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\">");
            foreach (ColumnInfo current in this.Fieldlist)
            {
                string columnName = current.ColumnName;
                string typeName   = current.TypeName;
                string text       = current.Description;
                text = CodeCommon.CutDescText(text, 15, columnName);
                stringPlus.AppendSpaceLine(1, "<tr>");
                stringPlus.AppendSpaceLine(1, "<td height=\"25\" width=\"30%\" align=\"right\">");
                stringPlus.AppendSpaceLine(2, text);
                stringPlus.AppendSpaceLine(1, ":</td>");
                stringPlus.AppendSpaceLine(1, "<td height=\"25\" width=\"*\" align=\"left\">");
                typeName.Trim().ToLower();
                stringPlus.AppendSpaceLine(2, "<asp:Label id=\"lbl" + columnName + "\" runat=\"server\"></asp:Label>");
                stringPlus.AppendSpaceLine(1, "</td></tr>");
            }
            stringPlus.AppendLine("</table>");
            return(stringPlus.ToString());
        }
Exemple #6
0
        /// <summary>
        /// 得到GetModel()的代码
        /// </summary>
        /// <param name="DbName"></param>
        /// <param name="_tablename"></param>
        /// <param name="_key"></param>
        /// <param name="ModelName"></param>
        /// <returns></returns>
        public string CreatGetModel()
        {
            //if (ModelSpace == "")
            //{
            //    ModelSpace = "ModelClassName"; ;
            //}
            StringPlus strclass = new StringPlus();

            strclass.AppendLine();
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// 得到一个对象实体");
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public " + ModelSpace + " GetModel(" + LTP.CodeHelper.CodeCommon.GetInParameter(Keys) + ")");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
            strclass.AppendSpaceLine(3, "strSql.Append(\"select  " + " \");");
            strclass.AppendSpaceLine(3, "strSql.Append(\" " + Fieldstrlist + " \");");
            strclass.AppendSpaceLine(3, "strSql.Append(\" from " + _tablename + " \");");
            strclass.AppendSpaceLine(3, "strSql.Append(\" where " + LTP.CodeHelper.CodeCommon.GetWhereExpression(Keys) + "\" );");


            strclass.AppendSpaceLine(3, "Database db = DatabaseFactory.CreateDatabase();");
            strclass.AppendSpaceLine(3, "DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());");
            strclass.AppendSpaceLine(3, "" + ModelSpace + " model=null;");

            strclass.AppendSpaceLine(3, "using (IDataReader dataReader = db.ExecuteReader(dbCommand))");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "if(dataReader.Read())");
            strclass.AppendSpaceLine(4, "{");
            strclass.AppendSpaceLine(5, "model=ReaderBind(dataReader);");
            strclass.AppendSpaceLine(4, "}");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "return model;");
            strclass.AppendSpaceLine(2, "}");
            return(strclass.Value);
        }
Exemple #7
0
        /// <summary>
        /// 得到某字段最大值的方法代码(只有主键是int型的情况下生成)
        /// </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(3, "string strsql = \"select max(" + keyname + ")+1 from " + _tablename + "\";");
                            strclass.AppendSpaceLine(3, "Database db = DatabaseFactory.CreateDatabase();");
                            strclass.AppendSpaceLine(3, "object obj = db.ExecuteScalar(CommandType.Text, strsql);");
                            strclass.AppendSpaceLine(3, "if (obj != null && obj != DBNull.Value)");
                            strclass.AppendSpaceLine(3, "{");
                            strclass.AppendSpaceLine(4, "return int.Parse(obj.ToString());");
                            strclass.AppendSpaceLine(3, "}");
                            strclass.AppendSpaceLine(3, "return 1;");
                            strclass.AppendSpaceLine(2, "}");
                            break;
                        }
                    }
                }
            }
            return(strclass.ToString());
        }
Exemple #8
0
        public string CreatBLLGetModelByCache(string ModelName)
        {
            StringPlus strclass = new StringPlus();

            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryGetModelByCache"].ToString());
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public " + ModelSpace + " GetModelByCache(" + Maticsoft.CodeHelper.CodeCommon.GetInParameter(Keys, true) + ")");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, KeysNullTip);
            string para = "";

            if (Keys.Count > 0)
            {
                para = "+ " + Maticsoft.CodeHelper.CodeCommon.GetFieldstrlistAdd(Keys, true);
            }
            strclass.AppendSpaceLine(3, "string CacheKey = \"" + ModelName + "Model-\" " + para + ";");
            strclass.AppendSpaceLine(3, "object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);");
            strclass.AppendSpaceLine(3, "if (objModel == null)");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "try");
            strclass.AppendSpaceLine(4, "{");
            strclass.AppendSpaceLine(5, "objModel = dal.GetModel(" + Maticsoft.CodeHelper.CodeCommon.GetFieldstrlist(Keys, true) + ");");
            strclass.AppendSpaceLine(5, "if (objModel != null)");
            strclass.AppendSpaceLine(5, "{");
            strclass.AppendSpaceLine(6, "int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt(\"ModelCache\");");
            //strclass.AppendSpaceLine(6, "int ModelCache = Globals.SafeInt(BLL.SysManage.ConfigSystem.GetValueByCache(\"CacheTime\"), 30);");
            strclass.AppendSpaceLine(6, "Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);");
            strclass.AppendSpaceLine(5, "}");
            strclass.AppendSpaceLine(4, "}");
            strclass.AppendSpaceLine(4, "catch{}");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "return (" + ModelSpace + ")objModel;");
            strclass.AppendSpaceLine(2, "}");
            return(strclass.Value);
        }
        /// <summary>
        /// 生成完整Model类
        /// </summary>
        public string CreatModel()
        {
            StringPlus strclass = new StringPlus();

            strclass.AppendLine("using System;");
            strclass.AppendLine("namespace " + Modelpath);
            strclass.AppendLine("{");
            strclass.AppendSpaceLine(1, "/// <summary>");
            if (TableDescription.Length > 0)
            {
                strclass.AppendSpaceLine(1, "/// 【Model】: " + TableDescription.Replace("\r\n", "\r\n\t///"));
            }
            else
            {
                strclass.AppendSpaceLine(1, "/// 【Model】: " + _modelname /*+ ":" + Languagelist["summary"].ToString()*/);
            }
            strclass.AppendSpaceLine(1, "/// </summary>");
            strclass.AppendSpaceLine(1, "[Serializable]");
            strclass.AppendSpaceLine(1, "public partial class " + _modelname);
            strclass.AppendSpaceLine(1, "{");
            strclass.AppendSpaceLine(2, "public " + _modelname + "()");
            strclass.AppendSpaceLine(2, "{}");
            strclass.AppendLine(CreatModelMethod());
            strclass.AppendSpaceLine(1, "}");
            strclass.AppendLine("}");
            strclass.AppendLine("");

            if (Modelpath.Contains("Maticsoft"))//如果为默认命名空间直接返回
            {
                return(strclass.ToString());
            }
            else//否则直接替换原始命名空间
            {
                return(strclass.ToString().Replace("Maticsoft", Modelpath.Split('.')[0]));
            }
        }
        /// <summary>
        /// 生成INSERT查询语句
        /// </summary>
        /// <param name="dbname">库名</param>
        /// <param name="tablename">表名</param>
        /// <returns></returns>
        public string GetSQLInsert(string dbname, string tablename)
        {
            dbobj.DbConnectStr = _dbconnectStr;
            //DataTable dt = dbobj.GetColumnList(dbname, tablename);
            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 (LTP.CodeHelper.CodeCommon.IsAddMark(columnType))
                    {
                        strsql2.Append("'" + columnName + "',");
                    }
                    else
                    {
                        strsql2.Append(columnName + ",");
                    }
                }
                strsql.DelLastComma();
                strsql2.DelLastComma();
            }
            strsql.Append(") VALUES (" + strsql2.Value + ")");
            return(strsql.Value);
        }
Exemple #11
0
        public static string GetWhereExpression(List <ColumnInfo> keys, bool IdentityisPrior)
        {
            StringPlus stringPlus  = new StringPlus();
            ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys);

            if (IdentityisPrior && identityKey != null)
            {
                if (CodeCommon.IsAddMark(identityKey.TypeName))
                {
                    stringPlus.Append(identityKey.ColumnName + "='\"+" + identityKey.ColumnName + "+\"'");
                }
                else
                {
                    stringPlus.Append(identityKey.ColumnName + "=\"+" + identityKey.ColumnName + "+\"");
                }
            }
            else
            {
                foreach (ColumnInfo current in keys)
                {
                    if (current.IsPrimaryKey || !current.IsIdentity)
                    {
                        if (CodeCommon.IsAddMark(current.TypeName))
                        {
                            stringPlus.Append(current.ColumnName + "='\"+" + current.ColumnName + "+\"' and ");
                        }
                        else
                        {
                            stringPlus.Append(current.ColumnName + "=\"+" + current.ColumnName + "+\" and ");
                        }
                    }
                }
                stringPlus.DelLastChar("and");
            }
            return(stringPlus.Value);
        }
        /// <summary>
        /// 生成获取实体代码
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="keyColumnList"></param>
        /// <returns></returns>
        private string BuildCode_GetModel(string tableName, List <Column> keyColumnList)
        {
            StringPlus sp = new StringPlus();

            //注释
            sp.AppendSpaceLine(1, "/// <summary>");
            sp.AppendSpaceLine(1, "/// " + "获取模型");
            sp.AppendSpaceLine(1, "/// </summary>");

            //方法头
            string strFun = string.Format("public {0} GetModel({1})", tableName, BuildHelper.BuildParameterListString(keyColumnList, true));

            sp.AppendSpaceLine(1, strFun);

            //方法体
            sp.AppendSpaceLine(1, "{");
            sp.AppendSpaceLine(2, string.Format("{0} model = null;", tableName));
            sp.AppendSpaceLine(2, string.Format("DataTable dt = GetModelTable({0});", BuildHelper.BuildParameterListString(keyColumnList, false)));
            sp.AppendSpaceLine(2, string.Format("model = DataTableHelper.CreateItem<{0}>(dt.Rows[0]);", tableName));
            sp.AppendSpaceLine(2, "return model;");
            sp.AppendSpaceLine(1, "}");

            return(sp.ToString());
        }
Exemple #13
0
        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <returns></returns>
        private string DeriveData()
        {
            int       count = 0;
            DataTable dt    = GetList(ref count);

            if (dt != null && dt.Rows.Count > 0)
            {
                string ExcelFolder = "ExcelFolder";// Assistant.GetConfigString("ExcelFolder");

                string filename = DateTime.Now.ToString("yyyyMMddHHmmssff") + ".xls";
                string msg      = string.Empty;
                if (dt != null && dt.Rows.Count > 0)
                {
                    dt.Columns.Remove("Ro");
                    dt.Columns.Remove("CBDW_BM");
                    dt.Columns["CBDW_MC"].ColumnName = "承办单位";
                    dt.Columns["AJNUM"].ColumnName   = "制作案件数";
                    dt.Columns["JNUM"].ColumnName    = "卷数";
                    dt.Columns["WJNUM"].ColumnName   = "文件数";
                    dt.Columns["WJYNUM"].ColumnName  = "文件页数";

                    msg = DataToExcel_Ex.Export(dt, "卷宗制作量统计", Server.MapPath("/" + ExcelFolder + "/" + filename));

                    //filename = dte.DataExcel(dt, "卷宗制作量统计", FilePath, nameList, null);
                }
                if (string.IsNullOrEmpty(msg))
                {
                    return(ReturnString.JsonToString(Prompt.win, "/" + ExcelFolder + "/" + filename, null));
                }
                else
                {
                    return(ReturnString.JsonToString(Prompt.error, StringPlus.String2Json(msg), null));
                }
            }
            return(ReturnString.JsonToString(Prompt.error, "导出失败", null));
        }
Exemple #14
0
        public string GetShowAspxCs()
        {
            //LTP.BuilderWeb.BuilderWeb bw = CreatBuilderWeb();
            if (ibw == null)
            {
                return("//请选择有效的表示层代码组件!");
            }
            string     cs      = ibw.GetShowAspxCs();
            StringPlus strcode = new StringPlus();

            //strcode.AppendSpaceLine(2, "protected void Page_LoadComplete(object sender, EventArgs e)");
            //strcode.AppendSpaceLine(2, "{");
            //strcode.AppendSpaceLine(3, "(Master.FindControl(\"lblTitle\") as Label).Text = \"详细信息\";");
            //strcode.AppendSpaceLine(2, "}");
            strcode.AppendSpaceLine(2, "protected void Page_Load(object sender, EventArgs e)");
            strcode.AppendSpaceLine(2, "{");
            strcode.AppendSpaceLine(3, "if (!Page.IsPostBack)");
            strcode.AppendSpaceLine(3, "{");
            strcode.AppendSpaceLine(4, "if (Request.Params[\"id\"] != null && Request.Params[\"id\"].Trim() != \"\")");
            strcode.AppendSpaceLine(4, "{");
            strcode.AppendSpaceLine(5, "string id = Request.Params[\"id\"];");
            if (_keys.Count > 0)
            {
                strcode.AppendSpaceLine(5, "//ShowInfo(" + LTP.CodeHelper.CodeCommon.GetFieldstrlist(Keys) + ");");
            }
            else
            {
                strcode.AppendSpaceLine(5, "ShowInfo();");
            }
            strcode.AppendSpaceLine(4, "}");
            strcode.AppendSpaceLine(3, "}");

            strcode.AppendSpaceLine(2, "}");
            strcode.AppendSpaceLine(2, cs);
            return(strcode.ToString());
        }
Exemple #15
0
        /// <summary>
        /// 得到表示层增加窗体的html代码
        /// </summary>
        public string GetUpdateAspx()
        {
            StringPlus strclass = new StringPlus();

            strclass.AppendLine("");
            strclass.AppendLine("<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\">");
            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, "<tr>");
                    strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"30%\" align=\"right\">");
                    strclass.AppendSpaceLine(2, deText);
                    strclass.AppendSpaceLine(1, ":</td>");
                    strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"*\" align=\"left\">");
                    strclass.AppendSpaceLine(2, "<asp:label id=\"lbl" + columnName + "\" runat=\"server\"></asp:label>");
                    strclass.AppendSpaceLine(1, "</td></tr>");
                }
                else
                {
                    //
                    strclass.AppendSpaceLine(1, "<tr>");
                    strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"30%\" align=\"right\">");
                    strclass.AppendSpaceLine(2, deText);
                    strclass.AppendSpaceLine(1, ":</td>");
                    strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"*\" align=\"left\">");
                    switch (columnType.Trim())
                    {
                    case "datetime":
                    case "smalldatetime":
                        strclass.AppendSpaceLine(2, "<INPUT onselectstart=\"return false;\" onkeypress=\"return false\" id=\"txt" + columnName + "\" onfocus=\"setday(this)\"");
                        strclass.AppendSpaceLine(2, " readOnly type=\"text\" size=\"10\" name=\"Text1\" runat=\"server\">");
                        break;

                    case "bit":
                        strclass.AppendSpaceLine(2, "<asp:CheckBox ID=\"chk" + columnName + "\" Text=\"" + deText + "\" runat=\"server\" Checked=\"False\" />");
                        break;

                    default:
                        strclass.AppendSpaceLine(2, "<asp:TextBox id=\"txt" + columnName + "\" runat=\"server\" Width=\"200px\"></asp:TextBox>");
                        break;
                    }
                    strclass.AppendSpaceLine(1, "</td></tr>");
                }
            }

            //按钮
            strclass.AppendSpaceLine(1, "<tr>");
            strclass.AppendSpaceLine(1, "<td height=\"25\" colspan=\"2\"><div align=\"center\">");
            strclass.AppendSpaceLine(2, "<asp:Button ID=\"btnAdd\" runat=\"server\" Text=\"· 提交 ·\" OnClick=\"btnAdd_Click\" ></asp:Button>");
            //strclass.AppendSpaceLine(2, "<asp:Button ID=\"btnCancel\" runat=\"server\" Text=\"· 取消 ·\" OnClick=\"btnCancel_Click\" ></asp:Button>");
            strclass.AppendSpaceLine(1, "</div></td></tr>");
            strclass.AppendLine("</table>");
            return(strclass.Value);
        }
Exemple #16
0
        /// <summary>
        /// 获取配置文件中串口线路的信息
        /// </summary>
        public static List <ComConfig> GetComConfig()
        {
            try
            {
                List <ComConfig> ls = new List <ComConfig>();

                List <string> strName               = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComName"), ';', true);
                List <string> strBaudRate           = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComBaudRate"), ';', false);
                List <string> strParity             = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComParity"), ';', false);
                List <string> strStopBits           = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComStopBits"), ';', false);
                List <string> strComTimeout         = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComTimeout"), ';', false);
                List <string> strRefreshPeriod      = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComRefreshPeriod"), ';', false);
                List <string> strConnectCheckPeriod = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComConnectCheckPeriod"), ';', false);
                List <string> strComInterFrameGap   = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComInterFrameGap"), ';', false);
                List <string> strDeviceID           = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComDeviceID"), ';', false);
                List <string> strDeviceType         = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComDeviceType"), ';', true);

                List <int> baudrate = new List <int>();
                foreach (string str in strBaudRate)
                {
                    baudrate.Add(int.Parse(str));
                }

                List <Parity> parity = new List <Parity>();
                foreach (string str in strParity)
                {
                    parity.Add(((Parity)(int.Parse(str))));
                }

                List <StopBits> stop = new List <StopBits>();
                foreach (string str in strStopBits)
                {
                    stop.Add(((StopBits)(int.Parse(str))));
                }

                for (int i = 0; i < strName.Count; i++)
                {
                    ComConfig cc = new ComConfig();

                    cc.ComPort            = new SerialPort(strName[i], baudrate[i], parity[i], 8, stop[i]);
                    cc.Timeout            = int.Parse(strComTimeout[i]);
                    cc.RefreshPeriod      = int.Parse(strRefreshPeriod[i]);
                    cc.ConnectCheckPeriod = int.Parse(strConnectCheckPeriod[i]);
                    cc.InterFrameGap      = int.Parse(strComInterFrameGap[i]);

                    Log.InfoFormat("解析串口线路配置信息:{0},{1},{2},{3},刷新周期{4}(ms),连接检测周期{5}(ms),超时{6}(ms),帧间隙{7}(ms)",
                                   cc.ComPort.PortName, cc.ComPort.BaudRate, cc.ComPort.Parity.ToString(),
                                   cc.ComPort.StopBits.ToString(), cc.RefreshPeriod, cc.ConnectCheckPeriod,
                                   cc.Timeout, cc.InterFrameGap);

                    cc.Device = new Dictionary <byte, string>();

                    List <string> deviceID   = StringPlus.GetStrArray(strDeviceID[i], ',', false);
                    List <string> deviceType = StringPlus.GetStrArray(strDeviceType[i], ',', false);

                    for (int j = 0; j < deviceID.Count; j++)
                    {
                        cc.Device.Add(byte.Parse(deviceID[j]), deviceType[j]);
                        Log.InfoFormat("解析串口线路配置信息:设备通讯地址[{0}],类型[{1}]", deviceID[j], deviceType[j]);
                    }
                    ls.Add(cc);
                }
                return(ls);
            }
            catch (System.Exception ex)
            {
                string str = "解析串口线路配置信息出错,程序无法继续执行: " + ex.Message;
                Log.Fatal(str);
                throw new Exception(str);
            }
        }
Exemple #17
0
        /// <summary>
        /// �õ��޸Ĵ���Ĵ���
        /// </summary>       
        public string GetUpdateShowAspxCs()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendLine();
            string key = Key;
            strclass.AppendSpaceLine(1, "private void ShowInfo(" + Maticsoft.CodeHelper.CodeCommon.GetInParameter(Keys, true) + ")");
            strclass.AppendSpaceLine(1, "{");
            strclass.AppendSpaceLine(2, BLLSpace + " bll=new " + BLLSpace + "();");
            strclass.AppendSpaceLine(2, ModelSpace + " model=bll.GetModel(" + Maticsoft.CodeHelper.CodeCommon.GetFieldstrlist(Keys, true) + ");");
            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;

                if (isFilterColume(columnName))
                {
                    continue;
                }

                //���Զ���-�����ֶδ���
                //if ((columnName.IndexOf("_cLang") > 0) && (columnType.Trim().ToLower() == "varchar"))
                //{
                //    strclass.AppendSpaceLine(2, "UCDroplistLanguage1.LanguageCode =model." + columnName + ";");
                //    continue;
                //}
                //if (columnName.IndexOf("_iAuthority") > 0)
                //{
                //    strclass.AppendSpaceLine(2, "UCDroplistPermission1.PermissionID =model." + columnName + ";");
                //    continue;
                //}
                //if (columnName.IndexOf("_cCurrency") > 0)//���Ҵ���
                //{
                //    strclass.AppendSpaceLine(2, "UCDroplistCurrency1.CurrencyCode =model." + columnName + ";");
                //    continue;
                //}
                //if (columnName.IndexOf("_cCurrencyUnit") > 0)//���Ҵ���
                //{
                //    strclass.AppendSpaceLine(2, "UCDroplistCurrencyUnit1.CurrencyUnitID =model." + columnName + ";");
                //    continue;
                //}

                switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
                {
                    case "int":
                    case "long":
                    case "smallint":
                    case "float":
                    case "numeric":
                    case "decimal":
                    case "datetime":
                    case "smalldatetime":
                        if ((ispk) || (IsIdentity))
                        {
                            strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text=model." + columnName + ".ToString();");
                        }
                        else
                        {
                            strclass.AppendSpaceLine(2, "this.txt" + columnName + ".Text=model." + columnName + ".ToString();");
                        }
                        break;
                    case "bool":
                        strclass.AppendSpaceLine(2, "this.chk" + columnName + ".Checked=model." + columnName + ";");
                        break;
                    case "byte[]":
                        strclass.AppendSpaceLine(2, "this.txt" + columnName + ".Text=model." + columnName + ".ToString();");
                        break;
                    case "guid":
                    case "uniqueidentifier":
                        strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text=model." + columnName + ".ToString();");
                        break;
                    default:
                        if ((ispk) || (IsIdentity))
                        {
                            strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text=model." + columnName + ";");
                        }
                        else
                        {
                            strclass.AppendSpaceLine(2, "this.txt" + columnName + ".Text=model." + columnName + ";");
                        }
                        break;
                }
            }
            strclass.AppendLine();
            strclass.AppendSpaceLine(1, "}");
            return strclass.Value;
        }
Exemple #18
0
        /// <summary>
        /// �õ��޸Ĵ���Ĵ���
        /// </summary>      
        public string GetUpdateAspxCs()
        {
            StringPlus strclass = new StringPlus();
            StringPlus strclass0 = new StringPlus();
            StringPlus strclass1 = new StringPlus();
            StringPlus strclass2 = new StringPlus();
            strclass.AppendLine();
            strclass.AppendSpaceLine(3, "string strErr=\"\";");
            //bool ishasuser = false;
            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;

                //���Զ���-�����ֶδ���
                //if (
                //    (columnName.IndexOf("_iCreator") > 0) ||  //ҳ�治��Ҫ��2��
                //    (columnName.IndexOf("_dateCreate") > 0) ||
                //    (columnName.IndexOf("_bValid") > 0) ||
                //    (columnName.IndexOf("_dateValid") > 0) ||
                //    (columnName.IndexOf("_dateExpire") > 0)
                //    )
                //{
                //    continue;
                //}
                //if ((!ishasuser) && (columnName.IndexOf("_iMaintainer") > 0))
                //{
                //    strclass0.AppendSpaceLine(4, "User currentUser;");
                //    strclass0.AppendSpaceLine(3, "if (Session[\"UserInfo\"] != null)");
                //    strclass0.AppendSpaceLine(3, "{");
                //    strclass0.AppendSpaceLine(4, "currentUser = (User)Session[\"UserInfo\"];");
                //    strclass0.AppendSpaceLine(3, "}else{");
                //    strclass0.AppendSpaceLine(4, "return;");
                //    strclass0.AppendSpaceLine(3, "}");
                //    ishasuser = true;
                //}

                deText = Maticsoft.CodeHelper.CodeCommon.CutDescText(deText, 15, columnName);

                //���Զ���-�����ֶδ���
                //if ((columnName.IndexOf("_cLang") > 0) && (columnType.Trim().ToLower() == "varchar"))//���Դ���
                //{
                //    strclass2.AppendSpaceLine(3, "model." + columnName + "= UCDroplistLanguage1.LanguageCode;");
                //    continue;
                //}
                //if (columnName.IndexOf("_iAuthority") > 0)//Ȩ�޽�ɫ����
                //{
                //    strclass2.AppendSpaceLine(3, "model." + columnName + "= UCDroplistPermission1.PermissionID;");
                //    continue;
                //}
                //if (columnName.IndexOf("_cCurrency") > 0)//���Ҵ���
                //{
                //    strclass2.AppendSpaceLine(3, "model." + columnName + "= UCDroplistCurrency1.CurrencyCode;");
                //    continue;
                //}
                //if (columnName.IndexOf("_cCurrencyUnit") > 0)//���Ҵ���
                //{
                //    strclass2.AppendSpaceLine(3, "model." + columnName + "= UCDroplistCurrencyUnit1.CurrencyUnitID;");
                //    continue;
                //}

                switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
                {
                    case "int":
                    case "smallint":
                        if ((ispk) || (IsIdentity))
                        {
                            strclass0.AppendSpaceLine(3, "int " + columnName + "=int.Parse(this.lbl" + columnName + ".Text);");
                        }
                        else
                        {
                            strclass0.AppendSpaceLine(3, "int " + columnName + "=int.Parse(this.txt" + columnName + ".Text);");
                            strclass1.AppendSpaceLine(3, "if(!PageValidate.IsNumber(txt" + columnName + ".Text))");
                            strclass1.AppendSpaceLine(3, "{");
                            strclass1.AppendSpaceLine(4, "strErr+=\"" + deText + "��ʽ����\\\\n\";	");
                            strclass1.AppendSpaceLine(3, "}");
                        }
                        break;
                    case "long":
                        if ((ispk) || (IsIdentity))
                        {
                            strclass0.AppendSpaceLine(3, "long " + columnName + "=long.Parse(this.lbl" + columnName + ".Text);");
                        }
                        else
                        {
                            strclass0.AppendSpaceLine(3, "long " + columnName + "=long.Parse(this.txt" + columnName + ".Text);");
                            strclass1.AppendSpaceLine(3, "if(!PageValidate.IsNumber(txt" + columnName + ".Text))");
                            strclass1.AppendSpaceLine(3, "{");
                            strclass1.AppendSpaceLine(4, "strErr+=\"" + deText + "��ʽ����\\\\n\";	");
                            strclass1.AppendSpaceLine(3, "}");
                        }
                        break;
                    case "float":
                    case "numeric":
                    case "decimal":
                        if ((ispk) || (IsIdentity))
                        {
                            strclass0.AppendSpaceLine(3, "decimal " + columnName + "=decimal.Parse(this.lbl" + columnName + ".Text);");
                        }
                        else
                        {
                            strclass0.AppendSpaceLine(3, "decimal " + columnName + "=decimal.Parse(this.txt" + columnName + ".Text);");
                            strclass1.AppendSpaceLine(3, "if(!PageValidate.IsDecimal(txt" + columnName + ".Text))");
                            strclass1.AppendSpaceLine(3, "{");
                            strclass1.AppendSpaceLine(4, "strErr+=\"" + deText + "��ʽ����\\\\n\";	");
                            strclass1.AppendSpaceLine(3, "}");
                        }
                        break;
                    case "datetime":
                    case "smalldatetime":
                        strclass0.AppendSpaceLine(3, "DateTime " + columnName + "=DateTime.Parse(this.txt" + columnName + ".Text);");
                        strclass1.AppendSpaceLine(3, "if(!PageValidate.IsDateTime(txt" + columnName + ".Text))");
                        strclass1.AppendSpaceLine(3, "{");
                        strclass1.AppendSpaceLine(4, "strErr+=\"" + deText + "��ʽ����\\\\n\";	");
                        strclass1.AppendSpaceLine(3, "}");

                        break;
                    case "bool":
                        strclass0.AppendSpaceLine(3, "bool " + columnName + "=this.chk" + columnName + ".Checked;");
                        break;
                    case "byte[]":
                        strclass0.AppendSpaceLine(3, "byte[] " + columnName + "= new UnicodeEncoding().GetBytes(this.txt" + columnName + ".Text);");
                        break;
                    case "guid":
                    case "uniqueidentifier":
                        strclass0.AppendSpaceLine(3, "Guid " + columnName + "= new Guid(this.lbl" + columnName + ".Text);");
                        break;
                    default:
                        if ((ispk) || (IsIdentity))
                        {
                            strclass0.AppendSpaceLine(3, "string " + columnName + "=this.lbl" + columnName + ".Text;");
                        }
                        else
                        {
                            strclass0.AppendSpaceLine(3, "string " + columnName + "=this.txt" + columnName + ".Text;");
                            strclass1.AppendSpaceLine(3, "if(this.txt" + columnName + ".Text.Trim().Length==0)");
                            strclass1.AppendSpaceLine(3, "{");
                            strclass1.AppendSpaceLine(4, "strErr+=\"" + deText + "����Ϊ�գ�\\\\n\";	");
                            strclass1.AppendSpaceLine(3, "}");
                        }
                        break;
                }
                strclass2.AppendSpaceLine(3, "model." + columnName + "=" + columnName + ";");

            }
            strclass.AppendLine(strclass1.ToString());
            strclass.AppendSpaceLine(3, "if(strErr!=\"\")");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "MessageBox.Show(this,strErr);");
            strclass.AppendSpaceLine(4, "return;");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendLine(strclass0.ToString());
            strclass.AppendLine();
            strclass.AppendSpaceLine(3, ModelSpace + " model=new " + ModelSpace + "();");
            strclass.AppendLine(strclass2.ToString());
            strclass.AppendSpaceLine(3, BLLSpace + " bll=new " + BLLSpace + "();");
            strclass.AppendSpaceLine(3, "bll.Update(model);");
            strclass.AppendSpaceLine(3, "Maticsoft.Common.MessageBox.ShowAndRedirect(this,\"����ɹ���\",\"list.aspx\");");
            return strclass.ToString();
        }
Exemple #19
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.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();
        }
Exemple #20
0
        /// <summary>
        /// �õ���ʾ����ʾ�����html����
        /// </summary>     
        public string GetShowAspx()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendLine();
            strclass.AppendLine("<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\">");
            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);

                strclass.AppendSpaceLine(1, "<tr>");
                strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"30%\" align=\"right\">");
                strclass.AppendSpaceLine(2, deText);
                strclass.AppendSpaceLine(1, "��</td>");
                strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"*\" align=\"left\">");
                switch (columnType.Trim().ToLower())
                {
                    //case "bit":
                    //    strclass.AppendSpaceLine(2, "<asp:CheckBox ID=\"chk" + columnName + "\" Text=\"" + deText + "\" runat=\"server\" Checked=\"False\" />" );
                    //    break;
                    default:
                        strclass.AppendSpaceLine(2, "<asp:Label id=\"lbl" + columnName + "\" runat=\"server\"></asp:Label>");
                        break;
                }
                strclass.AppendSpaceLine(1, "</td></tr>");
            }
            strclass.AppendLine("</table>");
            return strclass.ToString();
        }
Exemple #21
0
 /// <summary>
 /// �õ�GetList()�Ĵ���
 /// </summary>
 /// <param name="_tablename"></param>
 /// <param name="_key"></param>
 /// <returns></returns>
 public string CreatGetListByPageProc()
 {
     StringPlus strclass = new StringPlus();
     strclass.AppendSpaceLine(2, "/*");
     //strclass.AppendSpaceLine(2, "/// <summary>");
     //strclass.AppendSpaceLine(2, "/// "+Languagelist["summaryGetList3"].ToString());
     //strclass.AppendSpaceLine(2, "/// </summary>");
     //strclass.AppendSpaceLine(2, "public DataSet GetList(int PageSize,int PageIndex,string strWhere)");
     //strclass.AppendSpaceLine(2, "{");
     //strclass.AppendSpaceLine(3, "" + DbParaHead + "Parameter[] parameters = {");
     //strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + "tblName\", " + DbParaDbType + ".VarChar, 255),");
     //strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + "fldName\", " + DbParaDbType + ".VarChar, 255),");
     //strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + "PageSize\", " + DbParaDbType + "." + CodeCommon.CSToProcType(dbobj.DbType, "int") + "),");
     //strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + "PageIndex\", " + DbParaDbType + "." + CodeCommon.CSToProcType(dbobj.DbType, "int") + "),");
     //strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + "IsReCount\", " + DbParaDbType + "." + CodeCommon.CSToProcType(dbobj.DbType, "bit") + "),");
     //strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + "OrderType\", " + DbParaDbType + "." + CodeCommon.CSToProcType(dbobj.DbType, "bit") + "),");
     //strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + "strWhere\", " + DbParaDbType + ".VarChar,1000),");
     //strclass.AppendSpaceLine(5, "};");
     //strclass.AppendSpaceLine(3, "parameters[0].Value = \"" + TableName + "\";");
     //strclass.AppendSpaceLine(3, "parameters[1].Value = \"" + _key + "\";");
     //strclass.AppendSpaceLine(3, "parameters[2].Value = PageSize;");
     //strclass.AppendSpaceLine(3, "parameters[3].Value = PageIndex;");
     //strclass.AppendSpaceLine(3, "parameters[4].Value = 0;");
     //strclass.AppendSpaceLine(3, "parameters[5].Value = 0;");
     //strclass.AppendSpaceLine(3, "parameters[6].Value = strWhere;	");
     //strclass.AppendSpaceLine(3, "return " + DbHelperName + ".RunProcedure(\"UP_GetRecordByPage\",parameters,\"ds\");");
     //strclass.AppendSpaceLine(2, "}");
     strclass.AppendSpaceLine(2, "*/");
     return strclass.Value;
 }
Exemple #22
0
        /// <summary>
        /// �õ���ҳ�����Ĵ���
        /// </summary>        
        public string CreatGetListByPage()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// " + Languagelist["GetRecordCount"].ToString());
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public int GetRecordCount(string strWhere)");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
            strclass.AppendSpaceLine(3, "strSql.Append(\"select count(1) FROM " + TableName + " \");");
            strclass.AppendSpaceLine(3, "if(strWhere.Trim()!=\"\")");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "strSql.Append(\" where \"+strWhere);");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "object obj = DbHelperSQL.GetSingle(strSql.ToString());");
            strclass.AppendSpaceLine(3, "if (obj == null)");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "return 0;");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "else");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "return Convert.ToInt32(obj);");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(2, "}");

            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryGetList3"].ToString());
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
            strclass.AppendSpaceLine(3, "strSql.Append(\"SELECT * FROM ( \");");
            strclass.AppendSpaceLine(3, "strSql.Append(\" SELECT ROW_NUMBER() OVER (\");");
            strclass.AppendSpaceLine(3, "if (!string.IsNullOrEmpty(orderby.Trim()))");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "strSql.Append(\"order by T.\" + orderby );");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "else");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "strSql.Append(\"order by T." + _IdentityKey + " desc\");");
            strclass.AppendSpaceLine(3, "}");

            strclass.AppendSpaceLine(3, "strSql.Append(\")AS Row, T.*  from " + TableName + " T \");");
            strclass.AppendSpaceLine(3, "if (!string.IsNullOrEmpty(strWhere.Trim()))");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "strSql.Append(\" WHERE \" + strWhere);");
            strclass.AppendSpaceLine(3, "}");

            strclass.AppendSpaceLine(3, "strSql.Append(\" ) TT\");");
            strclass.AppendSpaceLine(3, "strSql.AppendFormat(\" WHERE TT.Row between {0} and {1}\", startIndex, endIndex);");

            strclass.AppendSpaceLine(3, "return " + DbHelperName + ".Query(strSql.ToString());");
            strclass.AppendSpaceLine(2, "}");

            return strclass.Value;
        }
Exemple #23
0
        /// <summary>
        /// �õ�GetList()�Ĵ���
        /// </summary>
        /// <param name="_tablename"></param>
        /// <param name="_key"></param>
        /// <returns></returns>
        public string CreatGetList()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryGetList"].ToString());
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public DataSet GetList(string strWhere)");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
            strclass.AppendSpace(3, "strSql.Append(\"select ");
            strclass.AppendLine(Fieldstrlist + " \");");
            strclass.AppendSpaceLine(3, "strSql.Append(\" FROM " + TableName + " \");");
            strclass.AppendSpaceLine(3, "if(strWhere.Trim()!=\"\")");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "strSql.Append(\" where \"+strWhere);");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "return " + DbHelperName + ".Query(strSql.ToString());");
            strclass.AppendSpaceLine(2, "}");

            if ((dbobj.DbType == "SQL2000") ||
                (dbobj.DbType == "SQL2005") ||
                (dbobj.DbType == "SQL2008") ||
                (dbobj.DbType == "SQL2012"))
            {
                strclass.AppendLine();
                strclass.AppendSpaceLine(2, "/// <summary>");
                strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryGetList2"].ToString());
                strclass.AppendSpaceLine(2, "/// </summary>");
                strclass.AppendSpaceLine(2, "public DataSet GetList(int Top,string strWhere,string filedOrder)");
                strclass.AppendSpaceLine(2, "{");
                strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
                strclass.AppendSpaceLine(3, "strSql.Append(\"select \");");
                strclass.AppendSpaceLine(3, "if(Top>0)");
                strclass.AppendSpaceLine(3, "{");
                strclass.AppendSpaceLine(4, "strSql.Append(\" top \"+Top.ToString());");
                strclass.AppendSpaceLine(3, "}");
                strclass.AppendSpaceLine(3, "strSql.Append(\" " + Fieldstrlist + " \");");
                strclass.AppendSpaceLine(3, "strSql.Append(\" FROM " + TableName + " \");");
                strclass.AppendSpaceLine(3, "if(strWhere.Trim()!=\"\")");
                strclass.AppendSpaceLine(3, "{");
                strclass.AppendSpaceLine(4, "strSql.Append(\" where \"+strWhere);");
                strclass.AppendSpaceLine(3, "}");
                strclass.AppendSpaceLine(3, "strSql.Append(\" order by \" + filedOrder);");
                strclass.AppendSpaceLine(3, "return " + DbHelperName + ".Query(strSql.ToString());");
                strclass.AppendSpaceLine(2, "}");
            }

            //����List<>
            strclass.AppendLine(); // ���峬 2015-10-13
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryGetList"].ToString());
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public List<" + ModelSpace + "> GetModelList(string strWhere)");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "DataSet ds = GetList(strWhere);");
            strclass.AppendSpaceLine(3, "return DataTableToList(ds.Tables[0]);");
            strclass.AppendSpaceLine(2, "}");

            //����List<>
            strclass.AppendLine();// ���峬 2015-10-13
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryGetList"].ToString());
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public List<" + ModelSpace + "> DataTableToList(DataTable dt)");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "List<" + ModelSpace + "> modelList = new List<" + ModelSpace + ">();");
            strclass.AppendSpaceLine(3, "int rowsCount = dt.Rows.Count;");
            strclass.AppendSpaceLine(3, "if (rowsCount > 0)");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, ModelSpace + " model;");
            strclass.AppendSpaceLine(4, "for (int n = 0; n < rowsCount; n++)");
            strclass.AppendSpaceLine(4, "{");
            strclass.AppendSpaceLine(5, "model = DataRowToModel(dt.Rows[n]);");
            strclass.AppendSpaceLine(5, "if (model != null)");
            strclass.AppendSpaceLine(5, "{");
            strclass.AppendSpaceLine(6, "modelList.Add(model);");
            strclass.AppendSpaceLine(5, "}");
            strclass.AppendSpaceLine(4, "}");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "return modelList;");
            strclass.AppendSpaceLine(2, "}");

            return strclass.Value;
        }
Exemple #24
0
 /// <summary>
 /// �õ�Exists�����Ĵ���
 /// </summary>
 /// <param name="_tablename"></param>
 /// <param name="ID"></param>
 /// <returns></returns>
 public string CreatExists()
 {
     StringPlus strclass = new StringPlus();
     if (_keys.Count > 0)
     {
         string strInparam = Maticsoft.CodeHelper.CodeCommon.GetInParameter(Keys, false);
         if (!string.IsNullOrEmpty(strInparam))
         {
             strclass.AppendLine("");
             strclass.AppendSpaceLine(2, "/// <summary>");
             strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryExists"].ToString());
             strclass.AppendSpaceLine(2, "/// </summary>");
             strclass.AppendSpaceLine(2, "public bool Exists(" + strInparam + ")");
             strclass.AppendSpaceLine(2, "{");
             strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
             strclass.AppendSpaceLine(3, "strSql.Append(\"select count(1) from " + _tablename + "\");");
             strclass.AppendSpaceLine(3, "strSql.Append(\" where " + Maticsoft.CodeHelper.CodeCommon.GetWhereExpression(Keys, false) + "\");");
             strclass.AppendSpaceLine(3, "return " + DbHelperName + ".Exists(strSql.ToString());");
             strclass.AppendSpace(2, "}");
         }
     }
     return strclass.ToString();
 }
Exemple #25
0
        /// <summary>
        /// �õ�Delete�Ĵ���
        /// </summary>
        /// <param name="_tablename"></param>
        /// <param name="_key"></param>
        /// <returns></returns>
        public string CreatDelete()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendLine("");
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryDelete"].ToString());
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public bool Delete(" + Maticsoft.CodeHelper.CodeCommon.GetInParameter(Keys, true) + ")");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
            //if (dbobj.DbType != "OleDb")
            //{
            //    strclass.AppendSpaceLine(3, "strSql.Append(\"delete " + _tablename + " \");" );
            //}
            //else
            //{
            strclass.AppendSpaceLine(3, "strSql.Append(\"delete from " + _tablename + " \");");
            //}
            strclass.AppendSpaceLine(3, "strSql.Append(\" where " + Maticsoft.CodeHelper.CodeCommon.GetWhereExpression(Keys, true) + "\" );");

            strclass.AppendSpaceLine(3, "int rowsAffected=" + DbHelperName + ".ExecuteSql(strSql.ToString());");

            strclass.AppendSpaceLine(3, "if (rowsAffected > 0)");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "return true;");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "else");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "return false;");
            strclass.AppendSpaceLine(3, "}");

            strclass.AppendSpace(2, "}");

            #region �����������ȵ�ɾ��(���б�ʶ�ֶΣ����зDZ�ʶ�����ֶ�)

            if ((Maticsoft.CodeHelper.CodeCommon.HasNoIdentityKey(Keys)) && (Maticsoft.CodeHelper.CodeCommon.GetIdentityKey(Keys) != null))
            {
                strclass.AppendSpaceLine(2, "/// <summary>");
                strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryDelete"].ToString());
                strclass.AppendSpaceLine(2, "/// </summary>");
                strclass.AppendSpaceLine(2, "public bool Delete(" + Maticsoft.CodeHelper.CodeCommon.GetInParameter(Keys, false) + ")");
                strclass.AppendSpaceLine(2, "{");
                strclass.AppendSpaceLine(3, KeysNullTip);
                strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
                strclass.AppendSpaceLine(3, "strSql.Append(\"delete from " + _tablename + " \");");
                strclass.AppendSpaceLine(3, "strSql.Append(\" where " + GetWhereExpression(Keys, false) + "\");");
                strclass.AppendLine(GetPreParameter(Keys, false));

                strclass.AppendSpaceLine(3, "int rows=" + DbHelperName + ".ExecuteSql(strSql.ToString(),parameters);");
                strclass.AppendSpaceLine(3, "if (rows > 0)");
                strclass.AppendSpaceLine(3, "{");
                strclass.AppendSpaceLine(4, "return true;");
                strclass.AppendSpaceLine(3, "}");
                strclass.AppendSpaceLine(3, "else");
                strclass.AppendSpaceLine(3, "{");
                strclass.AppendSpaceLine(4, "return false;");
                strclass.AppendSpaceLine(3, "}");

                strclass.AppendSpaceLine(2, "}");
            }

            #endregion

            #region ����ɾ������

            string keyField = "";
            if (Keys.Count == 1)
            {
                keyField = Keys[0].ColumnName;
            }
            else
            {
                foreach (ColumnInfo field in Keys)
                {
                    if (field.IsIdentity)
                    {
                        keyField = field.ColumnName;
                        break;
                    }
                }
            }
            if (keyField.Trim().Length > 0)
            {
                strclass.AppendSpaceLine(2, "/// <summary>");
                strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryDeletelist"].ToString());
                strclass.AppendSpaceLine(2, "/// </summary>");
                strclass.AppendSpaceLine(2, "public bool DeleteList(string " + keyField + "list )");
                strclass.AppendSpaceLine(2, "{");
                strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
                strclass.AppendSpaceLine(3, "strSql.Append(\"delete from " + _tablename + " \");");
                strclass.AppendSpaceLine(3, "strSql.Append(\" where " + keyField + " in (\"+" + keyField + "list + \")  \");");
                strclass.AppendSpaceLine(3, "int rows=" + DbHelperName + ".ExecuteSql(strSql.ToString());");
                strclass.AppendSpaceLine(3, "if (rows > 0)");
                strclass.AppendSpaceLine(3, "{");
                strclass.AppendSpaceLine(4, "return true;");
                strclass.AppendSpaceLine(3, "}");
                strclass.AppendSpaceLine(3, "else");
                strclass.AppendSpaceLine(3, "{");
                strclass.AppendSpaceLine(4, "return false;");
                strclass.AppendSpaceLine(3, "}");
                strclass.AppendSpaceLine(2, "}");
            }
            #endregion

            return strclass.ToString();
        }
Exemple #26
0
        /// <summary>
        /// DataRowToModel�Ĵ���
        /// </summary>      
        public string CreatDataRowToModel()
        {
            if (ModelSpace == "")
            {
                //ModelSpace = "ModelClassName"; ;
            }
            StringPlus strclass = new StringPlus();
            strclass.AppendLine();
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryGetModel"].ToString());
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public " + ModelSpace + " DataRowToModel(DataRow row)");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "" + ModelSpace + " model=new " + ModelSpace + "();");

            strclass.AppendSpaceLine(3, "if (row != null)");
            strclass.AppendSpaceLine(3, "{");

            #region �ֶθ�ֵ
            foreach (ColumnInfo field in Fieldlist)
            {
                string columnName = field.ColumnName;
                string columnType = field.TypeName;

                //strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null && row[\"" + columnName + "\"].ToString()!=\"\")");
                //strclass.AppendSpaceLine(4, "{");
                #region
                switch (CodeCommon.DbTypeToCS(columnType))
                {
                    case "int":
                        {
                            strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null && row[\"" + columnName + "\"].ToString()!=\"\")");
                            strclass.AppendSpaceLine(4, "{");
                            strclass.AppendSpaceLine(5, "model." + columnName + "=int.Parse(row[\"" + columnName + "\"].ToString());");
                            strclass.AppendSpaceLine(4, "}");
                        }
                        break;
                    case "long":
                        {
                            strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null && row[\"" + columnName + "\"].ToString()!=\"\")");
                            strclass.AppendSpaceLine(4, "{");
                            strclass.AppendSpaceLine(5, "model." + columnName + "=long.Parse(row[\"" + columnName + "\"].ToString());");
                            strclass.AppendSpaceLine(4, "}");
                        }
                        break;
                    case "decimal":
                        {
                            strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null && row[\"" + columnName + "\"].ToString()!=\"\")");
                            strclass.AppendSpaceLine(4, "{");
                            strclass.AppendSpaceLine(5, "model." + columnName + "=decimal.Parse(row[\"" + columnName + "\"].ToString());");
                            strclass.AppendSpaceLine(4, "}");
                        }
                        break;
                    case "float":
                        {
                            strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null && row[\"" + columnName + "\"].ToString()!=\"\")");
                            strclass.AppendSpaceLine(4, "{");
                            strclass.AppendSpaceLine(5, "model." + columnName + "=float.Parse(row[\"" + columnName + "\"].ToString());");
                            strclass.AppendSpaceLine(4, "}");
                        }
                        break;
                    case "DateTime":
                        {
                            strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null && row[\"" + columnName + "\"].ToString()!=\"\")");
                            strclass.AppendSpaceLine(4, "{");
                            strclass.AppendSpaceLine(5, "model." + columnName + "=DateTime.Parse(row[\"" + columnName + "\"].ToString());");
                            strclass.AppendSpaceLine(4, "}");
                        }
                        break;
                    case "string":
                        {
                            strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null)");
                            strclass.AppendSpaceLine(4, "{");
                            strclass.AppendSpaceLine(5, "model." + columnName + "=row[\"" + columnName + "\"].ToString();");
                            strclass.AppendSpaceLine(4, "}");
                        }
                        break;
                    case "bool":
                        {
                            strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null && row[\"" + columnName + "\"].ToString()!=\"\")");
                            strclass.AppendSpaceLine(4, "{");
                            strclass.AppendSpaceLine(5, "if((row[\"" + columnName + "\"].ToString()==\"1\")||(row[\"" + columnName + "\"].ToString().ToLower()==\"true\"))");
                            strclass.AppendSpaceLine(5, "{");
                            strclass.AppendSpaceLine(6, "model." + columnName + "=true;");
                            strclass.AppendSpaceLine(5, "}");
                            strclass.AppendSpaceLine(5, "else");
                            strclass.AppendSpaceLine(5, "{");
                            strclass.AppendSpaceLine(6, "model." + columnName + "=false;");
                            strclass.AppendSpaceLine(5, "}");
                            strclass.AppendSpaceLine(4, "}");
                        }
                        break;
                    case "byte[]":
                        {
                            strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null && row[\"" + columnName + "\"].ToString()!=\"\")");
                            strclass.AppendSpaceLine(4, "{");
                            strclass.AppendSpaceLine(5, "model." + columnName + "=(byte[])row[\"" + columnName + "\"];");
                            strclass.AppendSpaceLine(4, "}");
                        }
                        break;
                    case "uniqueidentifier":
                    case "Guid":
                        {
                            strclass.AppendSpaceLine(4, "if(row[\"" + columnName + "\"]!=null && row[\"" + columnName + "\"].ToString()!=\"\")");
                            strclass.AppendSpaceLine(4, "{");
                            strclass.AppendSpaceLine(5, "model." + columnName + "= new Guid(row[\"" + columnName + "\"].ToString());");
                            strclass.AppendSpaceLine(4, "}");
                        }
                        break;
                    default:
                        strclass.AppendSpaceLine(5, "//model." + columnName + "=row[\"" + columnName + "\"].ToString();");
                        break;
                }
                #endregion
                //strclass.AppendSpaceLine(4, "}");
            }
            #endregion

            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "return model;");
            strclass.AppendSpaceLine(2, "}");
            return strclass.ToString();
        }
Exemple #27
0
        /// <summary>
        /// �õ�Add()�Ĵ���
        /// </summary>        
        public string CreatAdd()
        {
            if (ModelSpace == "")
            {
                //ModelSpace = "ModelClassName"; ;
            }
            StringPlus strclass = new StringPlus();
            strclass.AppendLine("");
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// " + Languagelist["summaryadd"].ToString());
            strclass.AppendSpaceLine(2, "/// </summary>");
            string strretu = "bool";
            if ((dbobj.DbType == "SQL2000" || dbobj.DbType == "SQL2005" ||
                dbobj.DbType == "SQL2008" || dbobj.DbType == "SQL2012" || dbobj.DbType == "SQLite") && (IsHasIdentity))
            {
                strretu = "int";
                if (_IdentityKeyType != "int")
                {
                    strretu = _IdentityKeyType;
                }
            }
            //if (dbobj.DbType == "OleDb" && IsHasIdentity)
            //{
            //    strretu = "bool";
            //}

            //��������ͷ
            string strFun = CodeCommon.Space(2) + "public " + strretu + " Add(" + ModelSpace + " model)";
            strclass.AppendLine(strFun);
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
            strclass.AppendSpaceLine(3, "StringBuilder strSql1=new StringBuilder();");
            strclass.AppendSpaceLine(3, "StringBuilder strSql2=new StringBuilder();");
            foreach (ColumnInfo field in Fieldlist)
            {
                string columnName = field.ColumnName;
                string columnType = field.TypeName;
                bool IsIdentity = field.IsIdentity;

                if (IsIdentity)
                {
                    continue;
                }
                strclass.AppendSpaceLine(3, "if (model." + columnName + " != null)");
                strclass.AppendSpaceLine(3, "{");
                strclass.AppendSpaceLine(4, "strSql1.Append(\"" + columnName + ",\");");
                if ((dbobj.DbType == "Oracle") && (columnType.ToLower() == "date" || columnType.ToLower() == "datetime"))
                {
                    strclass.AppendSpaceLine(4, "strSql2.Append(\"to_date('\" + model." + columnName + ".ToString() + \"','YYYY-MM-DD HH24:MI:SS'),\");");
                }
                else
                    if (columnType.ToLower() == "bit")
                    {
                        strclass.AppendSpaceLine(4, "strSql2.Append(\"\"+(model." + columnName + "? 1 : 0) +\",\");");
                    }
                    else
                        if ("uniqueidentifier" == columnType.ToLower())
                        {
                            strclass.AppendSpaceLine(4, "strSql2.Append(\"'\"+ Guid.NewGuid().ToString() +\"',\");");
                        }
                        else
                            if (CodeCommon.IsAddMark(columnType.Trim()))
                            {
                                strclass.AppendSpaceLine(4, "strSql2.Append(\"'\"+model." + columnName + "+\"',\");");
                            }
                            else
                            {
                                strclass.AppendSpaceLine(4, "strSql2.Append(\"\"+model." + columnName + "+\",\");");
                            }

                strclass.AppendSpaceLine(3, "}");
            }
            strclass.AppendSpaceLine(3, "strSql.Append(\"insert into " + TableName + "(\");");
            strclass.AppendSpaceLine(3, "strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));");
            strclass.AppendSpaceLine(3, "strSql.Append(\")\");");
            strclass.AppendSpaceLine(3, "strSql.Append(\" values (\");");
            strclass.AppendSpaceLine(3, "strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));");
            strclass.AppendSpaceLine(3, "strSql.Append(\")\");");

            if (strretu == "void")
            {
                strclass.AppendSpaceLine(3, "" + DbHelperName + ".ExecuteSql(strSql.ToString());");
            }
            else
                if (strretu == "bool")
                {
                    strclass.AppendSpaceLine(3, "int rows=" + DbHelperName + ".ExecuteSql(strSql.ToString());");
                    strclass.AppendSpaceLine(3, "if (rows > 0)");
                    strclass.AppendSpaceLine(3, "{");
                    strclass.AppendSpaceLine(4, "return true;");
                    strclass.AppendSpaceLine(3, "}");
                    strclass.AppendSpaceLine(3, "else");
                    strclass.AppendSpaceLine(3, "{");
                    strclass.AppendSpaceLine(4, "return false;");
                    strclass.AppendSpaceLine(3, "}");
                }
                else//�����Զ�������ֵ
                {
                    if ((dbobj.DbType == "SQL2000" || dbobj.DbType == "SQL2005"
                        || dbobj.DbType == "SQL2008" || dbobj.DbType == "SQL2012") && (IsHasIdentity))
                    {
                        strclass.AppendSpaceLine(3, "strSql.Append(\";select @@IDENTITY\");");
                    }
                    if ((dbobj.DbType == "SQLite") && (IsHasIdentity))
                    {
                        strclass.AppendSpaceLine(3, "strSql.Append(\";select LAST_INSERT_ROWID()\");");
                    }
                    strclass.AppendSpaceLine(3, "object obj = " + DbHelperName + ".GetSingle(strSql.ToString());");
                    strclass.AppendSpaceLine(3, "if (obj == null)");
                    strclass.AppendSpaceLine(3, "{");
                    strclass.AppendSpaceLine(4, "return 0;");
                    strclass.AppendSpaceLine(3, "}");
                    strclass.AppendSpaceLine(3, "else");
                    strclass.AppendSpaceLine(3, "{");
                    switch (strretu)
                    {
                        case "int":
                            strclass.AppendSpaceLine(4, "return Convert.ToInt32(obj);");
                            break;
                        case "long":
                            strclass.AppendSpaceLine(4, "return Convert.ToInt64(obj);");
                            break;
                        case "decimal":
                            strclass.AppendSpaceLine(4, "return Convert.ToDecimal(obj);");
                            break;
                    }
                    strclass.AppendSpaceLine(3, "}");
                }
            strclass.AppendSpace(2, "}");
            return strclass.ToString();
        }
Exemple #28
0
 /// <summary>
 /// �õ�Where������� - Parameter��ʽ (���磺����Exists  Delete  GetModel ��where)
 /// </summary>
 /// <param name="keys"></param>
 /// <returns></returns>
 public string GetWhereExpression(List<ColumnInfo> keys, bool IdentityisPrior)
 {
     StringPlus strClass = new StringPlus();
     ColumnInfo field = Maticsoft.CodeHelper.CodeCommon.GetIdentityKey(keys);
     if ((IdentityisPrior) && (field != null)) //�б�ʶ�ֶ�
     {
         strClass.Append(field.ColumnName + "=" + preParameter + field.ColumnName);
     }
     else
     {
         foreach (ColumnInfo key in keys)
         {
             if (key.IsPrimaryKey)
             {
                 strClass.Append(key.ColumnName + "=" + preParameter + key.ColumnName + " and ");
             }
         }
         strClass.DelLastChar("and");
     }
     return strClass.Value;
 }
        private string BuilderMethod()
        {
            StringPlus plus = new StringPlus();


            plus.AppendSpaceLine(2, "#region Method");


            //只读
            if (IsView)
            {
                plus.AppendSpaceLine(2, "/// <summary>");
                plus.AppendSpaceLine(2, "/// 是否只读");
                plus.AppendSpaceLine(2, "/// </summary>");
                plus.AppendSpaceLine(2, "public override bool IsReadOnly()");
                plus.AppendSpaceLine(2, "{");
                plus.AppendSpaceLine(3, "return true;");
                plus.AppendSpaceLine(2, "}");
            }

            Model.ColumnInfo identityColumn = Columns.Find(delegate(Model.ColumnInfo col) { return col.IsIdentity; });
            if (null != identityColumn)
            {
                plus.AppendSpaceLine(2, "/// <summary>");
                plus.AppendSpaceLine(2, "/// 获取实体中的标识列");
                plus.AppendSpaceLine(2, "/// </summary>");
                plus.AppendSpaceLine(2, "public override Field GetIdentityField()");
                plus.AppendSpaceLine(2, "{");
                plus.AppendSpaceLine(3, "return _." + identityColumn.ColumnName + ";");
                plus.AppendSpaceLine(2, "}");
            }

            List<Model.ColumnInfo> primarykeyColumns = Columns.FindAll(delegate(Model.ColumnInfo col) { return col.IsPK; });
            if (null != primarykeyColumns && primarykeyColumns.Count > 0)
            {
                plus.AppendSpaceLine(2, "/// <summary>");
                plus.AppendSpaceLine(2, "/// 获取实体中的主键列");
                plus.AppendSpaceLine(2, "/// </summary>");
                plus.AppendSpaceLine(2, "public override Field[] GetPrimaryKeyFields()");
                plus.AppendSpaceLine(2, "{");
                plus.AppendSpaceLine(3, "return new Field[] {");
                StringPlus plus2 = new StringPlus();
                foreach (Model.ColumnInfo col in primarykeyColumns)
                {
                    plus2.AppendSpaceLine(4, "_." + col.ColumnName + ",");
                }
                plus.Append(plus2.ToString().TrimEnd().Substring(0, plus2.ToString().TrimEnd().Length - 1));
                plus.AppendLine("};");
                plus.AppendSpaceLine(2, "}");
            }



            plus.AppendSpaceLine(2, "/// <summary>");
            plus.AppendSpaceLine(2, "/// 获取列信息");
            plus.AppendSpaceLine(2, "/// </summary>");
            plus.AppendSpaceLine(2, "public override Field[] GetFields()");
            plus.AppendSpaceLine(2, "{");
            plus.AppendSpaceLine(3, "return new Field[] {");
            StringPlus plus3 = new StringPlus();
            foreach (ColumnInfo col in Columns)
            {
                plus3.AppendSpaceLine(4, "_." + col.ColumnName + ",");
            }
            plus.Append(plus3.ToString().TrimEnd().Substring(0, plus3.ToString().TrimEnd().Length - 1));
            plus.AppendLine("};");
            plus.AppendSpaceLine(2, "}");


            plus.AppendSpaceLine(2, "/// <summary>");
            plus.AppendSpaceLine(2, "/// 获取值信息");
            plus.AppendSpaceLine(2, "/// </summary>");
            plus.AppendSpaceLine(2, "public override object[] GetValues()");
            plus.AppendSpaceLine(2, "{");
            plus.AppendSpaceLine(3, "return new object[] {");
            StringPlus plus4 = new StringPlus();
            foreach (ColumnInfo col in Columns)
            {
                plus4.AppendSpaceLine(4, "this._" + col.ColumnName + ",");
            }
            plus.Append(plus4.ToString().TrimEnd().Substring(0, plus4.ToString().TrimEnd().Length - 1));
            plus.AppendLine("};");
            plus.AppendSpaceLine(2, "}");

            //2015-08-10注释
            //plus.AppendSpaceLine(2, "/// <summary>");
            //plus.AppendSpaceLine(2, "/// 给当前实体赋值");
            //plus.AppendSpaceLine(2, "/// </summary>");
            //plus.AppendSpaceLine(2, "public override void SetPropertyValues(IDataReader reader)");
            //plus.AppendSpaceLine(2, "{");
            //foreach (ColumnInfo col in Columns)
            //{
            //    plus.AppendSpaceLine(3, "this._" + col.ColumnName + " = DataUtils.ConvertValue<" + col.TypeName + ">(reader[\"" + col.ColumnNameRealName + "\"]);");
            //}
            //plus.AppendSpaceLine(2, "}");


            //2015-08-10注释
            //plus.AppendSpaceLine(2, "/// <summary>");
            //plus.AppendSpaceLine(2, "/// 给当前实体赋值");
            //plus.AppendSpaceLine(2, "/// </summary>");
            //plus.AppendSpaceLine(2, "public override void SetPropertyValues(DataRow row)");
            //plus.AppendSpaceLine(2, "{");
            //foreach (ColumnInfo col in Columns)
            //{
            //    plus.AppendSpaceLine(3, "this._" + col.ColumnName + " = DataUtils.ConvertValue<" + col.TypeName + ">(row[\"" + col.ColumnNameRealName + "\"]);");
            //}
            //plus.AppendSpaceLine(2, "}");


            plus.AppendSpaceLine(2, "#endregion");
            plus.AppendLine();



            plus.AppendSpaceLine(2, "#region _Field");
            plus.AppendSpaceLine(2, "/// <summary>");
            plus.AppendSpaceLine(2, "/// 字段信息");
            plus.AppendSpaceLine(2, "/// </summary>");
            plus.AppendSpaceLine(2, "public class _");
            plus.AppendSpaceLine(2, "{");
            plus.AppendSpaceLine(3, "/// <summary>");
            plus.AppendSpaceLine(3, "/// * ");
            plus.AppendSpaceLine(3, "/// </summary>");
            plus.AppendSpaceLine(3, "public readonly static Field All = new Field(\"*\",\"" + TableName + "\");");
            foreach (ColumnInfo col in Columns)
            {
                plus.AppendSpaceLine(3, "/// <summary>");
                plus.AppendSpaceLine(3, "/// " + col.DeText);
                plus.AppendSpaceLine(3, "/// </summary>");
                plus.AppendSpaceLine(3, "public readonly static Field " + col.ColumnName + " = new Field(\"" + col.ColumnNameRealName + "\",\"" + TableName + "\",\"" + (string.IsNullOrEmpty(col.DeText) ? col.ColumnNameRealName : col.DeText) + "\");");
            }
            plus.AppendSpaceLine(2, "}");
            plus.AppendSpaceLine(2, "#endregion");
            plus.AppendLine();

            return plus.ToString();


        }
Exemple #30
0
 /// <summary>
 /// �õ�ij�ֶ����ֵ�ķ�������(ֻ��������int�͵����������)
 /// </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 " + DbHelperName + ".GetMaxID(\"" + keyname + "\", \"" + _tablename + "\"); ");
                     strclass.AppendSpaceLine(2, "}");
                     break;
                 }
             }
         }
     }
     return strclass.ToString();
 }
Exemple #31
0
 /// <summary>
 /// �����html����
 /// </summary>     
 public string GetListDesigner()
 {
     StringPlus strclass = new StringPlus();
     return strclass.ToString();
 }
Exemple #32
0
        /// <summary>
        /// 得到修改窗体的代码
        /// </summary>
        public string GetUpdateShowAspxCs()
        {
            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;

                switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
                {
                case "int":
                case "smallint":
                case "float":
                case "numeric":
                case "decimal":
                case "datetime":
                case "smalldatetime":
                    if ((ispk) || (IsIdentity))
                    {
                        strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text=model." + columnName + ".ToString();");
                    }
                    else
                    {
                        strclass.AppendSpaceLine(2, "this.txt" + columnName + ".Text=model." + columnName + ".ToString();");
                    }
                    break;

                case "bool":
                    strclass.AppendSpaceLine(2, "this.chk" + columnName + ".Checked=model." + columnName + ";");
                    break;

                case "byte[]":
                    strclass.AppendSpaceLine(2, "this.txt" + columnName + ".Text=model." + columnName + ".ToString();");
                    break;

                default:
                    if ((ispk) || (IsIdentity))
                    {
                        strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text=model." + columnName + ";");
                    }
                    else
                    {
                        strclass.AppendSpaceLine(2, "this.txt" + columnName + ".Text=model." + columnName + ";");
                    }
                    break;
                }
            }
            strclass.AppendLine();
            strclass.AppendSpaceLine(1, "}");
            return(strclass.Value);
        }
Exemple #33
0
        /// <summary>
        /// �õ���ʾ����ʾ����Ĵ���
        /// </summary>       
        public string GetShowAspxCs()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendLine();
            string key = Key;
            strclass.AppendSpaceLine(1, "private void ShowInfo(" + Maticsoft.CodeHelper.CodeCommon.GetInParameter(Keys, true) + ")");
            strclass.AppendSpaceLine(1, "{");
            strclass.AppendSpaceLine(2, BLLSpace + " bll=new " + BLLSpace + "();");
            strclass.AppendSpaceLine(2, ModelSpace + " model=bll.GetModel(" + Maticsoft.CodeHelper.CodeCommon.GetFieldstrlist(Keys, true) + ");");
            //bool ishasuser = false;
            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;
                //if ((ispk) || (IsIdentity))
                //{
                //    continue;
                //}

                #region �����ֶδ���
                //���Զ���-�����ֶδ���
                //if (columnName.IndexOf("_iAuthority") > 0)
                //{
                //    continue;
                //}
                //if ((columnName.IndexOf("_cLang") > 0) && (columnType.Trim().ToLower() == "varchar"))//���Դ���
                //{
                //    strclass.AppendSpaceLine(2, "BLL.SysManage.MultiLanguage bllML = new BLL.SysManage.MultiLanguage();");
                //    strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text= bllML.GetLanguageNameByCache(model." + columnName + ");");
                //    continue;
                //}
                //if ((!ishasuser) && ((columnName.IndexOf("_iCreator") > 0) || (columnName.IndexOf("_iMaintainer") > 0)))
                //{
                //    strclass.AppendSpaceLine(2, "Maticsoft.Accounts.Bus.User user = new Maticsoft.Accounts.Bus.User();");
                //    ishasuser = true;
                //}
                //if ((columnName.IndexOf("_iCreator") > 0) || (columnName.IndexOf("_iMaintainer") > 0))
                //{
                //    strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text= user.GetTrueNameByCache(model." + columnName + ");");
                //    ishasuser = true;
                //    continue;
                //}
                #endregion

                switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
                {
                    case "int":
                    case "long":
                    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.lbl" + columnName + ".Text=model." + columnName + "?\"��\":\"��\";");
                        break;
                    case "byte[]":
                        strclass.AppendSpaceLine(2, "this.lbl" + columnName + ".Text=model." + columnName + ".ToString();");
                        break;
                    case "guid":
                    case "uniqueidentifier":
                        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();
        }
Exemple #34
0
        /// <summary>
        /// 修改窗体的html代码
        /// </summary>
        public string GetUpdateDesigner()
        {
            StringPlus strclass = new StringPlus();

            return(strclass.Value);
        }
Exemple #35
0
        /// <summary>
        /// �õ���ʾ�����Ӵ����html����
        /// </summary>      
        public string GetUpdateAspx()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendLine("");
            strclass.AppendLine("<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\">");
            bool hasDate = false;
            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, "<tr>");
                    strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"30%\" align=\"right\">");
                    strclass.AppendSpaceLine(2, deText);
                    strclass.AppendSpaceLine(1, "��</td>");
                    strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"*\" align=\"left\">");
                    strclass.AppendSpaceLine(2, "<asp:label id=\"lbl" + columnName + "\" runat=\"server\"></asp:label>");
                    strclass.AppendSpaceLine(1, "</td></tr>");
                }
                else
                {
                    //
                    strclass.AppendSpaceLine(1, "<tr>");
                    strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"30%\" align=\"right\">");
                    strclass.AppendSpaceLine(2, deText);
                    strclass.AppendSpaceLine(1, "��</td>");
                    strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"*\" align=\"left\">");

                    switch (columnType.Trim().ToLower())
                    {
                        case "datetime":
                        case "smalldatetime":
                            //strclass.AppendSpaceLine(2, "<INPUT onselectstart=\"return false;\" onkeypress=\"return false\" id=\"txt" + columnName + "\" onfocus=\"setday(this)\"");
                            //strclass.AppendSpaceLine(2, " readOnly type=\"text\" size=\"10\" name=\"Text1\" runat=\"server\">");
                            strclass.AppendSpaceLine(2, "<asp:TextBox ID=\"txt" + columnName + "\" runat=\"server\" Width=\"70px\"  onfocus=\"setday(this)\"></asp:TextBox>");
                            hasDate = true;
                            break;
                        case "bit":
                            strclass.AppendSpaceLine(2, "<asp:CheckBox ID=\"chk" + columnName + "\" Text=\"" + deText + "\" runat=\"server\" Checked=\"False\" />");
                            break;
                        default:
                            strclass.AppendSpaceLine(2, "<asp:TextBox id=\"txt" + columnName + "\" runat=\"server\" Width=\"200px\"></asp:TextBox>");
                            break;
                    }
                    strclass.AppendSpaceLine(1, "</td></tr>");
                }
            }

            ////��ť
            //strclass.AppendSpaceLine(1, "<tr>");
            //strclass.AppendSpaceLine(1, "<td height=\"25\" colspan=\"2\"><div align=\"center\">");
            //strclass.AppendSpaceLine(2, "<asp:Button ID=\"btnSave\" runat=\"server\" Text=\"�� ���� ��\" OnClick=\"btnSave_Click\" ></asp:Button>");
            ////strclass.AppendSpaceLine(2, "<asp:Button ID=\"btnCancel\" runat=\"server\" Text=\"�� ȡ�� ��\" OnClick=\"btnCancel_Click\" ></asp:Button>");
            //strclass.AppendSpaceLine(1, "</div></td></tr>");
            strclass.AppendLine("</table>");
            if (hasDate)
            {
                strclass.AppendLine("<script src=\"/js/calendar1.js\" type=\"text/javascript\"></script>");
            }
            return strclass.Value;
        }
Exemple #36
0
        /// <summary>
        /// 生成数据库表创建脚本
        /// </summary>
        /// <returns></returns>
        public string CreateTabScript(string dbname, string tablename)
        {
            dbobj.DbConnectStr = _dbconnectStr;
            List <ColumnInfo> collist  = dbobj.GetColumnInfoList(dbname, tablename);
            DataTable         dt       = LTP.CodeHelper.CodeCommon.GetColumnInfoDt(collist);
            StringPlus        strclass = new StringPlus();


            //string PKfild="";//主键字段
            //bool IsIden=false;//是否是标识字段
            StringPlus ColdefaVal = new StringPlus();        //字段的默认值列表

            Hashtable  FildtabList = new Hashtable();        //字段列表
            StringPlus FildList    = new StringPlus();       //字段列表

            //开始创建表
            strclass.AppendLine("");
            strclass.AppendLine(dbobj.GetTableScript(dbname, tablename));
            strclass.AppendLine(";");

            if (dt != null)
            {
                DataRow[] dtrows;
                if (Fieldlist.Count > 0)
                {
                    dtrows = dt.Select("ColumnName in (" + Fields + ")", "colorder asc");
                }
                else
                {
                    dtrows = dt.Select();
                }
                foreach (DataRow row in dtrows)
                {
                    string columnName = row["ColumnName"].ToString();
                    string columnType = row["TypeName"].ToString();
                    string IsIdentity = row["IsIdentity"].ToString();
                    if (IsIdentity == "√")
                    {
                        continue;
                    }
                    FildtabList.Add(columnName, columnType);
                    FildList.Append("" + columnName + ",");
                }
            }
            FildList.DelLastComma();

            //获取数据
            DataTable dtdata = dbobj.GetTabData(dbname, tablename);

            if (dtdata != null)
            {
                foreach (DataRow row in dtdata.Rows)               //循环表数据
                {
                    StringPlus strfild = new StringPlus();
                    StringPlus strdata = new StringPlus();
                    string []  split   = FildList.Value.Split(new Char [] { ',' });

                    foreach (string fild in split)                   //循环一行数据的各个字段
                    {
                        string colname = fild;
                        string coltype = "";
                        foreach (DictionaryEntry myDE in FildtabList)
                        {
                            if (myDE.Key.ToString() == colname)
                            {
                                coltype = myDE.Value.ToString();
                            }
                        }
                        string strval = "";
                        switch (coltype)
                        {
                        case "binary":
                        {
                            byte[] bys = (byte[])row[colname];
                            strval = LTP.CodeHelper.CodeCommon.ToHexString(bys);
                        }
                        break;

                        case "bit":
                        {
                            strval = (row[colname].ToString().ToLower() == "true")?"1":"0";
                        }
                        break;

                        default:
                            strval = row[colname].ToString().Trim();
                            break;
                        }
                        if (strval != "")
                        {
                            if (LTP.CodeHelper.CodeCommon.IsAddMark(coltype))
                            {
                                strdata.Append("'" + strval + "',");
                            }
                            else
                            {
                                strdata.Append(strval + ",");
                            }
                            strfild.Append("" + colname + ",");
                        }
                    }
                    strfild.DelLastComma();
                    strdata.DelLastComma();
                    //导出数据INSERT语句
                    strclass.Append("INSERT " + tablename + " (");
                    strclass.Append(strfild.Value);
                    strclass.Append(") VALUES ( ");
                    strclass.Append(strdata.Value);                    //数据值
                    strclass.AppendLine(");");
                }
            }


            return(strclass.Value);
        }
Exemple #37
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;
        }
Exemple #38
0
        /// <summary>
        /// 生成数据库表创建脚本到文件
        /// </summary>
        /// <returns></returns>
        public void CreateTabScript(string dbname, string tablename, string filename, System.Windows.Forms.ProgressBar progressBar)
        {
            StreamWriter sw = new StreamWriter(filename, true, Encoding.Default);        //,false);

            dbobj.DbConnectStr = _dbconnectStr;
            //DataTable dt=dbobj.GetColumnInfoList(dbname,tablename);
            List <ColumnInfo> collist = dbobj.GetColumnInfoList(dbname, tablename);
            DataTable         dt      = LTP.CodeHelper.CodeCommon.GetColumnInfoDt(collist);

            StringPlus strclass = new StringPlus();
            //strclass.AppendLine("if exists (select * from sysobjects where id = OBJECT_ID('["+tablename+"]') and OBJECTPROPERTY(id, 'IsUserTable') = 1) ");
            //strclass.AppendLine("DROP TABLE '"+tablename+"'");

            //string PKfild="";//主键字段
            //bool IsIden=false;//是否是标识字段
            StringPlus ColdefaVal = new StringPlus();          //字段的默认值列表


            Hashtable  FildtabList = new Hashtable();        //字段列表
            StringPlus FildList    = new StringPlus();       //字段列表

            strclass.AppendLine("");
            strclass.AppendLine(dbobj.GetTableScript(dbname, tablename));
            strclass.AppendLine(";");

            if (dt != null)
            {
                DataRow[] dtrows;
                if (Fieldlist.Count > 0)
                {
                    dtrows = dt.Select("ColumnName in (" + Fields + ")", "colorder asc");
                }
                else
                {
                    dtrows = dt.Select();
                }
                foreach (DataRow row in dtrows)
                {
                    string columnName = row["ColumnName"].ToString();
                    string columnType = row["TypeName"].ToString();
                    string IsIdentity = row["IsIdentity"].ToString();
                    if (IsIdentity == "√")
                    {
                        continue;
                    }
                    FildtabList.Add(columnName, columnType);
                    FildList.Append("" + columnName + ",");
                }
            }
            FildList.DelLastComma();

            sw.Write(strclass.Value);

            #region 生成数据脚本

            //获取数据
            DataTable dtdata = dbobj.GetTabData(dbname, tablename);
            if (dtdata != null)
            {
                int i = 0;
                progressBar.Maximum = dtdata.Rows.Count;
                foreach (DataRow row in dtdata.Rows)               //循环表数据
                {
                    i++;
                    progressBar.Value = i;

                    StringPlus rowdata = new StringPlus();

                    StringPlus strfild = new StringPlus();
                    StringPlus strdata = new StringPlus();
                    string []  split   = FildList.Value.Split(new Char [] { ',' });

                    foreach (string fild in split)                   //循环一行数据的各个字段
                    {
                        string colname = fild;
                        string coltype = "";
                        foreach (DictionaryEntry myDE in FildtabList)
                        {
                            if (myDE.Key.ToString() == colname)
                            {
                                coltype = myDE.Value.ToString();
                            }
                        }
                        string strval = "";
                        switch (coltype)
                        {
                        case "binary":
                        {
                            byte[] bys = (byte[])row[colname];
                            strval = LTP.CodeHelper.CodeCommon.ToHexString(bys);
                        }
                        break;

                        case "bit":
                        {
                            strval = (row[colname].ToString().ToLower() == "true")?"1":"0";
                        }
                        break;

                        default:
                            strval = row[colname].ToString().Trim();
                            break;
                        }
                        if (strval != "")
                        {
                            if (LTP.CodeHelper.CodeCommon.IsAddMark(coltype))
                            {
                                strdata.Append("'" + strval + "',");
                            }
                            else
                            {
                                strdata.Append(strval + ",");
                            }
                            strfild.Append("" + colname + ",");
                        }
                    }
                    strfild.DelLastComma();
                    strdata.DelLastComma();

                    //导出数据INSERT语句
                    rowdata.Append("INSERT " + tablename + " (");
                    rowdata.Append(strfild.Value);
                    rowdata.Append(") VALUES ( ");
                    rowdata.Append(strdata.Value);                    //数据值
                    rowdata.AppendLine(");");
                    sw.Write(rowdata.Value);
                }
            }

            #endregion


            sw.Flush();
            sw.Close();
        }
Exemple #39
0
        public static string ViewTxtList(int top, int txtNum, string strWhere, string orderby, string txtUrl)
        {
            DtCms.BLL.Contents bll    = new DtCms.BLL.Contents();
            StringBuilder      strTxt = new StringBuilder();
            DataSet            ds     = bll.GetList(top, strWhere, orderby);

            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    strTxt.Append("<tr><td height=\"30\" align=\"left\" class=\"xuxian-heng\">▪ <a href=\"" + txtUrl + "?id=" + dr["Id"].ToString() + "\" title=\"" + dr["Title"].ToString() + "\">" + StringPlus.CutString(dr["Title"].ToString(), txtNum) + "</a></td></tr>\n");
                }
            }

            return(strTxt.ToString());
        }
Exemple #40
0
        /// <summary>
        /// 得到整个类的代码
        /// </summary>
        public string GetDALCode(bool Maxid, bool Exists, bool Add, bool Update, bool Delete, bool GetModel, bool List)
        {
            StringPlus strclass = new StringPlus();

            strclass.AppendLine("using System;");
            strclass.AppendLine("using System.Data;");
            strclass.AppendLine("using System.Text;");
            switch (dbobj.DbType)
            {
            case "SQL2005":
                strclass.AppendLine("using System.Data.SqlClient;");
                break;

            case "SQL2000":
                strclass.AppendLine("using System.Data.SqlClient;");
                break;

            case "Oracle":
                strclass.AppendLine("using System.Data.OracleClient;");
                break;

            case "MySQL":
                strclass.AppendLine("using MySql.Data.MySqlClient;");
                break;

            case "OleDb":
                strclass.AppendLine("using System.Data.OleDb;");
                break;
            }
            if (IDALpath != "")
            {
                strclass.AppendLine("using " + IDALpath + ";");
            }
            strclass.AppendLine("using Maticsoft.DBUtility;//请先添加引用");
            strclass.AppendLine("namespace " + DALpath);
            strclass.AppendLine("{");
            strclass.AppendSpaceLine(1, "/// <summary>");
            strclass.AppendSpaceLine(1, "/// 数据访问类" + DALName + "。");
            strclass.AppendSpaceLine(1, "/// </summary>");
            strclass.AppendSpace(1, "public class " + DALName);
            if (IClass != "")
            {
                strclass.Append(":" + IClass);
            }
            strclass.AppendLine("");
            strclass.AppendSpaceLine(1, "{");
            strclass.AppendSpaceLine(2, "public " + DALName + "()");
            strclass.AppendSpaceLine(2, "{}");
            strclass.AppendSpaceLine(2, "#region  成员方法");

            #region  方法代码
            if (Maxid)
            {
                strclass.AppendLine(CreatGetMaxID());
            }
            if (Exists)
            {
                strclass.AppendLine(CreatExists());
            }
            if (Add)
            {
                strclass.AppendLine(CreatAdd());
            }
            if (Update)
            {
                strclass.AppendLine(CreatUpdate());
            }
            if (Delete)
            {
                strclass.AppendLine(CreatDelete());
            }
            if (GetModel)
            {
                strclass.AppendLine(CreatGetModel());
            }
            if (List)
            {
                strclass.AppendLine(CreatGetList());
                strclass.AppendLine(CreatGetListByPageProc());
            }
            #endregion

            strclass.AppendSpaceLine(2, "#endregion  成员方法");
            strclass.AppendSpaceLine(1, "}");
            strclass.AppendLine("}");
            strclass.AppendLine("");

            return(strclass.ToString());
        }
Exemple #41
0
 /// <summary>
 /// 按字节长度剪切字符串
 /// </summary>
 /// <param name="str"></param>
 /// <param name="byteLength"></param>
 /// <param name="isDot">是否末尾加  ...</param>
 /// <returns></returns>
 public string GetStrByByteLength(string str, int byteLength, bool isDot)
 {
     return(StringPlus.GetStrByByteLength(str, byteLength, isDot));
 }
Exemple #42
0
        /// <summary>
        /// 得到GetModel()的代码
        /// </summary>
        /// <param name="DbName"></param>
        /// <param name="_tablename"></param>
        /// <param name="_key"></param>
        /// <param name="ModelName"></param>
        /// <returns></returns>
        public string CreatGetModel()
        {
            if (ModelSpace == "")
            {
                //ModelSpace = "ModelClassName"; ;
            }
            StringPlus strclass = new StringPlus();

            strclass.AppendLine();
            strclass.AppendSpaceLine(2, "/// <summary>");
            strclass.AppendSpaceLine(2, "/// 得到一个对象实体");
            strclass.AppendSpaceLine(2, "/// </summary>");
            strclass.AppendSpaceLine(2, "public " + ModelSpace + " GetModel(" + LTP.CodeHelper.CodeCommon.GetInParameter(Keys) + ")");
            strclass.AppendSpaceLine(2, "{");
            strclass.AppendSpaceLine(3, KeysNullTip);
            strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
            strclass.AppendSpace(3, "strSql.Append(\"select ");
            if (dbobj.DbType == "SQL2005" || dbobj.DbType == "SQL2000" || dbobj.DbType == "SQL2008")
            {
                strclass.Append(" top 1 ");
            }
            strclass.AppendLine(Fieldstrlist + " from " + _tablename + " \");");
            strclass.AppendSpaceLine(3, "strSql.Append(\" where " + GetWhereExpression(Keys) + "\");");

            strclass.AppendLine(GetPreParameter(Keys));

            strclass.AppendSpaceLine(3, "" + ModelSpace + " model=new " + ModelSpace + "();");
            strclass.AppendSpaceLine(3, "DataSet ds=" + DbHelperName + ".Query(strSql.ToString(),parameters);");
            strclass.AppendSpaceLine(3, "if(ds.Tables[0].Rows.Count>0)");
            strclass.AppendSpaceLine(3, "{");

            #region 字段赋值
            foreach (ColumnInfo field in Fieldlist)
            {
                string columnName = field.ColumnName;
                string columnType = field.TypeName;
                switch (CodeCommon.DbTypeToCS(columnType))
                {
                case "int":
                {
                    strclass.AppendSpaceLine(4, "if(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString()!=\"\")");
                    strclass.AppendSpaceLine(4, "{");
                    strclass.AppendSpaceLine(5, "model." + columnName + "=int.Parse(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString());");
                    strclass.AppendSpaceLine(4, "}");
                }
                break;

                case "long":
                {
                    strclass.AppendSpaceLine(4, "if(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString()!=\"\")");
                    strclass.AppendSpaceLine(4, "{");
                    strclass.AppendSpaceLine(5, "model." + columnName + "=long.Parse(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString());");
                    strclass.AppendSpaceLine(4, "}");
                }
                break;

                case "decimal":
                {
                    strclass.AppendSpaceLine(4, "if(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString()!=\"\")");
                    strclass.AppendSpaceLine(4, "{");
                    strclass.AppendSpaceLine(5, "model." + columnName + "=decimal.Parse(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString());");
                    strclass.AppendSpaceLine(4, "}");
                }
                break;

                case "float":
                {
                    strclass.AppendSpaceLine(4, "if(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString()!=\"\")");
                    strclass.AppendSpaceLine(4, "{");
                    strclass.AppendSpaceLine(5, "model." + columnName + "=float.Parse(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString());");
                    strclass.AppendSpaceLine(4, "}");
                }
                break;

                case "DateTime":
                {
                    strclass.AppendSpaceLine(4, "if(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString()!=\"\")");
                    strclass.AppendSpaceLine(4, "{");
                    strclass.AppendSpaceLine(5, "model." + columnName + "=DateTime.Parse(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString());");
                    strclass.AppendSpaceLine(4, "}");
                }
                break;

                case "string":
                {
                    strclass.AppendSpaceLine(4, "model." + columnName + "=ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString();");
                }
                break;

                case "bool":
                {
                    strclass.AppendSpaceLine(4, "if(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString()!=\"\")");
                    strclass.AppendSpaceLine(4, "{");
                    strclass.AppendSpaceLine(5, "if((ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString()==\"1\")||(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString().ToLower()==\"true\"))");
                    strclass.AppendSpaceLine(5, "{");
                    strclass.AppendSpaceLine(6, "model." + columnName + "=true;");
                    strclass.AppendSpaceLine(5, "}");
                    strclass.AppendSpaceLine(5, "else");
                    strclass.AppendSpaceLine(5, "{");
                    strclass.AppendSpaceLine(6, "model." + columnName + "=false;");
                    strclass.AppendSpaceLine(5, "}");
                    strclass.AppendSpaceLine(4, "}");
                }
                break;

                case "byte[]":
                {
                    strclass.AppendSpaceLine(4, "if(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString()!=\"\")");
                    strclass.AppendSpaceLine(4, "{");
                    strclass.AppendSpaceLine(5, "model." + columnName + "=(byte[])ds.Tables[0].Rows[0][\"" + columnName + "\"];");
                    strclass.AppendSpaceLine(4, "}");
                }
                break;

                case "Guid":
                {
                    strclass.AppendSpaceLine(4, "if(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString()!=\"\")");
                    strclass.AppendSpaceLine(4, "{");
                    strclass.AppendSpaceLine(5, "model." + columnName + "=new Guid(ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString());");
                    strclass.AppendSpaceLine(4, "}");
                }
                break;

                default:
                    strclass.AppendSpaceLine(4, "//model." + columnName + "=ds.Tables[0].Rows[0][\"" + columnName + "\"].ToString();");
                    break;
                }
            }
            #endregion

            strclass.AppendSpaceLine(4, "return model;");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(3, "else");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "return null;");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendSpaceLine(2, "}");
            return(strclass.ToString());
        }
Exemple #43
0
        /// <summary>
        /// 得到修改窗体的代码
        /// </summary>
        public string GetUpdateAspxCs()
        {
            StringPlus strclass  = new StringPlus();
            StringPlus strclass0 = new StringPlus();
            StringPlus strclass1 = new StringPlus();
            StringPlus strclass2 = new StringPlus();

            strclass.AppendLine();
            strclass.AppendSpaceLine(3, "string strErr=\"\";");
            foreach (ColumnInfo field in Fieldlist)
            {
                string columnName = field.ColumnName;
                string columnType = field.TypeName;
                bool   ispk       = field.IsPK;
                bool   IsIdentity = field.IsIdentity;
                if ((ispk) || (IsIdentity))
                {
                    continue;
                }
                switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
                {
                case "int":
                case "smallint":
                    strclass0.AppendSpaceLine(3, "int " + columnName + "=int.Parse(this.txt" + columnName + ".Text);");
                    strclass1.AppendSpaceLine(3, "if(!PageValidate.IsNumber(txt" + columnName + ".Text))");
                    strclass1.AppendSpaceLine(3, "{");
                    strclass1.AppendSpaceLine(4, "strErr+=\"" + columnName + "不是数字!\\\\n\";	");
                    strclass1.AppendSpaceLine(3, "}");
                    break;

                case "float":
                case "numeric":
                case "decimal":
                    strclass0.AppendSpaceLine(3, "decimal " + columnName + "=decimal.Parse(this.txt" + columnName + ".Text);");
                    strclass1.AppendSpaceLine(3, "if(!PageValidate.IsDecimal(txt" + columnName + ".Text))");
                    strclass1.AppendSpaceLine(3, "{");
                    strclass1.AppendSpaceLine(4, "strErr+=\"" + columnName + "不是数字!\\\\n\";	");
                    strclass1.AppendSpaceLine(3, "}");
                    break;

                case "datetime":
                case "smalldatetime":
                    strclass0.AppendSpaceLine(3, "DateTime " + columnName + "=DateTime.Parse(this.txt" + columnName + ".Text);");
                    strclass1.AppendSpaceLine(3, "if(!PageValidate.IsDateTime(txt" + columnName + ".Text))");
                    strclass1.AppendSpaceLine(3, "{");
                    strclass1.AppendSpaceLine(4, "strErr+=\"" + columnName + "不是时间格式!\\\\n\";	");
                    strclass1.AppendSpaceLine(3, "}");
                    break;

                case "bool":
                    strclass0.AppendSpaceLine(3, "bool " + columnName + "=this.chk" + columnName + ".Checked;");
                    break;

                case "byte[]":
                    strclass0.AppendSpaceLine(3, "byte[] " + columnName + "= new UnicodeEncoding().GetBytes(this.txt" + columnName + ".Text);");
                    break;

                default:
                    strclass0.AppendSpaceLine(3, "string " + columnName + "=this.txt" + columnName + ".Text;");
                    strclass1.AppendSpaceLine(3, "if(this.txt" + columnName + ".Text ==\"\")");
                    strclass1.AppendSpaceLine(3, "{");
                    strclass1.AppendSpaceLine(4, "strErr+=\"" + columnName + "不能为空!\\\\n\";	");
                    strclass1.AppendSpaceLine(3, "}");
                    break;
                }
                strclass2.AppendSpaceLine(3, "model." + columnName + "=" + columnName + ";");
            }
            strclass.AppendLine(strclass1.ToString());
            strclass.AppendSpaceLine(3, "if(strErr!=\"\")");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "MessageBox.Show(this,strErr);");
            strclass.AppendSpaceLine(4, "return;");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendLine(strclass0.ToString());
            strclass.AppendLine();
            strclass.AppendSpaceLine(3, ModelSpace + " model=new " + ModelSpace + "();");
            strclass.AppendLine(strclass2.ToString());
            strclass.AppendSpaceLine(3, BLLSpace + " bll=new " + BLLSpace + "();");
            strclass.AppendSpaceLine(3, "bll.Update(model);");
            return(strclass.ToString());
        }
Exemple #44
0
        /// <summary>
        /// ����sql����еIJ����б�(���磺���� Exists  Delete  GetModel ��where������ֵ)
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        public string GetPreParameter(List<ColumnInfo> keys, bool IdentityisPrior)
        {
            StringPlus strclass = new StringPlus();
            StringPlus strclass2 = new StringPlus();
            strclass.AppendSpaceLine(3, "" + DbParaHead + "Parameter[] parameters = {");

            ColumnInfo field = Maticsoft.CodeHelper.CodeCommon.GetIdentityKey(keys);
            if ((IdentityisPrior) && (field != null)) //�б�ʶ�ֶ�
            {
                strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + "" + field.ColumnName + "\", " + DbParaDbType + "." + CodeCommon.DbTypeLength(dbobj.DbType, field.TypeName, "") + ")");
                strclass2.AppendSpaceLine(3, "parameters[0].Value = " + field.ColumnName + ";");
            }
            else
            {
                int n = 0;
                foreach (ColumnInfo key in keys)
                {
                    if (key.IsPrimaryKey)
                    {
                        strclass.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + "" + key.ColumnName + "\", " + DbParaDbType + "." + CodeCommon.DbTypeLength(dbobj.DbType, key.TypeName, "") + "),");
                        strclass2.AppendSpaceLine(3, "parameters[" + n.ToString() + "].Value = " + key.ColumnName + ";");
                        n++;
                    }
                }
                strclass.DelLastComma();
            }
            strclass.AppendLine("};");
            strclass.Append(strclass2.Value);
            return strclass.Value;
        }
Exemple #45
0
        public string CreatSearchForm()
        {
            StringPlus strclass = new StringPlus();

            return(strclass.Value);
        }
Exemple #46
0
 /// <summary>
 /// ���ɱ�ʾ��ҳ���CS����
 /// </summary>
 /// <param name="ExistsKey"></param>
 /// <param name="AddForm">�Ƿ��������Ӵ���Ĵ���</param>
 /// <param name="UpdateForm">�Ƿ������޸Ĵ���Ĵ���</param>
 /// <param name="ShowForm">�Ƿ�������ʾ����Ĵ���</param>
 /// <param name="SearchForm">�Ƿ����ɲ�ѯ����Ĵ���</param>
 /// <returns></returns>
 public string GetWebCode(bool ExistsKey, bool AddForm, bool UpdateForm, bool ShowForm, bool SearchForm)
 {
     StringPlus strclass = new StringPlus();
     if (AddForm)
     {
         strclass.AppendLine("  /******************************���Ӵ������********************************/");
         strclass.AppendLine(GetAddAspxCs());
     }
     if (UpdateForm)
     {
         strclass.AppendLine("  /******************************�޸Ĵ������********************************/");
         strclass.AppendLine("  /*�޸Ĵ���-��ʾ */");
         strclass.AppendLine(GetUpdateShowAspxCs());
         strclass.AppendLine("  /*�޸Ĵ���-�ύ���� */");
         strclass.AppendLine(GetUpdateAspxCs());
     }
     if (ShowForm)
     {
         strclass.AppendLine("  /******************************��ʾ�������********************************/");
         strclass.AppendLine(GetShowAspxCs());
     }
     //if (DelForm)
     //{
     //    strclass.Append("  /******************************ɾ���������********************************/");
     //    strclass.Append("");
     //    strclass.Append(CreatDeleteForm());
     //}
     return strclass.Value;
 }
Exemple #47
0
        /// <summary>
        /// 显示窗体的html代码
        /// </summary>
        public string GetShowDesigner()
        {
            StringPlus strclass = new StringPlus();

            return(strclass.ToString());
        }
Exemple #48
0
 /// <summary>
 /// ��ɾ��3��ҳ�����
 /// </summary>      
 public string GetWebHtmlCode(bool ExistsKey, bool AddForm, bool UpdateForm, bool ShowForm, bool SearchForm)
 {
     StringPlus strclass = new StringPlus();
     if (AddForm)
     {
         strclass.AppendLine(" <!--******************************����ҳ�����********************************-->");
         strclass.AppendLine(GetAddAspx());
     }
     if (UpdateForm)
     {
         strclass.AppendLine(" <!--******************************�޸�ҳ�����********************************-->");
         strclass.AppendLine(GetUpdateAspx());
     }
     if (ShowForm)
     {
         strclass.AppendLine("  <!--******************************��ʾҳ�����********************************-->");
         strclass.AppendLine(GetShowAspx());
     }
     if (SearchForm)
     {
         strclass.AppendLine("  <!--******************************�б�ҳ�����********************************-->");
         strclass.AppendLine(GetListAspx());
     }
     return strclass.ToString();
 }
Exemple #49
0
        /// <summary>
        /// 根据SQL查询结果 生成数据创建脚本
        /// </summary>
        /// <returns></returns>
        public string CreateTabScriptBySQL(string dbname, string strSQL)
        {
            dbobj.DbConnectStr = _dbconnectStr;
            //string PKfild = "";//主键字段
            bool       IsIden    = false;//是否是标识字段
            string     tablename = "TableName";
            StringPlus strclass  = new StringPlus();

            #region 查询表名
            int ns = strSQL.IndexOf(" from ");
            if (ns > 0)
            {
                string sqltemp = strSQL.Substring(ns + 5).Trim();
                int    ns2     = sqltemp.IndexOf(" ");
                if (sqltemp.Length > 0)
                {
                    if (ns2 > 0)
                    {
                        tablename = sqltemp.Substring(0, ns2).Trim();
                    }
                    else
                    {
                        tablename = sqltemp.Substring(0).Trim();
                    }
                }
            }
            tablename = tablename.Replace("[", "").Replace("]", "");

            #endregion

            #region 数据脚本


            //获取数据
            DataTable dtdata = dbobj.GetTabDataBySQL(dbname, strSQL);
            if (dtdata != null)
            {
                DataColumnCollection dtcols = dtdata.Columns;
                foreach (DataRow row in dtdata.Rows)//循环表数据
                {
                    StringPlus strfild = new StringPlus();
                    StringPlus strdata = new StringPlus();

                    foreach (DataColumn col in dtcols)//循环一行数据的各个字段
                    {
                        string colname = col.ColumnName;
                        string coltype = col.DataType.Name;
                        if (col.AutoIncrement)
                        {
                            IsIden = true;
                        }
                        string strval = "";
                        switch (coltype.ToLower())
                        {
                        case "binary":
                        case "byte[]":
                        case "blob":
                        {
                            byte[] bys = (byte[])row[colname];
                            strval = LTP.CodeHelper.CodeCommon.ToHexString(bys);
                        }
                        break;

                        case "bit":
                        case "boolean":
                        {
                            strval = (row[colname].ToString().ToLower() == "true") ? "1" : "0";
                        }
                        break;

                        default:
                            strval = row[colname].ToString().Trim();
                            break;
                        }
                        if (strval != "")
                        {
                            if (LTP.CodeHelper.CodeCommon.IsAddMark(coltype))
                            {
                                strdata.Append("'" + strval + "',");
                            }
                            else
                            {
                                strdata.Append(strval + ",");
                            }
                            strfild.Append("" + colname + ",");
                        }
                    }
                    strfild.DelLastComma();
                    strdata.DelLastComma();
                    //导出数据INSERT语句
                    strclass.Append("INSERT " + tablename + " (");
                    strclass.Append(strfild.Value);
                    strclass.Append(") VALUES ( ");
                    strclass.Append(strdata.Value);//数据值
                    strclass.AppendLine(")");
                }
            }
            //StringPlus strclass0 = new StringPlus();
            //if (IsIden)
            //{
            //    strclass0.AppendLine("SET IDENTITY_INSERT [" + tablename + "] ON");
            //    strclass0.AppendLine("");
            //}
            //strclass0.AppendLine(strclass.Value);
            //if (IsIden)
            //{
            //    strclass0.AppendLine("");
            //    strclass0.AppendLine("SET IDENTITY_INSERT [" + tablename + "] OFF");
            //}
            #endregion
            return(strclass.Value);
        }
Exemple #50
0
        public string CreatSearchForm()
        {
            StringPlus strclass = new StringPlus();

            return strclass.Value;
        }
Exemple #51
0
        public string CreatPROCUpdate()
        {
            StringPlus strclass  = new StringPlus();
            StringPlus strclass1 = new StringPlus();

            //strclass.Append("if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[");
            //strclass.Append("" + ProcPrefix + ""+_tablename+"_Update");
            //strclass.AppendLine("]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)");
            //strclass.AppendLine("drop procedure [dbo].[" + ProcPrefix + ""+_tablename+"_Update]");
            //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 + "_Update");

            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;

                switch (columnType.ToLower())
                {
                case "decimal":
                case "numeric":
                    strclass.AppendLine("@" + columnName + " " + columnType + "(" + Preci + "," + Scale + "),");
                    break;

                case "varchar":
                case "char":
                case "nchar":
                case "binary":
                case "nvarchar":
                case "varbinary":
                {
                    string len = CodeCommon.GetDataTypeLenVal(columnType.Trim(), Length);
                    strclass.AppendLine("@" + columnName + " " + columnType + "(" + len + "),");
                }
                break;

                default:
                    strclass.AppendLine("@" + columnName + " " + columnType + ",");
                    break;
                }
                if ((IsIdentity) || (IsPK))
                {
                    continue;
                }
                strclass1.Append("" + columnName + " = @" + columnName + ",");
            }
            strclass.DelLastComma();
            strclass1.DelLastComma();
            strclass.AppendLine();
            strclass.AppendLine(" AS ");
            strclass.AppendSpaceLine(1, "UPDATE " + _tablename + " SET ");
            strclass.AppendSpaceLine(1, strclass1.Value);
            strclass.AppendSpaceLine(1, "WHERE " + GetWhereExpression(Keys));
            strclass.AppendLine();
            strclass.AppendLine("GO");
            return(strclass.Value);
        }
Exemple #52
0
        /// <summary>
        /// �õ���ʾ�����Ӵ����html����
        /// </summary>      
        public string GetAddAspx()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendLine();
            strclass.AppendLine("<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\">");
            bool hasDate = false;
            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;
                if (IsIdentity)
                {
                    continue;
                }

                if (isFilterColume(columnName))
                {
                    continue;
                }
                if (columnType.Trim().ToLower() == "uniqueidentifier")
                {
                    continue;
                }

                deText = CodeHelper.CodeCommon.CutDescText(deText, 15, columnName);

                strclass.AppendSpaceLine(1, "<tr>");
                strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"30%\" align=\"right\">");
                strclass.AppendSpaceLine(2, deText);
                strclass.AppendSpaceLine(1, "��</td>");
                strclass.AppendSpaceLine(1, "<td height=\"25\" width=\"*\" align=\"left\">");

                switch (columnType.Trim().ToLower())
                {
                    case "datetime":
                    case "smalldatetime":
                        strclass.AppendSpaceLine(2, "<asp:TextBox ID=\"txt" + columnName + "\" runat=\"server\" Width=\"70px\"  onfocus=\"setday(this)\"></asp:TextBox>");
                        hasDate = true;
                        break;
                    case "bit":
                        strclass.AppendSpaceLine(2, "<asp:CheckBox ID=\"chk" + columnName + "\" Text=\"" + deText + "\" runat=\"server\" Checked=\"False\" />");
                        break;
                    case "uniqueidentifier":
                        break;
                    default:
                        strclass.AppendSpaceLine(2, "<asp:TextBox id=\"txt" + columnName + "\" runat=\"server\" Width=\"200px\"></asp:TextBox>");
                        break;
                }
                strclass.AppendSpaceLine(1, "</td></tr>");
            }
            strclass.AppendLine("</table>");
            if (hasDate)
            {
                strclass.AppendLine("<script src=\"/js/calendar1.js\" type=\"text/javascript\"></script>");
            }
            return strclass.ToString();
        }
Exemple #53
0
        public IndicAkshar[] Split(string s)
        {
            IndicAkshar[] IA = null;
            try
            {
                string[] retVal = new string[s.Length];
                int      cnt    = 0;

                string lockedString = "";

                char   lastChar       = ' ';
                string lastCharNature = "a";
                bool   released       = false;
                for (int i = 0; i < s.Length; i++)
                {
                    released = false;
                    char currChar = StringPlus.CharAt(s, i);

                    IndicChar I = _ic.NewChar;
                    I.CharSet  = CharSet;
                    I.BaseChar = currChar;

                    if (currChar == this.CharSet.Special2)
                    {
                        if (cnt >= 1)
                        {
                            retVal[cnt - 1] = retVal[cnt - 1] + currChar;
                            continue;
                        }
                    }


                    string currCharNature = I.CharNature;
                    bool   CanIRelase     = CanRelease(currCharNature, lastCharNature);

                    if (CanIRelase)
                    {
                        bool CanImmRelase = IsImmRelease(currCharNature);
                        if (CanImmRelase)
                        {
                            if (lockedString != "")
                            {
                                retVal[cnt++] = lockedString;
                            }
                            lockedString = currChar.ToString();
                            released     = false;
                        }
                        else
                        {
                            #region NotImmRElease
                            if (I.IsSpecialFinishing || I.IsNeutral)
                            {
                                #region SpecialCharFinishing
                                if (lockedString == "")
                                {
                                    try
                                    {
                                        retVal[cnt - 1] = retVal[cnt - 1] + lockedString + currChar;
                                    }
                                    catch
                                    {
                                        throw new Exception("Invalid Lang Char ");
                                    }
                                }
                                else
                                {
                                    retVal[cnt++] = lockedString + currChar;
                                }
                                #endregion
                            }
                            else
                            {
                                if (!I.CanIgonre)
                                {
                                    lockedString = lockedString + currChar;
                                    if (lockedString != "")
                                    {
                                        retVal[cnt++] = lockedString;
                                    }
                                }
                                else
                                {
                                    if (lockedString != "")
                                    {
                                        retVal[cnt++] = lockedString;
                                    }
                                    retVal[cnt++] = currChar.ToString();
                                }
                            }
                            lockedString = "";
                            released     = true;
                            #endregion
                        }
                        lastChar       = ' ';
                        lastCharNature = currCharNature;
                    }

                    else
                    {
                        lastChar       = currChar;
                        lockedString   = lockedString + currChar;
                        lastCharNature = currCharNature;
                    }
                }
                if (!released)
                {
                    retVal[cnt++] = lockedString;
                }

                IA = new IndicAkshar[cnt];
                for (int i = 0; i < cnt; i++)
                {
                    IA[i] = new IndicAkshar();
                    IA[i].SetChars(retVal[i], this.CharSet);
                }
            }
            catch
            {
            }
            return(IA);
        }
Exemple #54
0
        /// <summary>
        /// �õ���ʾ�����Ӵ���Ĵ���
        /// </summary>      
        public string GetAddAspxCs()
        {
            StringPlus strclass = new StringPlus();
            StringPlus strclass0 = new StringPlus();
            StringPlus strclass1 = new StringPlus();
            StringPlus strclass2 = new StringPlus();
            strclass.AppendLine();
            strclass.AppendSpaceLine(3, "string strErr=\"\";");
            //bool ishasuser = false;
            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;
                if ((IsIdentity))
                {
                    continue;
                }
                if ("uniqueidentifier" == columnType.ToLower())
                {
                    continue;
                }
                //���Զ���-�����ֶδ���
                //if ((!ishasuser) && ((columnName.IndexOf("_iCreator") > 0) || (columnName.IndexOf("_iMaintainer") > 0)))
                //{
                //    strclass0.AppendSpaceLine(3, "User currentUser;");
                //    strclass0.AppendSpaceLine(3, "if (Session[\"UserInfo\"] != null)");
                //    strclass0.AppendSpaceLine(3, "{");
                //    strclass0.AppendSpaceLine(4, "currentUser = (User)Session[\"UserInfo\"];");
                //    strclass0.AppendSpaceLine(3, "}else{");
                //    strclass0.AppendSpaceLine(4, "return;");
                //    strclass0.AppendSpaceLine(3, "}");
                //    ishasuser = true;
                //}

                deText = Maticsoft.CodeHelper.CodeCommon.CutDescText(deText, 15, columnName);

                switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
                {
                    case "int":
                    case "smallint":
                       strclass0.AppendSpaceLine(3, "int " + columnName + "=int.Parse(this.txt" + columnName + ".Text);");
                            strclass1.AppendSpaceLine(3, "if(!PageValidate.IsNumber(txt" + columnName + ".Text))");
                            strclass1.AppendSpaceLine(3, "{");
                            strclass1.AppendSpaceLine(4, "strErr+=\"" + deText + "��ʽ����\\\\n\";	");
                            strclass1.AppendSpaceLine(3, "}");
                        break;
                    case "float":
                    case "numeric":
                    case "decimal":
                        strclass0.AppendSpaceLine(3, "decimal " + columnName + "=decimal.Parse(this.txt" + columnName + ".Text);");
                        strclass1.AppendSpaceLine(3, "if(!PageValidate.IsDecimal(txt" + columnName + ".Text))");
                        strclass1.AppendSpaceLine(3, "{");
                        strclass1.AppendSpaceLine(4, "strErr+=\"" + deText + "��ʽ����\\\\n\";	");
                        strclass1.AppendSpaceLine(3, "}");
                        break;
                    case "datetime":
                    case "smalldatetime":
                        strclass0.AppendSpaceLine(3, "DateTime " + columnName + "=DateTime.Parse(this.txt" + columnName + ".Text);");
                        strclass1.AppendSpaceLine(3, "if(!PageValidate.IsDateTime(txt" + columnName + ".Text))");
                        strclass1.AppendSpaceLine(3, "{");
                        strclass1.AppendSpaceLine(4, "strErr+=\"" + deText + "��ʽ����\\\\n\";	");
                        strclass1.AppendSpaceLine(3, "}");

                        break;
                    case "bool":
                        strclass0.AppendSpaceLine(3, "bool " + columnName + "=this.chk" + columnName + ".Checked;");
                        break;
                    case "byte[]":
                        strclass0.AppendSpaceLine(3, "byte[] " + columnName + "= new UnicodeEncoding().GetBytes(this.txt" + columnName + ".Text);");
                        break;
                    case "guid":
                    case "uniqueidentifier":
                        break;
                    default:
                        strclass0.AppendSpaceLine(3, "string " + columnName + "=this.txt" + columnName + ".Text;");
                        strclass1.AppendSpaceLine(3, "if(this.txt" + columnName + ".Text.Trim().Length==0)");
                        strclass1.AppendSpaceLine(3, "{");
                        strclass1.AppendSpaceLine(4, "strErr+=\"" + deText + "����Ϊ�գ�\\\\n\";	");
                        strclass1.AppendSpaceLine(3, "}");
                        break;
                }
                strclass2.AppendSpaceLine(3, "model." + columnName + "=" + columnName + ";");
            }
            strclass.AppendLine(strclass1.ToString());
            strclass.AppendSpaceLine(3, "if(strErr!=\"\")");
            strclass.AppendSpaceLine(3, "{");
            strclass.AppendSpaceLine(4, "MessageBox.Show(this,strErr);");
            strclass.AppendSpaceLine(4, "return;");
            strclass.AppendSpaceLine(3, "}");
            strclass.AppendLine(strclass0.ToString());
            strclass.AppendSpaceLine(3, ModelSpace + " model=new " + ModelSpace + "();");
            strclass.AppendLine(strclass2.ToString());
            strclass.AppendSpaceLine(3, BLLSpace + " bll=new " + BLLSpace + "();");
            strclass.AppendSpaceLine(3, "bll.Add(model);");
            strclass.AppendSpaceLine(3, NameSpace + ".Common.MessageBox.ShowAndRedirect(this,\"����ɹ���\",\"add.aspx\");");
            return strclass.Value;
        }
Exemple #55
0
        /// <summary>
        /// 得到Add()的代码
        /// </summary>
        public string CreatAdd()
        {
            if (ModelSpace == "")
            {
                //ModelSpace = "ModelClassName"; ;
            }
            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, "{");
            strclass.AppendSpaceLine(3, "StringBuilder strSql=new StringBuilder();");
            strclass.AppendSpaceLine(3, "strSql.Append(\"insert into " + _tablename + "(\");");
            strclass1.AppendSpace(3, "strSql.Append(\"");
            int n = 0;

            foreach (ColumnInfo field in Fieldlist)
            {
                string columnName = field.ColumnName;
                string columnType = field.TypeName;
                bool   IsIdentity = field.IsIdentity;
                string Length     = field.Length;
                if (field.IsIdentity)
                {
                    continue;
                }
                strclass3.AppendSpaceLine(5, "new " + DbParaHead + "Parameter(\"" + preParameter + columnName + "\", " + DbParaDbType + "." + CodeCommon.DbTypeLength(dbobj.DbType, columnType, Length) + "),");
                strclass1.Append(columnName + ",");
                strclass2.Append(preParameter + columnName + ",");
                strclass4.AppendSpaceLine(3, "parameters[" + n + "].Value = model." + columnName + ";");
                n++;
            }

            //去掉最后的逗号
            strclass1.DelLastComma();
            strclass2.DelLastComma();
            strclass3.DelLastComma();
            strclass1.AppendLine(")\");");
            strclass.Append(strclass1.ToString());
            strclass.AppendSpaceLine(3, "strSql.Append(\" values (\");");
            strclass.AppendSpaceLine(3, "strSql.Append(\"" + strclass2.ToString() + ")\");");
            if ((dbobj.DbType == "SQL2000" || dbobj.DbType == "SQL2005" || dbobj.DbType == "SQL2008") && (IsHasIdentity))
            {
                strclass.AppendSpaceLine(3, "strSql.Append(\";select @@IDENTITY\");");
            }
            strclass.AppendSpaceLine(3, "" + DbParaHead + "Parameter[] parameters = {");
            strclass.Append(strclass3.Value);
            strclass.AppendLine("};");
            strclass.AppendLine(strclass4.Value);

            //重新定义方法头
            if ((dbobj.DbType == "SQL2000" || dbobj.DbType == "SQL2005" || dbobj.DbType == "SQL2008") && (IsHasIdentity))
            {
                strclass.AppendSpaceLine(3, "object obj = " + DbHelperName + ".GetSingle(strSql.ToString(),parameters);");
                strclass.AppendSpaceLine(3, "if (obj == null)");
                strclass.AppendSpaceLine(3, "{");
                strclass.AppendSpaceLine(4, "return 1;");
                strclass.AppendSpaceLine(3, "}");
                strclass.AppendSpaceLine(3, "else");
                strclass.AppendSpaceLine(3, "{");
                strclass.AppendSpaceLine(4, "return Convert.ToInt32(obj);");
                strclass.AppendSpaceLine(3, "}");
            }
            else
            {
                strclass.AppendSpaceLine(3, "" + DbHelperName + ".ExecuteSql(strSql.ToString(),parameters);");
            }
            strclass.AppendSpace(2, "}");
            return(strclass.ToString());
        }
Exemple #56
0
 /// <summary>
 /// ɾ��ҳ��
 /// </summary>
 /// <returns></returns>
 public string GetDeleteAspxCs()
 {
     StringPlus strclass = new StringPlus();
     strclass.AppendSpaceLine(1, "if(!Page.IsPostBack)");
     strclass.AppendSpaceLine(2, "{");
     strclass.AppendSpaceLine(3, BLLSpace + " bll=new " + BLLSpace + "();");
     switch (_keyType.Trim())
     {
         case "int":
         case "long":
         case "smallint":
         case "float":
         case "numeric":
         case "decimal":
         case "datetime":
         case "smalldatetime":
             strclass.AppendSpaceLine(3, _keyType + " " + _key + "=" + _keyType + ".Parse(Request.Params[\"id\"]);");
             break;
         default:
             strclass.AppendSpaceLine(3, "string " + _key + "=Request.Params[\"id\"];");
             break;
     }
     strclass.AppendSpaceLine(3, "bll.Delete(" + _key + ");");
     strclass.AppendSpaceLine(3, "Response.Redirect(\"list.aspx\");");
     strclass.AppendSpaceLine(2, "}");
     return strclass.Value;
 }
        private string BuilderModel()
        {
            StringPlus plus = new StringPlus();
            StringPlus plus2 = new StringPlus();
            StringPlus plus3 = new StringPlus();
            plus.AppendSpaceLine(2, "#region Model");
            foreach (ColumnInfo column in Columns)
            {
                if (!string.IsNullOrWhiteSpace(column.DefaultVal))
                {
                    var val = "";
                    if (column.TypeName.ToLower().Contains("bool"))
                    {
                        switch (val)
                        {
                            case "b'0'":
                                val = "0";
                                break;
                            case "b'1'":
                                val = "1";
                                break;
                        }
                        val = DataUtils.ConvertValue<bool>(column.DefaultVal) ? "true" : "false";
                    }
                    else if (column.TypeName.ToLower().Contains("string"))
                    {
                        val = "\"" + column.DefaultVal + "\"";
                    }
                    else if (column.TypeName.ToLower().Contains("guid"))
                    {
                        Guid tempGuid;
                        if (Guid.TryParse(column.DefaultVal, out tempGuid))
                        {
                            val = "Guid.Parse(\"" + column.DefaultVal + "\")";
                        }
                        else
                        {
                            val = "Guid.NewGuid()";
                        }
                    }
                    else if (column.TypeName.ToLower().Contains("int"))
                    {
                        val = column.DefaultVal;
                    }
                    else if (column.TypeName.ToLower().Contains("decimal"))
                    {
                        val = column.DefaultVal + "M";
                    }
                    else if (column.TypeName.ToLower().Contains("float"))
                    {
                        val = column.DefaultVal + "F";
                    }
                    if (string.IsNullOrWhiteSpace(val))
                    {
                        plus2.AppendSpaceLine(2, "private " + column.TypeName + " _" + column.ColumnName + ";");
                    }
                    else
                    {
                        plus2.AppendSpaceLine(2, "private " + column.TypeName + " _" + column.ColumnName + " = " + val + ";");
                    }
                }
                else
                {
                    plus2.AppendSpaceLine(2, "private " + column.TypeName + " _" + column.ColumnName + ";");
                }
                plus3.AppendSpaceLine(2, "/// <summary>");
                plus3.AppendSpaceLine(2, "/// " + column.DeText);
                plus3.AppendSpaceLine(2, "/// </summary>");
                plus3.AppendSpaceLine(2, "public " + column.TypeName + " " + column.ColumnName);
                plus3.AppendSpaceLine(2, "{");
                plus3.AppendSpaceLine(3, "get{ return _" + column.ColumnName + "; }");
                plus3.AppendSpaceLine(3, "set");
                plus3.AppendSpaceLine(3, "{");
                plus3.AppendSpaceLine(4, "this.OnPropertyValueChange(_." + column.ColumnName + ",_" + column.ColumnName + ",value);");
                plus3.AppendSpaceLine(4, "this._" + column.ColumnName + "=value;");
                plus3.AppendSpaceLine(3, "}");
                plus3.AppendSpaceLine(2, "}");
            }
            plus.Append(plus2.Value);
            plus.Append(plus3.Value);
            plus.AppendSpaceLine(2, "#endregion");

            return plus.ToString();


        }
Exemple #58
0
        /// <summary>
        /// �õ���ʾ���б�����html����
        /// </summary>     
        public string GetListAspx()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendLine();

            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 (IsIdentity)
                {
                    continue;
                }

                if (isFilterColume(columnName))
                {
                    continue;
                }

                switch (columnType.Trim().ToLower())
                {
                    case "bit":
                    case "dateTime":
                        strclass.AppendSpaceLine(2, "<asp:BoundField DataField=\"" + columnName + "\" HeaderText=\"" + deText + "\" SortExpression=\"" + columnName + "\" ItemStyle-HorizontalAlign=\"Center\"  /> ");
                        break;
                    default:
                        strclass.AppendSpaceLine(2, "<asp:BoundField DataField=\"" + columnName + "\" HeaderText=\"" + deText + "\" SortExpression=\"" + columnName + "\" ItemStyle-HorizontalAlign=\"Center\"  /> ");
                        break;
                }
            }
            return strclass.ToString();
        }
        public string Builder()
        {
            Columns = DbToCS.DbtoCSColumns(Columns);

            StringPlus plus = new StringPlus();
            plus.AppendLine("//------------------------------------------------------------------------------");
            plus.AppendLine("// <auto-generated>");
            plus.AppendLine("//     此代码由工具生成。");
            plus.AppendLine("//     运行时版本:" + Environment.Version.ToString());
            plus.AppendLine("//     Support: http://www.cnblogs.com/huxj");
            plus.AppendLine("//     Website: http://ITdos.com/Dos/ORM/Index.html");
            plus.AppendLine("//     对此文件的更改可能会导致不正确的行为,并且如果");
            plus.AppendLine("//     重新生成代码,这些更改将会丢失。");
            plus.AppendLine("// </auto-generated>");
            plus.AppendLine("//------------------------------------------------------------------------------");
            plus.AppendLine();
            plus.AppendLine();
            plus.AppendLine("using System;");
            plus.AppendLine("using System.Data;");
            plus.AppendLine("using System.Data.Common;");
            plus.AppendLine("using Dos.ORM;");
            plus.AppendLine("using Dos.ORM.Common;");
            plus.AppendLine();
            plus.AppendLine("namespace " + NameSpace);
            plus.AppendLine("{");
            plus.AppendLine();
            plus.AppendSpaceLine(1, "/// <summary>");
            plus.AppendSpaceLine(1, "/// 实体类" + ClassName + " 。(属性说明自动提取数据库字段的描述信息)");
            plus.AppendSpaceLine(1, "/// </summary>");
            plus.AppendSpaceLine(1, "[Serializable]");
            plus.AppendSpaceLine(1, "public partial class " + ClassName + " : Entity ");
            plus.AppendSpaceLine(1, "{");
            plus.AppendSpaceLine(2, "public " + ClassName + "():base(\"" + TableName + "\") {}");
            plus.AppendLine();
            plus.AppendLine(BuilderModel());
            plus.AppendLine(BuilderMethod());
            plus.AppendSpaceLine(1, "}");
            plus.AppendLine("}");
            plus.AppendLine("");
            return plus.ToString();
        }
Exemple #60
0
        /// <summary>
        /// �õ���ʾ���б����Ĵ���
        /// </summary>       
        public string GetListAspxCs()
        {
            StringPlus strclass = new StringPlus();
            strclass.AppendLine();
            strclass.AppendSpace(2, BLLSpace + " bll = new " + BLLSpace + "();");

            return strclass.ToString();
        }