//[Transaction(TransactionMode.Requires)] //public void AddSupplierAddress(SupplierAddress SupplierAddress) //{ // if (SupplierAddress.IsPrimary) // { // this.genericMgr.Update("update from SupplierAddress set IsPrimary = ? where Supplier = ?", new object[] { false, SupplierAddress.Supplier }); // this.genericMgr.FlushSession(); // } // genericMgr.Create(SupplierAddress); //} //[Transaction(TransactionMode.Requires)] //public void UpdateSupplierAddress(Partyaddress SupplierAddress) //{ // if (SupplierAddress.IsPrimary) // { // this.genericMgr.Update("update from SupplierAddress set IsPrimary = ? where Supplier = ?", new object[] { false, SupplierAddress.Supplier }); // this.genericMgr.FlushSession(); // } // genericMgr.Update(SupplierAddress); //} #endregion #region private methods private IList <Supplier> GetOrderSupplier(com.Sconit.CodeMaster.OrderType type, string fromTo) { IList <Supplier> supplierList = genericMgr.FindAll <Supplier>(); return(supplierList); }
public IList <Supplier> GetOrderToSupplier(com.Sconit.CodeMaster.OrderType type) { return(GetOrderSupplier(type, "To")); }
public static string CheckFlowStatement(string flow, com.Sconit.CodeMaster.OrderType type) { return(CheckFlowStatement(flow, type, false)); }
public static void AddPartyToPermissionStatement(ref string whereStatement, string partyToTableAlias, string partyToFieldName, com.Sconit.CodeMaster.OrderType orderType) { //su特殊处理,不用考虑权限 User user = SecurityContextHolder.Get(); if (user.Code.Trim().ToLower() != "su") { if (whereStatement == string.Empty) { if (orderType == com.Sconit.CodeMaster.OrderType.Procurement) { whereStatement = " where (" + partyToTableAlias + ".IsCheckPartyToAuthority = 0 or (exists (select 1 from UserPermissionView as up where up.UserId =" + user.Id + "and up.PermissionCategoryType = " + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and up.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } else if (orderType == com.Sconit.CodeMaster.OrderType.Distribution) { whereStatement = " where (" + partyToTableAlias + ".IsCheckPartyToAuthority = 0 or (exists (select 1 from UserPermissionView as up where up.UserId =" + user.Id + "and up.PermissionCategoryType in (" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Customer + " ) and up.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } else if (orderType == com.Sconit.CodeMaster.OrderType.Production) { whereStatement = " where (" + partyToTableAlias + ".IsCheckPartyToAuthority = 0 or (exists (select 1 from UserPermissionView as up where up.UserId =" + user.Id + "and up.PermissionCategoryType = " + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and up.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } } else { if (orderType == com.Sconit.CodeMaster.OrderType.Procurement) { whereStatement += " and (" + partyToTableAlias + ".IsCheckPartyToAuthority = 0 or (exists (select 1 from UserPermissionView as up where up.UserId =" + user.Id + "and up.PermissionCategoryType = " + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and up.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } else if (orderType == com.Sconit.CodeMaster.OrderType.Distribution) { whereStatement += " and (" + partyToTableAlias + ".IsCheckPartyToAuthority = 0 or (exists (select 1 from UserPermissionView as up where up.UserId =" + user.Id + "and up.PermissionCategoryType in (" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Customer + " ) and up.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } else if (orderType == com.Sconit.CodeMaster.OrderType.Production) { whereStatement += " and (" + partyToTableAlias + ".IsCheckPartyToAuthority = 0 or (exists (select 1 from UserPermissionView as up where up.UserId =" + user.Id + "and up.PermissionCategoryType = " + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and up.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } } } }
//参数OrderType指菜单类别:供货、发货、生产 //参数orderType指订单类型:采购/生产/移库/销售 public static void AddPartyFromAndPartyToPermissionStatement(ref string whereStatement, string orderTypeTableAlias, string orderTypeFieldName, string partyFromTableAlias, string partyFromFieldName, string partyToTableAlias, string partyToFieldName, com.Sconit.CodeMaster.OrderType orderType, bool isSupplier) { //su特殊处理,不用考虑权限 User user = SecurityContextHolder.Get(); if (user.Code.Trim().ToLower() != "su") { if (whereStatement == string.Empty) { if (orderType == com.Sconit.CodeMaster.OrderType.Procurement) { if (isSupplier) { whereStatement = " where " + orderTypeTableAlias + "." + orderTypeFieldName + " in (" + (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + "," + (int)com.Sconit.CodeMaster.OrderType.Procurement + "," + (int)com.Sconit.CodeMaster.OrderType.SubContract + "," + (int)com.Sconit.CodeMaster.OrderType.ScheduleLine + ")" + " and exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType in (" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Supplier + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Customer + ") and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + ")"; } else { whereStatement = " where ((" + orderTypeTableAlias + "." + orderTypeFieldName + " in (" + (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + "," + (int)com.Sconit.CodeMaster.OrderType.Procurement + "," + (int)com.Sconit.CodeMaster.OrderType.SubContract + "," + (int)com.Sconit.CodeMaster.OrderType.ScheduleLine + ") and ( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType in (" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Supplier + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Customer + ") and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + "))" + " and (exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))" + " or (" + orderTypeTableAlias + "." + orderTypeFieldName + " in (" + (int)com.Sconit.CodeMaster.OrderType.Transfer + "," + (int)com.Sconit.CodeMaster.OrderType.SubContractTransfer + ") and ( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + "))))"; } } else if (orderType == com.Sconit.CodeMaster.OrderType.Distribution) { whereStatement = " where ((" + orderTypeTableAlias + "." + orderTypeFieldName + " = " + (int)com.Sconit.CodeMaster.OrderType.Distribution + " and ( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType in (" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Customer + ") and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")) and (exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + ")))" + " or (" + orderTypeTableAlias + "." + orderTypeFieldName + " in (" + (int)com.Sconit.CodeMaster.OrderType.Transfer + "," + (int)com.Sconit.CodeMaster.OrderType.SubContractTransfer + ") and ( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + "))))"; } else if (orderType == com.Sconit.CodeMaster.OrderType.Production) { whereStatement = " where (( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + "))" + " or (( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } else if (orderType == com.Sconit.CodeMaster.OrderType.Transfer) { whereStatement = " where (( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + "))" + " or (exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } } else { if (orderType == com.Sconit.CodeMaster.OrderType.Procurement) { if (isSupplier) { whereStatement += " and " + orderTypeTableAlias + "." + orderTypeFieldName + " in (" + (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + "," + (int)com.Sconit.CodeMaster.OrderType.Procurement + "," + (int)com.Sconit.CodeMaster.OrderType.SubContract + "," + (int)com.Sconit.CodeMaster.OrderType.ScheduleLine + ")" + " and exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType in (" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Supplier + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Customer + ") and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + ")"; } else { whereStatement += " and ((" + orderTypeTableAlias + "." + orderTypeFieldName + " in (" + (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + "," + (int)com.Sconit.CodeMaster.OrderType.Procurement + "," + (int)com.Sconit.CodeMaster.OrderType.SubContract + "," + (int)com.Sconit.CodeMaster.OrderType.ScheduleLine + ") and ( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType in (" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Supplier + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Customer + ") and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + "))" + " and (exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))" + " or (" + orderTypeTableAlias + "." + orderTypeFieldName + " in (" + (int)com.Sconit.CodeMaster.OrderType.Transfer + "," + (int)com.Sconit.CodeMaster.OrderType.SubContractTransfer + ") and ( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + "))))"; } } else if (orderType == com.Sconit.CodeMaster.OrderType.Distribution) { whereStatement += " and ((" + orderTypeTableAlias + "." + orderTypeFieldName + " = " + (int)com.Sconit.CodeMaster.OrderType.Distribution + " and ( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType in (" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + "," + (int)com.Sconit.CodeMaster.PermissionCategoryType.Customer + ") and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")) and (exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + ")))" + " or (" + orderTypeTableAlias + "." + orderTypeFieldName + " in (" + (int)com.Sconit.CodeMaster.OrderType.Transfer + "," + (int)com.Sconit.CodeMaster.OrderType.SubContractTransfer + ") and ( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + "))))"; } else if (orderType == com.Sconit.CodeMaster.OrderType.Production) { whereStatement += " and (( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + "))" + " or (exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } else if (orderType == com.Sconit.CodeMaster.OrderType.Transfer) { whereStatement += " and (( exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyFromTableAlias + "." + partyFromFieldName + "))" + " or (exists (select 1 from UserPermissionView as p where p.UserId =" + user.Id + "and p.PermissionCategoryType =" + (int)com.Sconit.CodeMaster.PermissionCategoryType.Region + " and p.PermissionCode = " + partyToTableAlias + "." + partyToFieldName + ")))"; } } } }