/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.T_StationOnline model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_StationOnline set "); strSql.Append("LastOnlineIp=@LastOnlineIp,"); strSql.Append("PW=@PW,"); strSql.Append("UpdateTime=@UpdateTime"); strSql.Append(" where Mncode=@Mncode "); SqlParameter[] parameters = { new SqlParameter("@LastOnlineIp", SqlDbType.NVarChar, 50), new SqlParameter("@PW", SqlDbType.NVarChar, 25), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@Mncode", SqlDbType.NVarChar, 25) }; parameters[0].Value = model.LastOnlineIp; parameters[1].Value = model.PW; parameters[2].Value = model.UpdateTime; parameters[3].Value = model.Mncode; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.T_StationOnline model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_StationOnline("); strSql.Append("Mncode,LastOnlineIp,PW,UpdateTime)"); strSql.Append(" values ("); strSql.Append("@Mncode,@LastOnlineIp,@PW,@UpdateTime)"); SqlParameter[] parameters = { new SqlParameter("@Mncode", SqlDbType.NVarChar, 25), new SqlParameter("@LastOnlineIp", SqlDbType.NVarChar, 50), new SqlParameter("@PW", SqlDbType.NVarChar, 25), new SqlParameter("@UpdateTime", SqlDbType.DateTime) }; parameters[0].Value = model.Mncode; parameters[1].Value = model.LastOnlineIp; parameters[2].Value = model.PW; parameters[3].Value = model.UpdateTime; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.T_StationOnline DataRowToModel(DataRow row) { Maticsoft.Model.T_StationOnline model = new Maticsoft.Model.T_StationOnline(); if (row != null) { if (row["Mncode"] != null) { model.Mncode = row["Mncode"].ToString(); } if (row["LastOnlineIp"] != null) { model.LastOnlineIp = row["LastOnlineIp"].ToString(); } if (row["PW"] != null) { model.PW = row["PW"].ToString(); } if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "") { model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.T_StationOnline GetModel(string Mncode) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Mncode,LastOnlineIp,PW,UpdateTime from T_StationOnline "); strSql.Append(" where Mncode=@Mncode "); SqlParameter[] parameters = { new SqlParameter("@Mncode", SqlDbType.NVarChar, 25) }; parameters[0].Value = Mncode; Maticsoft.Model.T_StationOnline model = new Maticsoft.Model.T_StationOnline(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }