/// <summary> /// 更新一条数据 /// </summary> public bool Update(LumluxSSYDB.Model.tSwitchInfoes model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tSwitchInfoes set "); strSql.Append("iAlarmState=@iAlarmState,"); strSql.Append("iState_Command=@iState_Command,"); strSql.Append("sHostInfo_GUID=@sHostInfo_GUID,"); strSql.Append("dCreateDate=@dCreateDate,"); strSql.Append("sSwitch_GUID=@sSwitch_GUID,"); strSql.Append("dUpdateTiime=@dUpdateTiime,"); strSql.Append("sDesc=@sDesc"); strSql.Append(" where sGUID=@sGUID "); SqlParameter[] parameters = { new SqlParameter("@iAlarmState", SqlDbType.Int, 4), new SqlParameter("@iState_Command", SqlDbType.Int, 4), new SqlParameter("@sHostInfo_GUID", SqlDbType.Char, 36), new SqlParameter("@dCreateDate", SqlDbType.DateTime), new SqlParameter("@sSwitch_GUID", SqlDbType.Char, 36), new SqlParameter("@dUpdateTiime", SqlDbType.DateTime), new SqlParameter("@sDesc", SqlDbType.NVarChar, 500), new SqlParameter("@sGUID", SqlDbType.Char, 36) }; parameters[0].Value = model.iAlarmState; parameters[1].Value = model.iState_Command; parameters[2].Value = model.sHostInfo_GUID; parameters[3].Value = model.dCreateDate; parameters[4].Value = model.sSwitch_GUID; parameters[5].Value = model.dUpdateTiime; parameters[6].Value = model.sDesc; parameters[7].Value = model.sGUID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public LumluxSSYDB.Model.tSwitchInfoes DataRowToModel(DataRow row) { LumluxSSYDB.Model.tSwitchInfoes model = new LumluxSSYDB.Model.tSwitchInfoes(); if (row != null) { if (row["sGUID"] != null) { model.sGUID = row["sGUID"].ToString(); } if (row["iAlarmState"] != null && row["iAlarmState"].ToString() != "") { model.iAlarmState = int.Parse(row["iAlarmState"].ToString()); } if (row["iState_Command"] != null && row["iState_Command"].ToString() != "") { model.iState_Command = int.Parse(row["iState_Command"].ToString()); } if (row["sHostInfo_GUID"] != null) { model.sHostInfo_GUID = row["sHostInfo_GUID"].ToString(); } if (row["dCreateDate"] != null && row["dCreateDate"].ToString() != "") { model.dCreateDate = DateTime.Parse(row["dCreateDate"].ToString()); } if (row["sSwitch_GUID"] != null) { model.sSwitch_GUID = row["sSwitch_GUID"].ToString(); } if (row["dUpdateTiime"] != null && row["dUpdateTiime"].ToString() != "") { model.dUpdateTiime = DateTime.Parse(row["dUpdateTiime"].ToString()); } if (row["sDesc"] != null) { model.sDesc = row["sDesc"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(LumluxSSYDB.Model.tSwitchInfoes model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tSwitchInfoes("); strSql.Append("sGUID,iAlarmState,iState_Command,sHostInfo_GUID,dCreateDate,sSwitch_GUID,dUpdateTiime,sDesc)"); strSql.Append(" values ("); strSql.Append("@sGUID,@iAlarmState,@iState_Command,@sHostInfo_GUID,@dCreateDate,@sSwitch_GUID,@dUpdateTiime,@sDesc)"); SqlParameter[] parameters = { new SqlParameter("@sGUID", SqlDbType.Char, 36), new SqlParameter("@iAlarmState", SqlDbType.Int, 4), new SqlParameter("@iState_Command", SqlDbType.Int, 4), new SqlParameter("@sHostInfo_GUID", SqlDbType.Char, 36), new SqlParameter("@dCreateDate", SqlDbType.DateTime), new SqlParameter("@sSwitch_GUID", SqlDbType.Char, 36), new SqlParameter("@dUpdateTiime", SqlDbType.DateTime), new SqlParameter("@sDesc", SqlDbType.NVarChar, 500) }; parameters[0].Value = model.sGUID; parameters[1].Value = model.iAlarmState; parameters[2].Value = model.iState_Command; parameters[3].Value = model.sHostInfo_GUID; parameters[4].Value = model.dCreateDate; parameters[5].Value = model.sSwitch_GUID; parameters[6].Value = model.dUpdateTiime; parameters[7].Value = model.sDesc; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public LumluxSSYDB.Model.tSwitchInfoes GetModel(string sGUID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 sGUID,iAlarmState,iState_Command,sHostInfo_GUID,dCreateDate,sSwitch_GUID,dUpdateTiime,sDesc from tSwitchInfoes "); strSql.Append(" where sGUID=@sGUID "); SqlParameter[] parameters = { new SqlParameter("@sGUID", SqlDbType.Char, 36) }; parameters[0].Value = sGUID; LumluxSSYDB.Model.tSwitchInfoes model = new LumluxSSYDB.Model.tSwitchInfoes(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }