/// <summary> /// 更新一条数据 /// </summary> public bool Update(CdHotelManage.Model.SuoSys model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SuoSys set "); strSql.Append("SuoTypeName=@SuoTypeName,"); strSql.Append("IsComm=@IsComm,"); strSql.Append("IsBackSuo=@IsBackSuo"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@SuoTypeName", SqlDbType.NVarChar, 50), new SqlParameter("@IsComm", SqlDbType.Bit, 1), new SqlParameter("@IsBackSuo", SqlDbType.Bit, 1), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.SuoTypeName; parameters[1].Value = model.IsComm; parameters[2].Value = model.IsBackSuo; parameters[3].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(CdHotelManage.Model.SuoSys model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SuoSys("); strSql.Append("SuoTypeName,IsComm,IsBackSuo)"); strSql.Append(" values ("); strSql.Append("@SuoTypeName,@IsComm,@IsBackSuo)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@SuoTypeName", SqlDbType.NVarChar, 50), new SqlParameter("@IsComm", SqlDbType.Bit, 1), new SqlParameter("@IsBackSuo", SqlDbType.Bit, 1) }; parameters[0].Value = model.SuoTypeName; parameters[1].Value = model.IsComm; parameters[2].Value = model.IsBackSuo; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public CdHotelManage.Model.SuoSys DataRowToModel(DataRow row) { CdHotelManage.Model.SuoSys model = new CdHotelManage.Model.SuoSys(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["SuoTypeName"] != null) { model.SuoTypeName = row["SuoTypeName"].ToString(); } if (row["IsComm"] != null && row["IsComm"].ToString() != "") { if ((row["IsComm"].ToString() == "1") || (row["IsComm"].ToString().ToLower() == "true")) { model.IsComm = true; } else { model.IsComm = false; } } if (row["IsBackSuo"] != null && row["IsBackSuo"].ToString() != "") { if ((row["IsBackSuo"].ToString() == "1") || (row["IsBackSuo"].ToString().ToLower() == "true")) { model.IsBackSuo = true; } else { model.IsBackSuo = false; } } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public CdHotelManage.Model.SuoSys GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,SuoTypeName,IsComm,IsBackSuo from SuoSys "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; CdHotelManage.Model.SuoSys model = new CdHotelManage.Model.SuoSys(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }