public GuessResultModel Get(int id) { DataTable dt = SqlHelper.ExecuteDataTable("select * from GuessResult where id=@id", new MySqlParameter("id", id)); if (dt.Rows.Count <= 0) { return(null); } else if (dt.Rows.Count == 1) { GuessResultModel model = new GuessResultModel(); DataRow row = dt.Rows[0]; model.id = (int)row["id"]; model.StuName = (string)row["StuName"]; model.IP = (string)GetNull(row["IP"]); model.Lun = (int)row["Lun"]; model.GuessPath = (string)row["GuessPath"]; model.GuessNumber = (int)row["GuessNumber"]; model.Remark = (string)GetNull(row["Remark"]); return(model); } else { throw new Exception("出现多条数据!"); } }
public int AddNew(GuessResultModel model) { object obj = SqlHelper.ExecuteScalar("insert into GuessResult(StuName,IP,Lun,GuessPath,GuessNumber,Remark) values(@StuName,@IP,@Lun,@GuessPath,@GuessNumber,@Remark )", new MySqlParameter("StuName", model.StuName), new MySqlParameter("IP", PutNull(model.IP)), new MySqlParameter("Lun", model.Lun), new MySqlParameter("GuessPath", model.GuessPath), new MySqlParameter("GuessNumber", model.GuessNumber), new MySqlParameter("Remark", PutNull(model.Remark))); return(Convert.ToInt32(obj)); }
public int Update(GuessResultModel model) { object obj = SqlHelper.ExecuteScalar("update GuessResult set StuName=@StuName,IP=@IP,Lun=@Lun,GuessPath=@GuessPath,GuessNumber=@GuessNumber,Remark=@Remark where id=@id", new MySqlParameter("StuName", model.StuName), new MySqlParameter("IP", PutNull(model.IP)), new MySqlParameter("Lun", model.Lun), new MySqlParameter("GuessPath", model.GuessPath), new MySqlParameter("GuessNumber", model.GuessNumber), new MySqlParameter("Remark", PutNull(model.Remark)), new MySqlParameter("id", model.id)); return(Convert.ToInt32(obj)); }
public IEnumerable <GuessResultModel> GetAll() { DataTable dt = SqlHelper.ExecuteDataTable("select * from GuessResult"); List <GuessResultModel> list = new List <GuessResultModel>(); foreach (DataRow row in dt.Rows) { GuessResultModel model = new GuessResultModel(); model.id = (int)row["id"]; model.StuName = (string)row["StuName"]; model.IP = (string)GetNull(row["IP"]); model.Lun = (int)row["Lun"]; model.GuessPath = (string)row["GuessPath"]; model.GuessNumber = (int)row["GuessNumber"]; model.Remark = (string)GetNull(row["Remark"]); list.Add(model); } return(list); }
public int AddNew(GuessResultModel model) { return(new GuessResultDAL().AddNew(model)); }
public int Update(GuessResultModel model) { return(new GuessResultDAL().Update(model)); }