Beispiel #1
0
 /// <summary>
 /// 由一行数据得到一个实体
 /// </summary>
 private Hi.Model.BD_DefDoc_B GetModel(DataRow r)
 {
     Hi.Model.BD_DefDoc_B model = new Hi.Model.BD_DefDoc_B();
     model.ID         = SqlHelper.GetInt(r["ID"]);
     model.CompID     = SqlHelper.GetInt(r["CompID"]);
     model.DefID      = SqlHelper.GetInt(r["DefID"]);
     model.AtName     = SqlHelper.GetString(r["AtName"]);
     model.AtVal      = SqlHelper.GetString(r["AtVal"]);
     model.SortIndex  = SqlHelper.GetString(r["SortIndex"]);
     model.ts         = SqlHelper.GetDateTime(r["ts"]);
     model.dr         = SqlHelper.GetInt(r["dr"]);
     model.modifyuser = SqlHelper.GetInt(r["modifyuser"]);
     return(model);
 }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hi.Model.BD_DefDoc_B model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [BD_DefDoc_B] set ");
            strSql.Append("[CompID]=@CompID,");
            strSql.Append("[DefID]=@DefID,");
            strSql.Append("[AtName]=@AtName,");
            strSql.Append("[AtVal]=@AtVal,");
            strSql.Append("[SortIndex]=@SortIndex,");
            strSql.Append("[ts]=@ts,");
            strSql.Append("[dr]=@dr,");
            strSql.Append("[modifyuser]=@modifyuser");
            strSql.Append(" where [ID]=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",         SqlDbType.Int),
                new SqlParameter("@CompID",     SqlDbType.Int),
                new SqlParameter("@DefID",      SqlDbType.Int),
                new SqlParameter("@AtName",     SqlDbType.VarChar,   50),
                new SqlParameter("@AtVal",      SqlDbType.VarChar,   50),
                new SqlParameter("@SortIndex",  SqlDbType.VarChar,   50),
                new SqlParameter("@ts",         SqlDbType.DateTime),
                new SqlParameter("@dr",         SqlDbType.SmallInt),
                new SqlParameter("@modifyuser", SqlDbType.Int)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.CompID;
            parameters[2].Value = model.DefID;

            if (model.AtName != null)
            {
                parameters[3].Value = model.AtName;
            }
            else
            {
                parameters[3].Value = DBNull.Value;
            }


            if (model.AtVal != null)
            {
                parameters[4].Value = model.AtVal;
            }
            else
            {
                parameters[4].Value = DBNull.Value;
            }


            if (model.SortIndex != null)
            {
                parameters[5].Value = model.SortIndex;
            }
            else
            {
                parameters[5].Value = DBNull.Value;
            }


            if (model.ts != DateTime.MinValue)
            {
                parameters[6].Value = model.ts;
            }
            else
            {
                parameters[6].Value = DBNull.Value;
            }

            parameters[7].Value = model.dr;
            parameters[8].Value = model.modifyuser;

            return(SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString(), parameters) > 0);
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hi.Model.BD_DefDoc_B model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [BD_DefDoc_B](");
            strSql.Append("[CompID],[DefID],[AtName],[AtVal],[SortIndex],[ts],[modifyuser])");
            strSql.Append(" values (");
            strSql.Append("@CompID,@DefID,@AtName,@AtVal,@SortIndex,@ts,@modifyuser)");
            strSql.Append(";select @@Identity");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CompID",     SqlDbType.Int),
                new SqlParameter("@DefID",      SqlDbType.Int),
                new SqlParameter("@AtName",     SqlDbType.VarChar,   50),
                new SqlParameter("@AtVal",      SqlDbType.VarChar,   50),
                new SqlParameter("@SortIndex",  SqlDbType.VarChar,   50),
                new SqlParameter("@ts",         SqlDbType.DateTime),
                new SqlParameter("@modifyuser", SqlDbType.Int)
            };
            parameters[0].Value = model.CompID;
            parameters[1].Value = model.DefID;

            if (model.AtName != null)
            {
                parameters[2].Value = model.AtName;
            }
            else
            {
                parameters[2].Value = DBNull.Value;
            }


            if (model.AtVal != null)
            {
                parameters[3].Value = model.AtVal;
            }
            else
            {
                parameters[3].Value = DBNull.Value;
            }


            if (model.SortIndex != null)
            {
                parameters[4].Value = model.SortIndex;
            }
            else
            {
                parameters[4].Value = DBNull.Value;
            }


            if (model.ts != DateTime.MinValue)
            {
                parameters[5].Value = model.ts;
            }
            else
            {
                parameters[5].Value = DBNull.Value;
            }

            parameters[6].Value = model.modifyuser;
            return(SqlHelper.GetInt(SqlHelper.GetSingle(SqlHelper.LocalSqlServer, strSql.ToString(), parameters)));
        }
Beispiel #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.BD_DefDoc_B model, System.Data.SqlClient.SqlTransaction Tran)
 {
     return(dal.Add(model, Tran));
 }