/// <summary> /// 更新项目模块记录 /// </summary> /// <param name="sys_Modules">项目模块对象</param> /// <returns>受影响的记录数</returns> public int UpdateSys_Modules(Sys_Modules sys_Modules) { string sql = @"UPDATE dbo.Sys_Modules SET ProjID = @ProjID, ModuleCode = @ModuleCode, ModuleName = @ModuleName, ShortName = @ShortName, ParentId = @ParentId, UrlString = @UrlString, ModuleEntry = @ModuleEntry, ModuleIconS = @ModuleIconS, ModuleIconB = @ModuleIconB, IsShowInDeskTop = @IsShowInDeskTop, OpenType = @OpenType, Status = @Status, Hint = @Hint, DisplayOrder = @DisplayOrder, DisplayPrivilegeMask = @DisplayPrivilegeMask, HelpUrlString = @HelpUrlString, Remark = @Remark, ModifiedBy = @ModifiedBy, ModifiedOn = @ModifiedOn WHERE KeyId = @KeyId"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddInParameter(command, "KeyId", DbType.Int32, sys_Modules.KeyId); db.AddInParameter(command, "ProjID", DbType.Int32, sys_Modules.ProjID); db.AddInParameter(command, "ModuleCode", DbType.String, sys_Modules.ModuleCode); db.AddInParameter(command, "ModuleName", DbType.String, sys_Modules.ModuleName); db.AddInParameter(command, "ShortName", DbType.String, string.IsNullOrEmpty(sys_Modules.ShortName) ? DBNull.Value : (object)sys_Modules.ShortName); db.AddInParameter(command, "ParentId", DbType.Int32, sys_Modules.ParentId.HasValue ? (object)sys_Modules.ParentId : DBNull.Value); db.AddInParameter(command, "UrlString", DbType.String, string.IsNullOrEmpty(sys_Modules.UrlString) ? DBNull.Value : (object)sys_Modules.UrlString); db.AddInParameter(command, "ModuleEntry", DbType.String, string.IsNullOrEmpty(sys_Modules.ModuleEntry) ? DBNull.Value : (object)sys_Modules.ModuleEntry); db.AddInParameter(command, "ModuleIconS", DbType.String, string.IsNullOrEmpty(sys_Modules.ModuleIconS) ? DBNull.Value : (object)sys_Modules.ModuleIconS); db.AddInParameter(command, "ModuleIconB", DbType.String, string.IsNullOrEmpty(sys_Modules.ModuleIconB) ? DBNull.Value : (object)sys_Modules.ModuleIconB); db.AddInParameter(command, "IsShowInDeskTop", DbType.Boolean, sys_Modules.IsShowInDeskTop); db.AddInParameter(command, "OpenType", DbType.Int32, sys_Modules.OpenType.HasValue ? (object)sys_Modules.OpenType : DBNull.Value); db.AddInParameter(command, "Status", DbType.Boolean, sys_Modules.Status); db.AddInParameter(command, "Hint", DbType.String, string.IsNullOrEmpty(sys_Modules.Hint) ? DBNull.Value : (object)sys_Modules.Hint); db.AddInParameter(command, "DisplayOrder", DbType.Int32, sys_Modules.DisplayOrder.HasValue ? (object)sys_Modules.DisplayOrder : DBNull.Value); db.AddInParameter(command, "DisplayPrivilegeMask", DbType.Int32, sys_Modules.DisplayPrivilegeMask.HasValue ? (object)sys_Modules.DisplayPrivilegeMask : DBNull.Value); db.AddInParameter(command, "HelpUrlString", DbType.String, string.IsNullOrEmpty(sys_Modules.HelpUrlString) ? DBNull.Value : (object)sys_Modules.HelpUrlString); db.AddInParameter(command, "Remark", DbType.String, string.IsNullOrEmpty(sys_Modules.Remark) ? DBNull.Value : (object)sys_Modules.Remark); db.AddInParameter(command, "ModifiedBy", DbType.Int32, sys_Modules.ModifiedBy.HasValue ? (object)sys_Modules.ModifiedBy : DBNull.Value); db.AddInParameter(command, "ModifiedOn", DbType.DateTime, sys_Modules.ModifiedOn.HasValue ? (object)sys_Modules.ModifiedOn : DBNull.Value); return(db.ExecuteNonQuery(command)); }
/// <summary> /// 新增模块信息 /// </summary> /// <param name="module"></param> /// <returns></returns> public bool InsertModuleInfo(Sys_Modules module) { using (var db = new QYZEntity()) { db.Sys_Modules.AddObject(module); db.SaveChanges(); return(true); } }
/// <summary> /// 删除模块信息 /// </summary> /// <param name="module"></param> /// <returns></returns> public bool DeleteModuleInfo(Sys_Modules module) { using (var db = new QYZEntity()) { Sys_Modules m = db.Sys_Modules.Where(p => p.ID == module.ID).ToList <Sys_Modules>().FirstOrDefault <Sys_Modules>(); db.Sys_Modules.DeleteObject(m); db.SaveChanges(); return(true); } }
public override void ExecuteDelete() { if (SelectedModule != null) { ModuleInfoBLL bll = new ModuleInfoBLL(); if (bll.DeleteModuleInfo(SelectedModule)) { ModuleList.Remove(SelectedModule); SelectedModule = null; } } }
public override void ExecuteAdd() { Sys_Modules module = new Sys_Modules(); module.ID = new ModuleInfoBLL().GetMaxModuleID(); module.MenuID = Convert.ToInt32(MenuID); FrmModuleSettingEdit edit = new FrmModuleSettingEdit(module); edit.SaveEvent += (m) => { ModuleList.Add(m); }; edit.ShowDialog(); }
/// <summary> /// 更新模块信息 /// </summary> /// <param name="modules"></param> /// <returns></returns> public bool UpdateModuleInfo(Sys_Modules modules) { using (var db = new QYZEntity()) { Sys_Modules module = db.Sys_Modules.Where(p => p.ID == modules.ID).ToList <Sys_Modules>().FirstOrDefault <Sys_Modules>(); module.Name = modules.Name; module.MenuID = modules.MenuID; module.ImagePath = modules.ImagePath; module.Parameter = modules.Parameter; module.Remark = modules.Remark; module.StartUpClass = modules.StartUpClass; module.DllName = modules.DllName; db.SaveChanges(); return(true); } }
/// <summary> ///根据主键值查找项目模块记录 /// </summary> /// <param name="keyId">模块内码</param> /// <returns>Sys_Modules</returns> public Sys_Modules FindSys_Modules(int keyId) { string sql = @"SELECT KeyId, ProjID, ModuleCode, ModuleName, ShortName, ParentId, UrlString, ModuleEntry, ModuleIconS, ModuleIconB, IsShowInDeskTop, OpenType, Status, Hint, DisplayOrder, DisplayPrivilegeMask, HelpUrlString, Remark, CreatedBy, CreatedOn, ModifiedBy, ModifiedOn FROM dbo.Sys_Modules WHERE KeyId = @KeyId"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddInParameter(command, "KeyId", DbType.Int32, keyId); Sys_Modules sys_Modules = null; using (IDataReader dr = db.ExecuteReader(command)) { if (dr.Read()) { sys_Modules = new Sys_Modules(); sys_Modules.KeyId = (int)dr["KeyId"]; sys_Modules.ProjID = (int)dr["ProjID"]; sys_Modules.ModuleCode = (string)dr["ModuleCode"]; sys_Modules.ModuleName = (string)dr["ModuleName"]; sys_Modules.ShortName = dr["ShortName"] == DBNull.Value ? null : (string)dr["ShortName"]; sys_Modules.ParentId = dr["ParentId"] == DBNull.Value ? null : (int?)dr["ParentId"]; sys_Modules.UrlString = dr["UrlString"] == DBNull.Value ? null : (string)dr["UrlString"]; sys_Modules.ModuleEntry = dr["ModuleEntry"] == DBNull.Value ? null : (string)dr["ModuleEntry"]; sys_Modules.ModuleIconS = dr["ModuleIconS"] == DBNull.Value ? null : (string)dr["ModuleIconS"]; sys_Modules.ModuleIconB = dr["ModuleIconB"] == DBNull.Value ? null : (string)dr["ModuleIconB"]; sys_Modules.IsShowInDeskTop = (bool)dr["IsShowInDeskTop"]; sys_Modules.OpenType = dr["OpenType"] == DBNull.Value ? null : (int?)dr["OpenType"]; sys_Modules.Status = (bool)dr["Status"]; sys_Modules.Hint = dr["Hint"] == DBNull.Value ? null : (string)dr["Hint"]; sys_Modules.DisplayOrder = dr["DisplayOrder"] == DBNull.Value ? null : (int?)dr["DisplayOrder"]; sys_Modules.DisplayPrivilegeMask = dr["DisplayPrivilegeMask"] == DBNull.Value ? null : (int?)dr["DisplayPrivilegeMask"]; sys_Modules.HelpUrlString = dr["HelpUrlString"] == DBNull.Value ? null : (string)dr["HelpUrlString"]; sys_Modules.Remark = dr["Remark"] == DBNull.Value ? null : (string)dr["Remark"]; sys_Modules.CreatedBy = (int)dr["CreatedBy"]; sys_Modules.CreatedOn = (DateTime)dr["CreatedOn"]; sys_Modules.ModifiedBy = dr["ModifiedBy"] == DBNull.Value ? null : (int?)dr["ModifiedBy"]; sys_Modules.ModifiedOn = dr["ModifiedOn"] == DBNull.Value ? null : (DateTime?)dr["ModifiedOn"]; } } return(sys_Modules); }
/// <summary> /// 插入项目模块记录 /// </summary> /// <param name="sys_Modules">项目模块对象</param> /// <returns></returns> public int InsertSys_Modules(Sys_Modules sys_Modules) { string sql = @"INSERT INTO dbo.Sys_Modules(ProjID, ModuleCode, ModuleName, ShortName, ParentId, UrlString, ModuleEntry, ModuleIconS, ModuleIconB, IsShowInDeskTop, OpenType, Status, Hint, DisplayOrder, DisplayPrivilegeMask, HelpUrlString, Remark, CreatedBy) VALUES(@ProjID, @ModuleCode, @ModuleName, @ShortName, @ParentId, @UrlString, @ModuleEntry, @ModuleIconS, @ModuleIconB, @IsShowInDeskTop, @OpenType, @Status, @Hint, @DisplayOrder, @DisplayPrivilegeMask, @HelpUrlString, @Remark, @CreatedBy); SELECT @KeyId = SCOPE_IDENTITY()"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddOutParameter(command, "KeyId", DbType.Int32, sizeof(int)); db.AddInParameter(command, "ProjID", DbType.Int32, sys_Modules.ProjID); db.AddInParameter(command, "ModuleCode", DbType.String, sys_Modules.ModuleCode); db.AddInParameter(command, "ModuleName", DbType.String, sys_Modules.ModuleName); db.AddInParameter(command, "ShortName", DbType.String, string.IsNullOrEmpty(sys_Modules.ShortName) ? DBNull.Value : (object)sys_Modules.ShortName); db.AddInParameter(command, "ParentId", DbType.Int32, sys_Modules.ParentId.HasValue ? (object)sys_Modules.ParentId : DBNull.Value); db.AddInParameter(command, "UrlString", DbType.String, string.IsNullOrEmpty(sys_Modules.UrlString) ? DBNull.Value : (object)sys_Modules.UrlString); db.AddInParameter(command, "ModuleEntry", DbType.String, string.IsNullOrEmpty(sys_Modules.ModuleEntry) ? DBNull.Value : (object)sys_Modules.ModuleEntry); db.AddInParameter(command, "ModuleIconS", DbType.String, string.IsNullOrEmpty(sys_Modules.ModuleIconS) ? DBNull.Value : (object)sys_Modules.ModuleIconS); db.AddInParameter(command, "ModuleIconB", DbType.String, string.IsNullOrEmpty(sys_Modules.ModuleIconB) ? DBNull.Value : (object)sys_Modules.ModuleIconB); db.AddInParameter(command, "IsShowInDeskTop", DbType.Boolean, sys_Modules.IsShowInDeskTop); db.AddInParameter(command, "OpenType", DbType.Int32, sys_Modules.OpenType.HasValue ? (object)sys_Modules.OpenType : DBNull.Value); db.AddInParameter(command, "Status", DbType.Boolean, sys_Modules.Status); db.AddInParameter(command, "Hint", DbType.String, string.IsNullOrEmpty(sys_Modules.Hint) ? DBNull.Value : (object)sys_Modules.Hint); db.AddInParameter(command, "DisplayOrder", DbType.Int32, sys_Modules.DisplayOrder.HasValue ? (object)sys_Modules.DisplayOrder : DBNull.Value); db.AddInParameter(command, "DisplayPrivilegeMask", DbType.Int32, sys_Modules.DisplayPrivilegeMask.HasValue ? (object)sys_Modules.DisplayPrivilegeMask : DBNull.Value); db.AddInParameter(command, "HelpUrlString", DbType.String, string.IsNullOrEmpty(sys_Modules.HelpUrlString) ? DBNull.Value : (object)sys_Modules.HelpUrlString); db.AddInParameter(command, "Remark", DbType.String, string.IsNullOrEmpty(sys_Modules.Remark) ? DBNull.Value : (object)sys_Modules.Remark); db.AddInParameter(command, "CreatedBy", DbType.Int32, sys_Modules.CreatedBy); int affectedRecords = db.ExecuteNonQuery(command); if (affectedRecords < 1) { throw new ApplicationException("插入数据失败, 没有记录被插入"); } else { string strTemp = "select @@identity"; DataTable dt = GetDataTable(strTemp); if (dt != null && dt.Rows.Count > 0) { affectedRecords = int.Parse(dt.Rows[0][0].ToString()); } } return(affectedRecords); }
/// <summary> /// 更新Sys_Modules /// </summary> /// <param name="sys_Modules">实体类</param> /// <param name="logEntity">日志类</param> /// <returns></returns> public string UpdateSys_Modules(Sys_Modules sys_Modules, Log_Operate logEntity) { string strResult = ""; using (TransactionScope trans = new TransactionScope()) { try { this._sys_ModulesDAO.UpdateSys_Modules(sys_Modules); Log_OperateFacade logFacade = new Log_OperateFacade(); int intLog = logFacade.CreateLog_Operate(logEntity); trans.Complete(); } catch (Exception ex) { strResult = ex.Message; } } return(strResult); }
/// <summary> /// 创建Sys_Modules /// </summary> /// <param name="sys_Modules">实体类</param> /// <param name="logEntity">日志类</param> /// <param name="strResult">错误信息</param> /// <returns></returns> public int InsertSys_Modules(Sys_Modules sys_Modules, Log_Operate logEntity, ref string strResult) { int intResult = 0; using (TransactionScope trans = new TransactionScope()) { try { intResult = this._sys_ModulesDAO.InsertSys_Modules(sys_Modules); Log_OperateFacade logFacade = new Log_OperateFacade(); logEntity.OperateFunction = "新增_sys_Modules表ID为" + intResult.ToString() + "的数据"; int intLog = logFacade.CreateLog_Operate(logEntity); trans.Complete(); } catch (Exception ex) { strResult = ex.Message; } } return(intResult); }
public FrmModuleSettingEdit(Sys_Modules module) { InitializeComponent(); this.DataContext = this; MainModule = module; if (module.Name == null || module.Name == "") { MyTitle = "新增菜单"; } else { MyTitle = "编辑菜单"; } new MenuInfoBLL().GetMenuInfo((int)GlobalVariable.systemType).ForEach(p => MenuList.Add(p)); SelectedMenu = MenuList.FirstOrDefault(p => p.ID == module.MenuID); if (module.DllName != "") { ReflectFunction.GetClassName(module.DllName).ForEach(p => StartUpClassList.Add(p)); StartUpClass = StartUpClassList.FirstOrDefault(p => p.FullName == module.StartUpClass); } }
public override void ExecuteEdit() { if (SelectedModule != null) { Sys_Modules module = new Sys_Modules(); module.ID = SelectedModule.ID; module.Name = SelectedModule.Name; module.MenuID = SelectedModule.MenuID; module.ImagePath = SelectedModule.ImagePath; module.Parameter = SelectedModule.Parameter; module.Remark = SelectedModule.Remark; module.StartUpClass = SelectedModule.StartUpClass; module.DllName = SelectedModule.DllName; FrmModuleSettingEdit edit = new FrmModuleSettingEdit(module); edit.SaveEvent += (m) => { ModuleList[ModuleList.IndexOf(SelectedModule)] = m; SelectedModule = m; }; edit.ShowDialog(); } }
/// <summary> /// 创建项目模块记录 /// </summary> /// <param name="sys_Modules"> /// 项目模块对象</param> /// <returns></returns> public int CreateSys_Modules(Sys_Modules sys_Modules) { return(this._sys_ModulesDAO.InsertSys_Modules(sys_Modules)); }
/// <summary> /// 返回满足查询条件的项目模块实体列表 /// </summary> /// <param name="param">查询条件</param> /// <returns>项目模块实体列表</returns> public IList <Sys_Modules> GetSys_Moduless(QueryParameter param) { string sql = @"SELECT KeyId, ProjID, ModuleCode, ModuleName, ShortName, ParentId, UrlString, ModuleEntry, ModuleIconS, ModuleIconB, IsShowInDeskTop, OpenType, Status, Hint, DisplayOrder, DisplayPrivilegeMask, HelpUrlString, Remark, CreatedBy, CreatedOn, ModifiedBy, ModifiedOn FROM dbo.Sys_Modules"; if (param != null) { sql = QueryParameter.CompleteSqlString(sql, param); } Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); if (param != null) { //设置参数 foreach (IExpression exp in param.WhereExpressions) { if (exp is SimpleExpression) { SimpleExpression simple = exp as SimpleExpression; db.AddInParameter(command, simple.ExpName, simple.DbType, simple.Value); } } } IList <Sys_Modules> list = new List <Sys_Modules>(); using (IDataReader dr = db.ExecuteReader(command)) { while (dr.Read()) { Sys_Modules sys_Modules = new Sys_Modules(); sys_Modules.KeyId = (int)dr["KeyId"]; sys_Modules.ProjID = (int)dr["ProjID"]; sys_Modules.ModuleCode = (string)dr["ModuleCode"]; sys_Modules.ModuleName = (string)dr["ModuleName"]; sys_Modules.ShortName = dr["ShortName"] == DBNull.Value ? null : (string)dr["ShortName"]; sys_Modules.ParentId = dr["ParentId"] == DBNull.Value ? null : (int?)dr["ParentId"]; sys_Modules.UrlString = dr["UrlString"] == DBNull.Value ? null : (string)dr["UrlString"]; sys_Modules.ModuleEntry = dr["ModuleEntry"] == DBNull.Value ? null : (string)dr["ModuleEntry"]; sys_Modules.ModuleIconS = dr["ModuleIconS"] == DBNull.Value ? null : (string)dr["ModuleIconS"]; sys_Modules.ModuleIconB = dr["ModuleIconB"] == DBNull.Value ? null : (string)dr["ModuleIconB"]; sys_Modules.IsShowInDeskTop = (bool)dr["IsShowInDeskTop"]; sys_Modules.OpenType = dr["OpenType"] == DBNull.Value ? null : (int?)dr["OpenType"]; sys_Modules.Status = (bool)dr["Status"]; sys_Modules.Hint = dr["Hint"] == DBNull.Value ? null : (string)dr["Hint"]; sys_Modules.DisplayOrder = dr["DisplayOrder"] == DBNull.Value ? null : (int?)dr["DisplayOrder"]; sys_Modules.DisplayPrivilegeMask = dr["DisplayPrivilegeMask"] == DBNull.Value ? null : (int?)dr["DisplayPrivilegeMask"]; sys_Modules.HelpUrlString = dr["HelpUrlString"] == DBNull.Value ? null : (string)dr["HelpUrlString"]; sys_Modules.Remark = dr["Remark"] == DBNull.Value ? null : (string)dr["Remark"]; sys_Modules.CreatedBy = (int)dr["CreatedBy"]; sys_Modules.CreatedOn = (DateTime)dr["CreatedOn"]; sys_Modules.ModifiedBy = dr["ModifiedBy"] == DBNull.Value ? null : (int?)dr["ModifiedBy"]; sys_Modules.ModifiedOn = dr["ModifiedOn"] == DBNull.Value ? null : (DateTime?)dr["ModifiedOn"]; list.Add(sys_Modules); } } return(list); }
/// <summary> /// 更新模块信息 /// </summary> /// <param name="modules"></param> /// <returns></returns> public bool UpdateModuleInfo(Sys_Modules modules) { return(dal.UpdateModuleInfo(modules)); }
/// <summary> /// 新增模块信息 /// </summary> /// <param name="module"></param> /// <returns></returns> public bool InsertModuleInfo(Sys_Modules module) { return(dal.InsertModuleInfo(module)); }
/// <summary> /// 删除模块信息 /// </summary> /// <param name="module"></param> /// <returns></returns> public bool DeleteModuleInfo(Sys_Modules module) { return(dal.DeleteModuleInfo(module)); }
/// <summary> /// 更新项目模块记录 /// </summary> /// <param name="sys_Modules"> /// 项目模块对象</param> /// <returns>受影响的记录数</returns> public int UpdateSys_Modules(Sys_Modules sys_Modules) { return(this._sys_ModulesDAO.UpdateSys_Modules(sys_Modules)); }