Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(tb_DrugLock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_DrugLock set ");

            strSql.Append(" temp2 = @temp2 , ");
            strSql.Append(" pic = @pic , ");
            strSql.Append(" lockName = @lockName , ");
            strSql.Append(" mark = @mark , ");
            strSql.Append(" createUser = @createUser , ");
            strSql.Append(" createDate = @createDate , ");
            strSql.Append(" updateUser = @updateUser , ");
            strSql.Append(" updateDate = @updateDate , ");
            strSql.Append(" lockType = @lockType , ");
            strSql.Append(" temp1 = @temp1  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",         SqlDbType.Int,         4),
                new SqlParameter("@temp2",      SqlDbType.NVarChar,   -1),
                new SqlParameter("@pic",        SqlDbType.NVarChar,  256),
                new SqlParameter("@lockName",   SqlDbType.NVarChar,   -1),
                new SqlParameter("@mark",       SqlDbType.NVarChar,   50),
                new SqlParameter("@createUser", SqlDbType.Int,         4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@updateUser", SqlDbType.Int,         4),
                new SqlParameter("@updateDate", SqlDbType.DateTime),
                new SqlParameter("@lockType",   SqlDbType.NVarChar,  100),
                new SqlParameter("@temp1",      SqlDbType.NVarChar, -1)
            };

            parameters[0].Value  = model.id;
            parameters[1].Value  = model.temp2;
            parameters[2].Value  = model.pic;
            parameters[3].Value  = model.lockName;
            parameters[4].Value  = model.mark;
            parameters[5].Value  = model.createUser;
            parameters[6].Value  = model.createDate;
            parameters[7].Value  = model.updateUser;
            parameters[8].Value  = model.updateDate;
            parameters[9].Value  = model.lockType;
            parameters[10].Value = model.temp1;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public tb_DrugLock DataRowToModel(DataRow row)
        {
            tb_DrugLock model = new tb_DrugLock();

            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["lockName"] != null)
                {
                    model.lockName = row["lockName"].ToString();
                }
                if (row["mark"] != null)
                {
                    model.mark = row["mark"].ToString();
                }
                if (row["createUser"] != null && row["createUser"].ToString() != "")
                {
                    model.createUser = int.Parse(row["createUser"].ToString());
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.createDate = DateTime.Parse(row["createDate"].ToString());
                }
                if (row["updateUser"] != null && row["updateUser"].ToString() != "")
                {
                    model.updateUser = int.Parse(row["updateUser"].ToString());
                }
                if (row["updateDate"] != null && row["updateDate"].ToString() != "")
                {
                    model.updateDate = DateTime.Parse(row["updateDate"].ToString());
                }
                if (row["lockType"] != null)
                {
                    model.lockType = row["lockType"].ToString();
                }
                if (row["temp1"] != null)
                {
                    model.temp1 = row["temp1"].ToString();
                }
                if (row["temp2"] != null)
                {
                    model.temp2 = row["temp2"].ToString();
                }
                if (row["pic"] != null)
                {
                    model.pic = row["pic"].ToString();
                }
            }
            return(model);
        }
Exemple #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(tb_DrugLock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_DrugLock(");
            strSql.Append("temp2,pic,lockName,mark,createUser,createDate,updateUser,updateDate,lockType,temp1");
            strSql.Append(") values (");
            strSql.Append("@temp2,@pic,@lockName,@mark,@createUser,@createDate,@updateUser,@updateDate,@lockType,@temp1");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@temp2",      SqlDbType.NVarChar,   -1),
                new SqlParameter("@pic",        SqlDbType.NVarChar,  256),
                new SqlParameter("@lockName",   SqlDbType.NVarChar,   -1),
                new SqlParameter("@mark",       SqlDbType.NVarChar,   50),
                new SqlParameter("@createUser", SqlDbType.Int,         4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@updateUser", SqlDbType.Int,         4),
                new SqlParameter("@updateDate", SqlDbType.DateTime),
                new SqlParameter("@lockType",   SqlDbType.NVarChar,  100),
                new SqlParameter("@temp1",      SqlDbType.NVarChar, -1)
            };

            parameters[0].Value = model.temp2;
            parameters[1].Value = model.pic;
            parameters[2].Value = model.lockName;
            parameters[3].Value = model.mark;
            parameters[4].Value = model.createUser;
            parameters[5].Value = model.createDate;
            parameters[6].Value = model.updateUser;
            parameters[7].Value = model.updateDate;
            parameters[8].Value = model.lockType;
            parameters[9].Value = model.temp1;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public tb_DrugLock GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from tb_DrugLock ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            tb_DrugLock model = new tb_DrugLock();
            DataSet     ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(tb_DrugLock model)
 {
     return(dal.Update(model));
 }
Exemple #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(tb_DrugLock model)
 {
     return(dal.Add(model));
 }