Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.testdevice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update testdevice set ");
            strSql.Append("devicename=@devicename,");
            strSql.Append("devicetest=@devicetest,");
            strSql.Append("remark=@remark");
            strSql.Append(" where devicetype=@devicetype ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@devicename", MySqlDbType.VarChar, 255),
                new MySqlParameter("@devicetest", MySqlDbType.VarChar,  32),
                new MySqlParameter("@remark",     MySqlDbType.VarChar, 255),
                new MySqlParameter("@devicetype", MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.devicename;
            parameters[1].Value = model.devicetest;
            parameters[2].Value = model.remark;
            parameters[3].Value = model.devicetype;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.testdevice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into testdevice(");
            strSql.Append("devicetype,devicename,devicetest,remark)");
            strSql.Append(" values (");
            strSql.Append("@devicetype,@devicename,@devicetest,@remark)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@devicetype", MySqlDbType.Int32,    11),
                new MySqlParameter("@devicename", MySqlDbType.VarChar, 255),
                new MySqlParameter("@devicetest", MySqlDbType.VarChar,  32),
                new MySqlParameter("@remark",     MySqlDbType.VarChar, 255)
            };
            parameters[0].Value = model.devicetype;
            parameters[1].Value = model.devicename;
            parameters[2].Value = model.devicetest;
            parameters[3].Value = model.remark;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.testdevice DataRowToModel(DataRow row)
 {
     Maticsoft.Model.testdevice model = new Maticsoft.Model.testdevice();
     if (row != null)
     {
         if (row["devicetype"] != null && row["devicetype"].ToString() != "")
         {
             model.devicetype = int.Parse(row["devicetype"].ToString());
         }
         if (row["devicename"] != null)
         {
             model.devicename = row["devicename"].ToString();
         }
         if (row["devicetest"] != null)
         {
             model.devicetest = row["devicetest"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.testdevice GetModel(int devicetype)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select devicetype,devicename,devicetest,remark from testdevice ");
            strSql.Append(" where devicetype=@devicetype ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@devicetype", MySqlDbType.Int32, 11)
            };
            parameters[0].Value = devicetype;

            Maticsoft.Model.testdevice model = new Maticsoft.Model.testdevice();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }