/// <summary> /// 数据编辑 /// </summary> /// <returns></returns> public virtual ReturnValue edit(double classId) { ReturnValue returnValue = new ReturnValue(); LoginInfo login = new LoginInfo(); Permissions p = login.value.getColumnPermissions(classId); if (!p.write) { returnValue.errNo = -1; returnValue.errMsg = "没有权限"; return(returnValue); } Dictionary <string, object> model = new Dictionary <string, object>(); foreach (var field in table.Fields) { if (PageContext.Current.Request.Form.ContainsKey(field.Key)) { model[field.Key] = s_request.getString(field.Key); } } Column column = new Column(classId); MWMS.DAL.Datatype.Table.ColumnConfig config = column.GetConfig(); if (!config.titleRepeat) { int count = 0; MySqlDataReader rs = Sql.ExecuteReader("select count(1) from maintable where id<>@id and title=@title", new MySqlParameter[] { new MySqlParameter("id", model["id"]), new MySqlParameter("title", model["title"]) }); if (rs.Read()) { count = rs.GetInt32(0); } rs.Close(); if (count > 0) { returnValue.errNo = -1; returnValue.errMsg = "标题已存在"; return(returnValue); } } if (!(model.ContainsKey("id") && model["id"].ToDouble() > 0)) { model["userId"] = this.loginInfo.value.id; } returnValue.userData = table.Save(model); return(returnValue); }
public ColumnConfig GetConfig() { bool inherit = false; double classId = 0, moduleId = 0; string parentId = ""; ColumnConfig config = new ColumnConfig(); MySqlDataReader rs = Sql.ExecuteReader("select thumbnailWidth,thumbnailHeight,thumbnailForce,saveRemoteImages,inherit,classId,parentId,moduleId,titleRepeat,watermark,childId from class where id=@id", new MySqlParameter[] { new MySqlParameter("id", Id) }); if (rs.Read()) { inherit = rs.GetInt32(4) == 1; config.picForce = rs.GetInt32(2) == 1; config.picSave = rs.GetInt32(3) == 1; config.picWidth = rs.GetInt32(0); config.picHeight = rs.GetInt32(1); classId = rs.GetDouble(5); parentId = rs.GetString(6); moduleId = rs.GetDouble(7); config.titleRepeat = (rs.IsDBNull(8) || rs.GetInt32(8) == 1); config.isRoot = rs.GetDouble(5) == 7; config.isColumn = rs.GetDouble(5) != 7; config.isModule = false; config.pId = Id; config.watermarkFlag = rs.IsDBNull(9) || rs.GetInt32(9) == 1; config.childId = rs.GetString(10); } rs.Close(); if (inherit) { string sql = ""; if (classId == 7) { rs = Sql.ExecuteReader("select thumbnailWidth,thumbnailHeight,thumbnailForce,saveRemoteImages,titleRepeat,watermark from module where id=@moduleId", new MySqlParameter[] { new MySqlParameter("moduleId", moduleId) }); if (rs.Read()) { config.picForce = rs.GetInt32(2) == 1; config.picSave = rs.GetInt32(3) == 1; config.picWidth = rs.GetInt32(0); config.picHeight = rs.GetInt32(1); config.titleRepeat = (rs.IsDBNull(4) || rs.GetInt32(4) == 1); config.isModule = true; config.isRoot = false; config.isColumn = false; config.pId = moduleId; config.watermarkFlag = rs.IsDBNull(5) || rs.GetInt32(5) == 1; } rs.Close(); } else { sql = "select thumbnailWidth,thumbnailHeight,thumbnailForce,saveRemoteImages,titleRepeat,classId,childId,id,watermark from class where id in (" + parentId + ") and inherit=0 order by layer desc "; bool flag = false; rs = Sql.ExecuteReader(sql); if (rs.Read()) { flag = true; config.picForce = rs.GetInt32(2) == 1; config.picSave = rs.GetInt32(3) == 1; config.picWidth = rs.GetInt32(0); config.picHeight = rs.GetInt32(1); config.titleRepeat = (rs.IsDBNull(4) || rs.GetInt32(4) == 1); config.isRoot = rs.GetDouble(5) == 7; config.isColumn = rs.GetDouble(5) != 7; config.isModule = false; config.childId = rs.GetString(6); config.pId = rs.GetDouble(7); config.watermarkFlag = rs.IsDBNull(8) || rs.GetInt32(8) == 1; } rs.Close(); if (!flag)//从模块中查找配制 { rs = Sql.ExecuteReader("select thumbnailWidth,thumbnailHeight,thumbnailForce,saveRemoteImages,titleRepeat,watermark from module where id=@moduleId", new MySqlParameter[] { new MySqlParameter("moduleId", moduleId) }); if (rs.Read()) { config.picForce = rs.GetInt32(2) == 1; config.picSave = rs.GetInt32(3) == 1; config.picWidth = rs.GetInt32(0); config.picHeight = rs.GetInt32(1); config.titleRepeat = (rs.IsDBNull(4) || rs.GetInt32(4) == 1); config.isModule = true; config.isRoot = false; config.isColumn = false; config.pId = moduleId; config.watermarkFlag = rs.IsDBNull(5) || rs.GetInt32(5) == 1; } rs.Close(); } } return(config); } else { return(config); } }