/// <summary> /// 增加一条数据 /// </summary> public bool Add(ScrapyForm.Model.spiderconfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into spiderconfig("); strSql.Append("ConfigName,SpiderPath,LogName,SpiderOutPut,AutoParms)"); strSql.Append(" values ("); strSql.Append("@ConfigName,@SpiderPath,@LogName,@SpiderOutPut,@AutoParms)"); MySqlParameter[] parameters = { new MySqlParameter("@ConfigName", MySqlDbType.VarChar, 100), new MySqlParameter("@SpiderPath", MySqlDbType.VarChar, 512), new MySqlParameter("@LogName", MySqlDbType.VarChar, 256), new MySqlParameter("@SpiderOutPut", MySqlDbType.VarChar, 256), new MySqlParameter("@AutoParms", MySqlDbType.VarChar, 256) }; parameters[0].Value = model.ConfigName; parameters[1].Value = model.SpiderPath; parameters[2].Value = model.LogName; parameters[3].Value = model.SpiderOutPut; parameters[4].Value = model.AutoParms; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ScrapyForm.Model.spiderconfig DataRowToModel(DataRow row) { ScrapyForm.Model.spiderconfig model = new ScrapyForm.Model.spiderconfig(); if (row != null) { if (row["Cid"] != null && row["Cid"].ToString() != "") { model.Cid = int.Parse(row["Cid"].ToString()); } if (row["ConfigName"] != null) { model.ConfigName = row["ConfigName"].ToString(); } if (row["SpiderPath"] != null) { model.SpiderPath = row["SpiderPath"].ToString(); } if (row["LogName"] != null) { model.LogName = row["LogName"].ToString(); } if (row["SpiderOutPut"] != null) { model.SpiderOutPut = row["SpiderOutPut"].ToString(); } if (row["AutoParms"] != null) { model.AutoParms = row["AutoParms"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ScrapyForm.Model.spiderconfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update spiderconfig set "); strSql.Append("ConfigName=@ConfigName,"); strSql.Append("SpiderPath=@SpiderPath,"); strSql.Append("LogName=@LogName,"); strSql.Append("SpiderOutPut=@SpiderOutPut,"); strSql.Append("AutoParms=@AutoParms"); strSql.Append(" where Cid=@Cid"); MySqlParameter[] parameters = { new MySqlParameter("@ConfigName", MySqlDbType.VarChar, 100), new MySqlParameter("@SpiderPath", MySqlDbType.VarChar, 512), new MySqlParameter("@LogName", MySqlDbType.VarChar, 256), new MySqlParameter("@SpiderOutPut", MySqlDbType.VarChar, 256), new MySqlParameter("@AutoParms", MySqlDbType.VarChar, 256), new MySqlParameter("@Cid", MySqlDbType.Int32, 11) }; parameters[0].Value = model.ConfigName; parameters[1].Value = model.SpiderPath; parameters[2].Value = model.LogName; parameters[3].Value = model.SpiderOutPut; parameters[4].Value = model.AutoParms; parameters[5].Value = model.Cid; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ScrapyForm.Model.spiderconfig GetModel(int Cid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Cid,ConfigName,SpiderPath,LogName,SpiderOutPut,AutoParms from spiderconfig "); strSql.Append(" where Cid=@Cid"); MySqlParameter[] parameters = { new MySqlParameter("@Cid", MySqlDbType.Int32) }; parameters[0].Value = Cid; ScrapyForm.Model.spiderconfig model = new ScrapyForm.Model.spiderconfig(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }