Example #1
0
        public List <YHFramework.SysModel.CodeDataModel> GetModelListByCodelist(List <string> codelist)
        {
            List <YHFramework.SysModel.CodeDataModel> result = new List <YHFramework.SysModel.CodeDataModel>();
            string        sql         = "select * from CodeData where CodeData in ({0})";
            StringBuilder codebuilder = new StringBuilder();

            foreach (var item in codelist)
            {
                codebuilder.Append("'" + item.FixSql() + "',");
            }
            sql = string.Format(sql, codebuilder.ToString().TrimEnd(','));

            YHFramework.SysModel.CodeDataModel model = new YHFramework.SysModel.CodeDataModel();
            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, sql.ToString());

            //var fields = DbTool.GetReaderFieldNames(dr);
            while (dr.Read())
            {
                //model = AutoBindDataReader(dr, fields);
                model = new YHFramework.SysModel.CodeDataModel();
                BindDataReader(model, dr);
                result.Add(model);
            }
            dr.Close();
            return(result);
        }
Example #2
0
        public int Update(YHFramework.SysModel.CodeDataModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CodeData set ");
            strSql.Append("CodeData=@CodeData,ShortCodeData=@ShortCodeData,CodeIndex=@CodeIndex,BatchNumber=@BatchNumber,BoxNumberId=@BoxNumberId,ContentStatusId=@ContentStatusId,UpdateOn=@UpdateOn,Createon=@Createon,ApployInfoId=@ApployInfoId ");
            strSql.Append(" where CodeDataId=@CodeDataId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@CodeData", DbTool.FixSqlParameter(model.CodeData))
                ,                             new SqlParameter("@ShortCodeData", DbTool.FixSqlParameter(model.ShortCodeData))
                ,                             new SqlParameter("@CodeIndex", DbTool.FixSqlParameter(model.CodeIndex))
                ,                             new SqlParameter("@BatchNumber", DbTool.FixSqlParameter(model.BatchNumber))
                ,                             new SqlParameter("@BoxNumberId", DbTool.FixSqlParameter(model.BoxNumberId))
                ,                             new SqlParameter("@ContentStatusId", DbTool.FixSqlParameter(model.ContentStatusId))
                ,                             new SqlParameter("@UpdateOn", DbTool.FixSqlParameter(model.UpdateOn))
                ,                             new SqlParameter("@Createon", DbTool.FixSqlParameter(model.Createon))
                ,                             new SqlParameter("@ApployInfoId", DbTool.FixSqlParameter(model.ApployInfoId))
                ,                             new SqlParameter("@CodeDataId", model.CodeDataId)
            };


            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters));
        }
Example #3
0
 protected void BindDataReader(YHFramework.SysModel.CodeDataModel model, SqlDataReader dr)
 {
     model.CodeDataId      = DbTool.ConvertObject <System.Int32>(dr["CodeDataId"]);
     model.CodeData        = DbTool.ConvertObject <System.String>(dr["CodeData"]);
     model.ShortCodeData   = DbTool.ConvertObject <System.String>(dr["ShortCodeData"]);
     model.CodeIndex       = DbTool.ConvertObject <System.String>(dr["CodeIndex"]);
     model.BatchNumber     = DbTool.ConvertObject <System.String>(dr["BatchNumber"]);
     model.BoxNumberId     = DbTool.ConvertObject <System.Int32>(dr["BoxNumberId"]);
     model.ContentStatusId = DbTool.ConvertObject <System.Int32>(dr["ContentStatusId"]);
     model.UpdateOn        = DbTool.ConvertObject <System.DateTime>(dr["UpdateOn"]);
     model.Createon        = DbTool.ConvertObject <System.DateTime>(dr["Createon"]);
     model.ApployInfoId    = DbTool.ConvertObject <System.Int32>(dr["ApployInfoId"]);
 }
Example #4
0
        public YHFramework.SysModel.CodeDataModel GetModel(int Id)
        {
            string sql = "select top 1 * from CodeData where CodeDataId =" + Id;

            YHFramework.SysModel.CodeDataModel model = new YHFramework.SysModel.CodeDataModel();
            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, sql.ToString());

            if (dr.Read())
            {
                //var fields = DbTool.GetReaderFieldNames(dr);
                //model = AutoBindDataReader(dr, fields);
                BindDataReader(model, dr);
            }
            dr.Close();
            return(model);
        }
