Example #1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="moduleEntity">功能实体</param>
 /// <param name="moduleButtonList">按钮实体列表</param>
 /// <param name="moduleColumnList">视图实体列表</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, ModuleEntity moduleEntity, List <ModuleButtonEntity> moduleButtonList, List <ModuleColumnEntity> moduleColumnList)
 {
     try
     {
         using (var tran = QSDMS_SQLDB.GetInstance().GetTransaction())
         {
             if (!string.IsNullOrEmpty(keyValue))
             {
                 moduleEntity.Modify(keyValue);
                 Base_Module moudle = Base_Module.SingleOrDefault("where ModuleId=@0", keyValue);
                 //if (moduleEntity.UrlAddress == null)
                 //{
                 //    moduleEntity.UrlAddress = "";
                 //}
                 moudle          = EntityConvertTools.CopyToModel <ModuleEntity, Base_Module>(moduleEntity, moudle);
                 moudle.ModuleId = keyValue;
                 moudle.Update();
             }
             else
             {
                 moduleEntity.Create();
                 Base_Module moudle = new Base_Module();
                 moudle = EntityConvertTools.CopyToModel <ModuleEntity, Base_Module>(moduleEntity, null);
                 moudle.Insert();
             }
             //删除操作按钮
             Base_ModuleButton.Delete("where ModuleId=@0", keyValue);
             if (moduleButtonList != null)
             {
                 foreach (ModuleButtonEntity buttonItem in moduleButtonList)
                 {
                     Base_ModuleButton modulebutton = new Base_ModuleButton();
                     modulebutton = EntityConvertTools.CopyToModel <ModuleButtonEntity, Base_ModuleButton>(buttonItem, null);
                     modulebutton.Insert();
                 }
             }
             //删除字段
             Base_ModuleColumn.Delete("where ModuleId=@0", keyValue);
             if (moduleColumnList != null)
             {
                 foreach (ModuleColumnEntity columnItem in moduleColumnList)
                 {
                     Base_ModuleColumn modulecolumn = new Base_ModuleColumn();
                     modulecolumn = EntityConvertTools.CopyToModel <ModuleColumnEntity, Base_ModuleColumn>(columnItem, null);
                     modulecolumn.Insert();
                 }
             }
             tran.Complete();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
 /// <summary>
 /// 删除功能
 /// </summary>
 /// <param name="keyValue">主键</param>
 public void RemoveForm(string keyValue)
 {
     try
     {
         QSDMS_SQLDB db = QSDMS_SQLDB.GetInstance();
         using (var tran = db.GetTransaction())
         {
             int count = db.Fetch <Base_Module>("select * from Base_Module").FindAll(t => t.ParentId == keyValue).Count();
             if (count > 0)
             {
                 throw new Exception("当前所选数据有子节点数据!");
             }
             Base_Module.Delete("where ModuleId=@0", keyValue);
             Base_ModuleButton.Delete("where ModuleId=@0", keyValue);
             Base_ModuleColumn.Delete("where ModuleId=@0", keyValue);
             //提交事务
             tran.Complete();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }