Ejemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ALS.Model.syringecal DataRowToModel(DataRow row)
 {
     ALS.Model.syringecal model = new ALS.Model.syringecal();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["brand"] != null)
         {
             model.brand = row["brand"].ToString();
         }
         if (row["version"] != null && row["version"].ToString() != "")
         {
             model.version = int.Parse(row["version"].ToString());
         }
         if (row["calibre"] != null && row["calibre"].ToString() != "")
         {
             model.calibre = int.Parse(row["calibre"].ToString());
         }
         if (row["compdis"] != null && row["compdis"].ToString() != "")
         {
             model.compdis = int.Parse(row["compdis"].ToString());
         }
         if (row["length"] != null && row["length"].ToString() != "")
         {
             model.length = int.Parse(row["length"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ALS.Model.syringecal model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_syringecal(");
            strSql.Append("brand,version,calibre,compdis,length)");
            strSql.Append(" values (");
            strSql.Append("@brand,@version,@calibre,@compdis,@length)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@brand",   MySqlDbType.VarChar, 100),
                new MySqlParameter("@version", MySqlDbType.Int32,    11),
                new MySqlParameter("@calibre", MySqlDbType.Int32,    11),
                new MySqlParameter("@compdis", MySqlDbType.Int32,    11),
                new MySqlParameter("@length",  MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.brand;
            parameters[1].Value = model.version;
            parameters[2].Value = model.calibre;
            parameters[3].Value = model.compdis;
            parameters[4].Value = model.length;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ALS.Model.syringecal model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_syringecal set ");
            strSql.Append("calibre=@calibre,");
            strSql.Append("compdis=@compdis,");
            strSql.Append("length=@length");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@calibre", MySqlDbType.Int32,    11),
                new MySqlParameter("@compdis", MySqlDbType.Int32,    11),
                new MySqlParameter("@length",  MySqlDbType.Int32,    11),
                new MySqlParameter("@ID",      MySqlDbType.Int32,    11),
                new MySqlParameter("@brand",   MySqlDbType.VarChar, 100),
                new MySqlParameter("@version", MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.calibre;
            parameters[1].Value = model.compdis;
            parameters[2].Value = model.length;
            parameters[3].Value = model.ID;
            parameters[4].Value = model.brand;
            parameters[5].Value = model.version;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ALS.Model.syringecal GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,brand,version,calibre,compdis,length from tb_syringecal ");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID", MySqlDbType.Int32)
            };
            parameters[0].Value = ID;

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

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