/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.VideoAttribConfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into VideoAttribConfig("); strSql.Append("GUID,VideoCategoryGUID,VideoAttribConfigName,VideoAttribConfigDescribe,VideoAttribConfigOrder)"); strSql.Append(" values ("); strSql.Append("@GUID,@VideoCategoryGUID,@VideoAttribConfigName,@VideoAttribConfigDescribe,@VideoAttribConfigOrder)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@GUID", SqlDbType.NVarChar, -1), new SqlParameter("@VideoCategoryGUID", SqlDbType.NVarChar, -1), new SqlParameter("@VideoAttribConfigName", SqlDbType.NVarChar, -1), new SqlParameter("@VideoAttribConfigDescribe", SqlDbType.NVarChar, -1), new SqlParameter("@VideoAttribConfigOrder", SqlDbType.Int, 4) }; parameters[0].Value = model.GUID; parameters[1].Value = model.VideoCategoryGUID; parameters[2].Value = model.VideoAttribConfigName; parameters[3].Value = model.VideoAttribConfigDescribe; parameters[4].Value = model.VideoAttribConfigOrder; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.VideoAttribConfig DataRowToModel(DataRow row) { Maticsoft.Model.VideoAttribConfig model = new Maticsoft.Model.VideoAttribConfig(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["GUID"] != null) { model.GUID = row["GUID"].ToString(); } if (row["VideoCategoryGUID"] != null) { model.VideoCategoryGUID = row["VideoCategoryGUID"].ToString(); } if (row["VideoAttribConfigName"] != null) { model.VideoAttribConfigName = row["VideoAttribConfigName"].ToString(); } if (row["VideoAttribConfigDescribe"] != null) { model.VideoAttribConfigDescribe = row["VideoAttribConfigDescribe"].ToString(); } if (row["VideoAttribConfigOrder"] != null && row["VideoAttribConfigOrder"].ToString() != "") { model.VideoAttribConfigOrder = int.Parse(row["VideoAttribConfigOrder"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据,如果属性名称重复,则不更新 /// </summary> public bool ExUpdate(Maticsoft.Model.VideoAttribConfig model, Maticsoft.Model.VideoAttribConfig modelOld) { StringBuilder strSql = new StringBuilder(); strSql.Append("update VideoAttribConfig set "); strSql.Append("GUID=@GUID,"); strSql.Append("VideoCategoryGUID=@VideoCategoryGUID,"); strSql.Append("VideoAttribConfigName=@VideoAttribConfigName,"); strSql.Append("VideoAttribConfigDescribe=@VideoAttribConfigDescribe,"); strSql.Append("VideoAttribConfigOrder=@VideoAttribConfigOrder"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@GUID", SqlDbType.VarChar, -1), new SqlParameter("@VideoCategoryGUID", SqlDbType.VarChar, -1), new SqlParameter("@VideoAttribConfigName", SqlDbType.VarChar, -1), new SqlParameter("@VideoAttribConfigDescribe", SqlDbType.VarChar, -1), new SqlParameter("@VideoAttribConfigOrder", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.GUID; parameters[1].Value = model.VideoCategoryGUID; parameters[2].Value = model.VideoAttribConfigName; parameters[3].Value = model.VideoAttribConfigDescribe; parameters[4].Value = model.VideoAttribConfigOrder; parameters[5].Value = model.ID; if (DbHelperSQL.Query("SELECT id FROM VideoAttribConfig WHERE VideoCategoryGUID='" + model.VideoCategoryGUID + "' AND VideoAttribConfigName!='" + modelOld.VideoAttribConfigName + "' AND VideoAttribConfigName='" + model.VideoAttribConfigName + "'").Tables[0].Rows.Count < 1) { int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// 增加一条数据,如果属性名称重复,则不增加 /// </summary> public int ExAdd(Maticsoft.Model.VideoAttribConfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into VideoAttribConfig("); strSql.Append("GUID,VideoCategoryGUID,VideoAttribConfigName,VideoAttribConfigDescribe,VideoAttribConfigOrder)"); strSql.Append(" values ("); strSql.Append("@GUID,@VideoCategoryGUID,@VideoAttribConfigName,@VideoAttribConfigDescribe,@VideoAttribConfigOrder)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@GUID", SqlDbType.VarChar, -1), new SqlParameter("@VideoCategoryGUID", SqlDbType.VarChar, -1), new SqlParameter("@VideoAttribConfigName", SqlDbType.VarChar, -1), new SqlParameter("@VideoAttribConfigDescribe", SqlDbType.VarChar, -1), new SqlParameter("@VideoAttribConfigOrder", SqlDbType.Int, 4) }; parameters[0].Value = model.GUID; parameters[1].Value = model.VideoCategoryGUID; parameters[2].Value = model.VideoAttribConfigName; parameters[3].Value = model.VideoAttribConfigDescribe; parameters[4].Value = model.VideoAttribConfigOrder; if (DbHelperSQL.Query("SELECT id FROM VideoAttribConfig WHERE VideoCategoryGUID='" + model.VideoCategoryGUID + "' AND VideoAttribConfigName='" + model.VideoAttribConfigName + "'").Tables[0].Rows.Count < 1) { object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } } else { return(0);//属性名称重复,返回0 } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.VideoAttribConfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update VideoAttribConfig set "); strSql.Append("GUID=@GUID,"); strSql.Append("VideoCategoryGUID=@VideoCategoryGUID,"); strSql.Append("VideoAttribConfigName=@VideoAttribConfigName,"); strSql.Append("VideoAttribConfigDescribe=@VideoAttribConfigDescribe,"); strSql.Append("VideoAttribConfigOrder=@VideoAttribConfigOrder"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@GUID", SqlDbType.NVarChar, -1), new SqlParameter("@VideoCategoryGUID", SqlDbType.NVarChar, -1), new SqlParameter("@VideoAttribConfigName", SqlDbType.NVarChar, -1), new SqlParameter("@VideoAttribConfigDescribe", SqlDbType.NVarChar, -1), new SqlParameter("@VideoAttribConfigOrder", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.GUID; parameters[1].Value = model.VideoCategoryGUID; parameters[2].Value = model.VideoAttribConfigName; parameters[3].Value = model.VideoAttribConfigDescribe; parameters[4].Value = model.VideoAttribConfigOrder; parameters[5].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.VideoAttribConfig ExGetModel(string GUID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,GUID,VideoCategoryGUID,VideoAttribConfigName,VideoAttribConfigDescribe,VideoAttribConfigOrder from VideoAttribConfig "); strSql.Append(" where GUID=@GUID"); SqlParameter[] parameters = { new SqlParameter("@GUID", SqlDbType.VarChar) }; parameters[0].Value = GUID; Maticsoft.Model.VideoAttribConfig model = new Maticsoft.Model.VideoAttribConfig(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据,如果属性名称重复,则不增加 /// </summary> public int ExAdd(Maticsoft.Model.VideoAttribConfig model) { return(dal.ExAdd(model)); }
/// <summary> /// 更新一条数据,如果属性名称重复,则不更新 /// </summary> public bool ExUpdate(Maticsoft.Model.VideoAttribConfig model, Maticsoft.Model.VideoAttribConfig modelOld) { return(dal.ExUpdate(model, modelOld)); }