using System; using System.Collections; using System.Data; using BP.DA; using BP.Web; using BP.En; using BP.Difference; namespace BP.Cloud { /// /// 部门编号人员 /// public class DeptEmpAttr { /// /// 操作员 /// public const string FK_Emp = "FK_Emp"; /// /// 部门编号 /// public const string FK_Dept = "FK_Dept"; /// /// 组织结构编码 /// public const string OrgNo = "OrgNo"; /// /// 是否是主要部门 /// public const string IsMainDept = "IsMainDept"; /// /// 人员编号() /// public const string EmpNo = "EmpNo"; } /// /// 部门编号人员 /// public class DeptEmp : EntityMyPK { #region 属性 /// /// 是否是主部门 /// public bool IsMainDept { get { return this.GetValBooleanByKey(DeptEmpAttr.IsMainDept); } set { this.SetValByKey(DeptEmpAttr.IsMainDept, value); } } public string FK_Emp { get { return this.GetValStringByKey(DeptEmpAttr.FK_Emp); } set { this.SetValByKey(DeptEmpAttr.FK_Emp, value); } } /// /// 人员编号 /// public string EmpNo { get { return this.GetValStringByKey(DeptEmpAttr.EmpNo); } set { this.SetValByKey(DeptEmpAttr.EmpNo, value); } } public string FK_Dept { get { return this.GetValStringByKey(DeptEmpAttr.FK_Dept); } set { this.SetValByKey(DeptEmpAttr.FK_Dept, value); } } /// /// 组织结构编码 /// public string OrgNo { get { return this.GetValStrByKey(EmpAttr.OrgNo); } set { this.SetValByKey(EmpAttr.OrgNo, value); } } #endregion #region 构造方法 /// /// 部门编号人员 /// public DeptEmp() { } /// /// 部门编号人员 /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("Port_DeptEmp", "部门人员"); map.AddMyPK(); map.AddTBString(DeptEmpAttr.FK_Dept, null, "编号", true, false, 0, 50, 20); map.AddTBString(DeptEmpAttr.FK_Emp, null, "人员", true, false, 0, 50, 20); map.AddTBString(EmpAttr.OrgNo, null, "OrgNo", false, false, 0, 50, 36); // SAAS 模式下用到. if (SystemConfig.CCBPMRunModel == BP.Sys.CCBPMRunModel.SAAS) { map.AddTBString(DeptEmpAttr.EmpNo, null, "EmpNo", false, false, 0, 50, 36); map.AddTBInt(DeptEmpAttr.IsMainDept, 1, "是否是主部门", false, false); } this._enMap = map; return this._enMap; } } #endregion protected override bool beforeDelete() { if (DataType.IsNullOrEmpty(this.EmpNo) == false) { BP.Cloud.Emp emp = new Emp(); emp.No = this.EmpNo; if (emp.RetrieveFromDBSources() == 1) { this.FK_Emp = emp.UserID; this.OrgNo = emp.OrgNo; } } this.setMyPK(this.FK_Dept + "_" + this.FK_Emp); //删除角色信息. DeptEmpStations des = new DeptEmpStations(); des.Delete(DeptEmpStationAttr.FK_Emp, this.FK_Emp, DeptEmpStationAttr.FK_Dept, this.FK_Dept); return base.beforeDelete(); } protected override bool beforeInsert() { //if (BP.Difference.SystemConfig.CCBPMRunModel!= BP.Sys.CCBPMRunModel.Single && this.EmpNo.Contains(BP.Web.WebUser.OrgNo + "_") == true) //{ // BP.Cloud.Emp emp = new BP.Cloud.Emp(this.EmpNo); // this.setMyPK(this.FK_Dept + "_" + emp.UserID); // this.FK_Emp = emp.UserID; // this.IsMainDept = false; //} //if (DataType.IsNullOrEmpty(this.EmpNo) == true) //{ // this.EmpNo = BP.Web.WebUser.OrgNo + "_" + this.FK_Emp; //} ////组织编号. //this.OrgNo = BP.Web.WebUser.OrgNo; //当前人员所在的部门. //this.OrgNo = BP.Web.WebUser.FK_Dept; return base.beforeInsert(); } } /// /// 部门编号人员s /// public class DeptEmps : EntitiesMM { #region 构造 /// /// 部门编号s /// public DeptEmps() { } /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new DeptEmp(); } } #endregion public override int RetrieveAll() { return this.Retrieve(EmpAttr.OrgNo, BP.Web.WebUser.OrgNo); } #region 为了适应自动翻译成java的需要,把实体转换成List. /// /// 转化成 java list,C#不能调用. /// /// List public System.Collections.Generic.IList ToJavaList() { return (System.Collections.Generic.IList)this; } /// /// 转化成list /// /// List public System.Collections.Generic.List Tolist() { System.Collections.Generic.List list = new System.Collections.Generic.List(); for (int i = 0; i < this.Count; i++) { list.Add((DeptEmp)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }