#region
|
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using CSFrameworkV5.Common;
|
using CSFrameworkV5.Core;
|
using CSFrameworkV5.DataAccess;
|
using CSFrameworkV5.Interfaces;
|
using CSFrameworkV5.Models;
|
using CSFrameworkV5.WebRef.SystemModule;
|
using tb_MyGroupUser = CSFrameworkV5.Interfaces.tb_MyGroupUser;
|
|
#endregion
|
|
namespace CSFrameworkV5.Business.BLL_Permission
|
{
|
public class bllGroup : bllBaseDataDict
|
{
|
private IBridge_UserGroup _Bridge;
|
|
private DataTable _GroupRoles;
|
|
private DataTable _GroupUsers;
|
|
public bllGroup()
|
{
|
_KeyFieldName = tb_MyGroup.__KeyName; //主键字段
|
_SummaryTableName = tb_MyGroup.__TableName; //表名
|
_DataDictBridge =
|
BridgeFactory.CreateDataDictBridge(typeof(tb_MyGroup));
|
_Bridge = CreateBridge(); //实例化桥接功能
|
}
|
|
public DataTable GroupRoles
|
{
|
get => _GroupRoles;
|
set => _GroupRoles = value;
|
}
|
|
public DataTable GroupUsers
|
{
|
get => _GroupUsers;
|
set => _GroupUsers = value;
|
}
|
|
public int Add(List<tb_MyGroupUser> data)
|
{
|
return _Bridge.Add(data);
|
}
|
|
private IBridge_UserGroup CreateBridge()
|
{
|
if (BridgeFactory.IsADODirect)
|
return new dalUserGroup(Loginer.CurrentUser);
|
|
if (BridgeFactory.IsWCFBridge) return new WCF_UserGroup();
|
|
throw new CustomException(BridgeFactory.UNKNOW_BRIDGE_TYPE);
|
}
|
|
public override void CreateDataBinder(DataRow sourceRow)
|
{
|
base.CreateDataBinder(sourceRow);
|
|
//新增记录,给帐套编号预设值
|
if (_DataBinder.Rows[0].RowState == DataRowState.Added)
|
{
|
_DataBinder.Rows[0][tb_MyGroup.IsVisible] = 'Y';
|
_DataBinder.Rows[0][tb_MyGroup.RowID] = Globals.NewRowID();
|
_DataBinder.Rows[0][tb_MyGroup.DataSetID] =
|
Loginer.CurrentUser.DBID;
|
}
|
}
|
|
//删除资料
|
public override bool Delete(string keyValue)
|
{
|
return _Bridge.DeleteGroupData(keyValue);
|
}
|
|
public bool DeleteGroupData(string groupCode)
|
{
|
return _Bridge.DeleteGroupData(groupCode);
|
}
|
|
public bool DeleteGroupRights(string groupCode)
|
{
|
return _Bridge.DeleteGroupRights(groupCode);
|
}
|
|
public bool DeleteGroupUser(string groupCode, string account)
|
{
|
return _Bridge.DeleteGroupUser(groupCode, account);
|
}
|
|
private DataTable GetGroup4Picker(bool firstRowEmpty)
|
{
|
var dt = _Bridge.GetGroup4Picker();
|
if (firstRowEmpty)
|
{
|
var row = dt.NewRow();
|
row[tb_MyGroup.GroupCode] = "";
|
row[tb_MyGroup.GroupName] = "";
|
dt.Rows.InsertAt(row, 0);
|
dt.AcceptChanges();
|
}
|
|
return dt;
|
}
|
|
public DataTable GetGroupByUser(string account)
|
{
|
return _Bridge.GetGroupByUser(account);
|
}
|
|
public DataTable GetGroupRoles(string groupCode)
|
{
|
return _Bridge.GetGroupRoles(groupCode);
|
}
|
|
public DataTable GetGroupRoles4Picker(string currentGroupCode,
|
string currentUser)
|
{
|
return _Bridge.GetGroupRoles4Picker(currentGroupCode, currentUser);
|
}
|
|
public DataTable GetGroupUsers(string groupCode)
|
{
|
return _Bridge.GetGroupUsers(groupCode);
|
}
|
|
public DataTable GetGroupUsers4Picker(string groupCode)
|
{
|
return _Bridge.GetGroupUsers4Picker(groupCode);
|
}
|
|
public DataTable GetGroupUsers4TreeList()
|
{
|
return _Bridge.GetGroupUsers4TreeList();
|
}
|
|
public DataTable GetMyGroups4Picker(string account)
|
{
|
return _Bridge.GetMyGroups4Picker(account);
|
}
|
|
public DataTable Search(string GroupCode, string GroupName,
|
string AttributeCodes, string Owner1,
|
string OwnerTel1)
|
{
|
var dt = _Bridge.Search(GroupCode, GroupName, AttributeCodes,
|
Owner1, OwnerTel1);
|
_SummaryTable = dt;
|
return dt;
|
}
|
|
public bool SetOwner(string ownerType, string groupCode, string account)
|
{
|
return _Bridge.SetOwner(ownerType, groupCode, account);
|
}
|
|
public bool Update(UpdateType updateType, DataTable dtGroupUsers,
|
DataTable dtGroupRoles)
|
{
|
//创建一个副本用于保存
|
var data = new DataSet();
|
|
if (updateType == UpdateType.Add)
|
{
|
var groupCode =
|
ConvertEx.ToString(
|
_DataBinder.Rows[0][tb_MyGroup.GroupCode]);
|
|
if (dtGroupUsers != null)
|
for (var i = 0; i <= dtGroupUsers.Rows.Count - 1; i++)
|
dtGroupUsers.Rows[i][Models.tb_MyGroupUser.GroupCode] =
|
groupCode;
|
|
if (dtGroupRoles != null)
|
for (var i = 0; i <= dtGroupRoles.Rows.Count - 1; i++)
|
dtGroupRoles.Rows[i][tb_MyGroupRole.GroupCode] =
|
groupCode;
|
}
|
|
if (dtGroupUsers != null) data.Tables.Add(dtGroupUsers);
|
|
if (dtGroupRoles != null) data.Tables.Add(dtGroupRoles);
|
|
//调用数据层的方法提交数据
|
if (data.Tables.Count > 0) return _DataDictBridge.Update(data);
|
|
throw new Exception("您没有修改数据,不需要保存!");
|
}
|
|
#region 父级组参考数据
|
|
private DataTable _GroupLookupData;
|
|
/// <summary>
|
/// 父级组参考数据
|
/// </summary>
|
public DataTable GroupLookupData
|
{
|
get
|
{
|
if (_GroupLookupData == null) ReloadGroupLookupData();
|
|
return _GroupLookupData;
|
}
|
}
|
|
public void ReloadGroupLookupData()
|
{
|
_GroupLookupData = GetGroup4Picker(true);
|
}
|
|
#endregion
|
}
|
}
|