Example #5
0
        protected YHFramework.SysModel.CodeDataModel AutoBindDataReader(SqlDataReader dr, params string[] fields)
        {
            var model = new YHFramework.SysModel.CodeDataModel();

            if (DbTool.HasFields("CodeDataId", fields))
            {
                model.CodeDataId = DbTool.ConvertObject <System.Int32>(dr["CodeDataId"]);
            }
            if (DbTool.HasFields("CodeData", fields))
            {
                model.CodeData = DbTool.ConvertObject <System.String>(dr["CodeData"]);
            }
            if (DbTool.HasFields("ShortCodeData", fields))
            {
                model.ShortCodeData = DbTool.ConvertObject <System.String>(dr["ShortCodeData"]);
            }
            if (DbTool.HasFields("CodeIndex", fields))
            {
                model.CodeIndex = DbTool.ConvertObject <System.String>(dr["CodeIndex"]);
            }
            if (DbTool.HasFields("BatchNumber", fields))
            {
                model.BatchNumber = DbTool.ConvertObject <System.String>(dr["BatchNumber"]);
            }
            if (DbTool.HasFields("BoxNumberId", fields))
            {
                model.BoxNumberId = DbTool.ConvertObject <System.Int32>(dr["BoxNumberId"]);
            }
            if (DbTool.HasFields("ContentStatusId", fields))
            {
                model.ContentStatusId = DbTool.ConvertObject <System.Int32>(dr["ContentStatusId"]);
            }
            if (DbTool.HasFields("UpdateOn", fields))
            {
                model.UpdateOn = DbTool.ConvertObject <System.DateTime>(dr["UpdateOn"]);
            }
            if (DbTool.HasFields("Createon", fields))
            {
                model.Createon = DbTool.ConvertObject <System.DateTime>(dr["Createon"]);
            }
            if (DbTool.HasFields("ApployInfoId", fields))
            {
                model.ApployInfoId = DbTool.ConvertObject <System.Int32>(dr["ApployInfoId"]);
            }

            return(model);
        }
Example #6
0
        public List <YHFramework.SysModel.CodeDataModel> GetModelList()
        {
            List <YHFramework.SysModel.CodeDataModel> result = new List <YHFramework.SysModel.CodeDataModel>();
            string sql = "select * from CodeData where 1=1";

            YHFramework.SysModel.CodeDataModel model = new YHFramework.SysModel.CodeDataModel();
            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, sql.ToString());

            //var fields = DbTool.GetReaderFieldNames(dr);
            while (dr.Read())
            {
                //model = AutoBindDataReader(dr, fields);
                model = new YHFramework.SysModel.CodeDataModel();
                BindDataReader(model, dr);
                result.Add(model);
            }
            dr.Close();
            return(result);
        }
Example #7
0
        public int Add(YHFramework.SysModel.CodeDataModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into  [CodeData]");
            strSql.Append("(CodeData,ShortCodeData,CodeIndex,BatchNumber,BoxNumberId,ContentStatusId,UpdateOn,Createon,ApployInfoId)");
            strSql.Append(" values (@CodeData,@ShortCodeData,@CodeIndex,@BatchNumber,@BoxNumberId,@ContentStatusId,@UpdateOn,@Createon,@ApployInfoId)");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CodeData", DbTool.FixSqlParameter(model.CodeData))
                ,                             new SqlParameter("@ShortCodeData", DbTool.FixSqlParameter(model.ShortCodeData))
                ,                             new SqlParameter("@CodeIndex", DbTool.FixSqlParameter(model.CodeIndex))
                ,                             new SqlParameter("@BatchNumber", DbTool.FixSqlParameter(model.BatchNumber))
                ,                             new SqlParameter("@BoxNumberId", DbTool.FixSqlParameter(model.BoxNumberId))
                ,                             new SqlParameter("@ContentStatusId", DbTool.FixSqlParameter(model.ContentStatusId))
                ,                             new SqlParameter("@UpdateOn", DbTool.FixSqlParameter(model.UpdateOn))
                ,                             new SqlParameter("@Createon", DbTool.FixSqlParameter(model.Createon))
                ,                             new SqlParameter("@ApployInfoId", DbTool.FixSqlParameter(model.ApployInfoId))
            };


            return(DbTool.ConvertObject <int>(SqlHelper.ExecuteScalar(conn, CommandType.Text, strSql.ToString(), parameters), 0));
        }