public DataTable GetModuleData(Sys_ModuleData objSys_ModuleData) { MySqlHelper objSqlHelper = new MySqlHelper(objSys_ModuleData.ConnectionKey); string sqlPower = @"select Sys_RoleData.DataSelect from Sys_RoleData ,Sys_RoleUser where Sys_RoleUser.UserID='{0}' and Sys_RoleData.RoleID=Sys_RoleUser.RoleID and Sys_RoleData.ModuleDataID='{1}'"; string PowerSelect = objModuleRule.CurrentEntities.ExecuteStoreQuery <string>(string.Format(sqlPower, IsRolePowerManage ? CurrentAccountTypeAdminUserID : CurrentUser.UserID, objSys_ModuleData.ModuleDataID)).ToList <string>().ConvertListToString(); DataTable objDataTable = objSqlHelper.ExecuteDataTable(" select * from (" + objSys_ModuleData.DataSelect + ") as DataPowers where DataValue in (" + ValueFormant(PowerSelect, objSys_ModuleData.FieldSourceType) + ")"); objDataTable.Columns.Add("DataSelect"); objDataTable.Columns.Add("DataID"); string dataSelect = ""; Sys_RoleData objSys_RoleData = objUserRule.Sys_RoleData.FirstOrDefault(s => s.ModuleDataID == objSys_ModuleData.ModuleDataID && s.RoleID == RoleID); if (objSys_RoleData.IsNoNull()) { dataSelect = objSys_RoleData.DataSelect; } foreach (DataRow objRow in objDataTable.Rows) { objRow["DataSelect"] = dataSelect; objRow["DataID"] = objSys_ModuleData.ModuleDataID.ToString() + objSys_ModuleData.ModuleID.ToString(); } return(objDataTable); }
/// <summary> /// 页面加载 /// </summary> public override void RenderPage() { if (ModuleDataID.IsNoNull()) { objSys_ModuleData = objModuleRule.Sys_ModuleData.First(s => s.ModuleDataID == ModuleDataID); ///连接串Key值 dropConnectionKey.SelectedValue = objSys_ModuleData.ConnectionKey.ToString(); radFieldSourceType.SelectedValue = objSys_ModuleData.FieldSourceType.ToString(); ///1int2字符串3bit4全球唯一码 radFieldType.SelectedValue = objSys_ModuleData.FieldType.ToString(); Page.DataBind(); } else { } }
/// <summary> /// 保存信息 /// </summary> public void SaveInfo() { if (ModuleDataID.IsNull()) { objSys_ModuleData.ModuleDataID = Guid.NewGuid().ToString(); objSys_ModuleData.ModuleID = ModuleID; ///连接串Key值 objSys_ModuleData.ConnectionKey = dropConnectionKey.SelectedValue; ///数据名称 objSys_ModuleData.DataName = txtDataName.TextCutWord(50); ///字段名 objSys_ModuleData.FieldName = txtFieldName.TextCut(50); ///数据查询 objSys_ModuleData.DataSelect = txtDataSelect.TextCut(1000); ///1全局2列表 objSys_ModuleData.PowerType = IsModuleType; ///1int2字符串3bit4全球唯一码 objSys_ModuleData.FieldType = radFieldType.SelectValueInt; objSys_ModuleData.FieldSourceType = radFieldSourceType.SelectValueInt; objModuleRule.InsertModuleData(objSys_ModuleData); MessageDialog("新增成功", "ModuleDataList.aspx?ModuleID=" + ModuleID); } else { objSys_ModuleData = objModuleRule.Sys_ModuleData.First(p => p.ModuleDataID == ModuleDataID); ///连接串Key值 objSys_ModuleData.ConnectionKey = dropConnectionKey.SelectedValue; ///数据名称 objSys_ModuleData.DataName = txtDataName.TextCutWord(50); ///字段名 objSys_ModuleData.FieldName = txtFieldName.TextCut(50); ///数据查询 objSys_ModuleData.DataSelect = txtDataSelect.TextCut(1000); ///1int2字符串3bit4全球唯一码 objSys_ModuleData.FieldType = radFieldType.SelectValueInt; objSys_ModuleData.FieldSourceType = radFieldSourceType.SelectValueInt; objModuleRule.UpdateModuleData(objSys_ModuleData); MessageDialog("修改成功", "ModuleDataList.aspx?ModuleID=" + ModuleID); } }
public DataTable GetModuleData(Sys_ModuleData objSys_ModuleData) { MySqlHelper objSqlHelper = new MySqlHelper(objSys_ModuleData.ConnectionKey); DataTable objDataTable = objSqlHelper.ExecuteDataTable(objSys_ModuleData.DataSelect); objDataTable.Columns.Add("DataSelect"); objDataTable.Columns.Add("DataID"); string dataSelect = ""; Sys_RoleData objSys_RoleData = objUserRule.Sys_RoleData.FirstOrDefault(s => s.ModuleDataID == objSys_ModuleData.ModuleDataID && s.RoleID == RoleID); if (objSys_RoleData.IsNoNull()) { dataSelect = objSys_RoleData.DataSelect; } foreach (DataRow objRow in objDataTable.Rows) { objRow["DataSelect"] = dataSelect; objRow["DataID"] = objSys_ModuleData.ModuleDataID.ToString() + objSys_ModuleData.ModuleID.ToString(); } return(objDataTable); }
/// <summary> /// 保存信息 /// </summary> public void SaveInfo() { if (hidDataVale.Value.IsNoNull()) { foreach (string selectValue in hidDataVale.Value.Split(';')) { string[] select = selectValue.Split(':'); string ModuleDataID = select[0]; Sys_ModuleData objSys_ModuleData = objModuleRule.Sys_ModuleData.First(s => s.ModuleDataID == ModuleDataID); Sys_RoleData objSys_RoleData = objUserRule.Sys_RoleData.FirstOrDefault(s => s.RoleID == RoleID && s.ModuleDataID == ModuleDataID); string value = select[1]; if (value.IsNoNull() && objSys_RoleData.IsNull()) { objSys_RoleData = new Sys_RoleData(); objSys_RoleData.ModuleDataID = ModuleDataID; objSys_RoleData.RoleDataID = Guid.NewGuid().ToString(); objSys_RoleData.RoleID = RoleID; objSys_RoleData.ModuleID = objSys_ModuleData.ModuleID; objSys_RoleData.DataSelect = value; objUserRule.CurrentEntities.AddTosys_roledata(objSys_RoleData); Sys_Role objaddSys_Role = objUserRule.Sys_Role.FirstOrDefault(s => s.RoleID == RoleID && s.IsSystem == true); if (objaddSys_Role.IsNoNull()) { ///已经有设置了数据权限 string sqlUpdate = ""; foreach (Sys_RoleData sys_RoleData in objUserRule.CurrentEntities.ExecuteStoreQuery <Sys_RoleData>(string.Format(@"select Sys_RoleData.* from Sys_RoleData where RoleID in(select RoleID from Sys_Role where ModuleTypeID='{0}' and IsSystem=0 ) and ModuleDataID='{1}'", objaddSys_Role.ModuleTypeID.ToString(), ModuleDataID.ToString()))) { var setvalue = sys_RoleData.DataSelect.ConvertListString().Intersect(value.ConvertListString()).ConvertListToString(); if (setvalue.IsNull()) { sqlUpdate += string.Format("delete from Sys_RoleData where RoleDataID='{0}';", sys_RoleData.RoleDataID); } else { sqlUpdate += string.Format("update Sys_RoleData set DataSelect='{0}' where RoleDataID='{1}';", setvalue, sys_RoleData.RoleDataID); } } if (sqlUpdate.IsNoNull()) { objUserRule.CurrentEntities.ExecuteStoreCommand(sqlUpdate); } } } else if (value.IsNoNull() && objSys_RoleData.IsNoNull()) { objSys_RoleData.DataSelect = value; objUserRule.SaveChanges(); Sys_Role objaddSys_Role = objUserRule.Sys_Role.FirstOrDefault(s => s.RoleID == RoleID && s.IsSystem == true); if (objaddSys_Role.IsNoNull()) { ///已经有设置了数据权限 string sqlUpdate = ""; foreach (Sys_RoleData sys_RoleData in objUserRule.CurrentEntities.ExecuteStoreQuery <Sys_RoleData>(string.Format(@"select Sys_RoleData.* from Sys_RoleData where RoleID in(select RoleID from Sys_Role where ModuleTypeID='{0}' and IsSystem=0 ) and ModuleDataID='{1}'", objaddSys_Role.ModuleTypeID.ToString(), ModuleDataID.ToString()))) { var setvalue = sys_RoleData.DataSelect.ConvertListString().Intersect(value.ConvertListString()).ConvertListToString(); if (setvalue.IsNull()) { sqlUpdate += string.Format("delete from Sys_RoleData where RoleDataID='{0}';", sys_RoleData.RoleDataID); } else { sqlUpdate += string.Format("update Sys_RoleData set DataSelect='{0}' where RoleDataID='{1}';", setvalue, sys_RoleData.RoleDataID); } } if (sqlUpdate.IsNoNull()) { objUserRule.CurrentEntities.ExecuteStoreCommand(sqlUpdate); } } } else if (value.IsNull() && objSys_RoleData.IsNoNull()) { objUserRule.CurrentEntities.DeleteObject(objSys_RoleData); objUserRule.SaveChanges(); Sys_Role objaddSys_Role = objUserRule.Sys_Role.FirstOrDefault(s => s.RoleID == RoleID && s.IsSystem == true); if (objaddSys_Role.IsNoNull()) { objUserRule.CurrentEntities.ExecuteStoreCommand(string.Format(@"delete from Sys_RoleData where RoleID in(select RoleID from Sys_Role where ModuleTypeID='{0}' and IsSystem=0 ) and ModuleDataID='{1}'", objaddSys_Role.ModuleTypeID.ToString(), ModuleDataID.ToString())); } } else if (value.IsNull() && objSys_RoleData.IsNull()) { } objUserRule.SaveChanges(); } RenderPage(); } MessageDialog("保存成功"); }