Пример #1
0
        public static bool GenerateCurrencyValue(BusinessObject obj)
        {
            bool isModified = false;

            String strFK_GECurrencyID = DataStructureProvider.GetForeignKeyOfTableName(obj.AATableName, "GECurrencys");

            if (!String.IsNullOrWhiteSpace(strFK_GECurrencyID))
            {
                if (AppCurrencyID == Guid.Empty)
                {
                    String strQuery = @"SELECT FK_GECurrencyID FROM GEAppConfigs";
                    AppCurrencyID = ABCHelper.DataConverter.ConvertToGuid(BusinessObjectController.GetData(strQuery));
                }
                ABCDynamicInvoker.SetValue(obj, strFK_GECurrencyID, AppCurrencyID);
                if (AppCurrencyID != Guid.Empty && DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colExchangeRate))
                {
                    object objDate    = DateTime.MinValue;
                    String strDateCol = String.Empty;
                    if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateTime))
                    {
                        strDateCol = ABCCommon.ABCConstString.colCreateTime;
                    }
                    if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colDocumentDate))
                    {
                        strDateCol = ABCCommon.ABCConstString.colDocumentDate;
                    }

                    if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colVoucherDate))
                    {
                        strDateCol = ABCCommon.ABCConstString.colVoucherDate;
                    }

                    if (!String.IsNullOrWhiteSpace(strDateCol))
                    {
                        objDate = ABCDynamicInvoker.GetValue(obj, strDateCol);

                        object objOldValue = ABCDynamicInvoker.GetValue(obj, ABCCommon.ABCConstString.colExchangeRate);

                        if (objDate != null && objDate is DateTime)
                        {
                            object objNewValue = CurrencyProvider.GetExchangeRate(AppCurrencyID, Convert.ToDateTime(objDate));
                            ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colExchangeRate, objNewValue);
                            isModified = isModified || (objOldValue != objNewValue);
                        }
                        else if (objDate != null && objDate is Nullable <DateTime> )
                        {
                            object objNewValue = CurrencyProvider.GetExchangeRate(AppCurrencyID, (objDate as Nullable <DateTime>).Value);
                            ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colExchangeRate, objNewValue);
                            isModified = isModified || (objOldValue != objNewValue);
                        }
                    }
                }
            }

            return(isModified);
        }
Пример #2
0
        public static double GetCredit(Guid partnerID, CreditConfigType configType)
        {
            double amt = 0;

            foreach (CRCreditConfigsInfo config in GetCreditConfigs(configType))
            {
                String strFKPartnerIDCol = config.PartnerIDField;
                if (String.IsNullOrWhiteSpace(strFKPartnerIDCol))
                {
                    strFKPartnerIDCol = "FK_MAPartnerID";
                }

                String strQuery = QueryGenerator.GenSelect(config.TableName, String.Format("SUM({0})", config.AmtFCField), true);
                strQuery = QueryGenerator.AddCondition(strQuery, config.ConditionString);

                if (DataStructureProvider.IsTableColumn(config.TableName, strFKPartnerIDCol))
                {
                    strQuery = QueryGenerator.AddEqualCondition(strQuery, strFKPartnerIDCol, partnerID);
                }
                else
                {
                    if (DataStructureProvider.IsExistedTable(config.ParentTableName))
                    {
                        if (DataStructureProvider.IsTableColumn(config.ParentTableName, strFKPartnerIDCol))
                        {
                            String strFK     = DataStructureProvider.GetForeignKeyOfTableName(config.TableName, config.ParentTableName);
                            String strQuery2 = QueryGenerator.GenSelect(config.ParentTableName, DataStructureProvider.GetPrimaryKeyColumn(config.ParentTableName), true);
                            strQuery2 = QueryGenerator.AddEqualCondition(strQuery2, strFKPartnerIDCol, partnerID);
                            strQuery  = QueryGenerator.AddCondition(strQuery, String.Format("{0} IN ({1})", strFK, strQuery2));
                        }
                    }
                }

                object obj = BusinessObjectController.GetData(strQuery);
                if (obj != null && obj != DBNull.Value)
                {
                    amt += Convert.ToDouble(obj);
                }
            }
            return(amt);
        }
Пример #3
0
        public static void CalculateCredit(String strTableName, Guid ID)
        {
            List <Guid> lstPartnerIDs     = new List <Guid>();
            BusinessObjectController ctrl = BusinessControllerFactory.GetBusinessController(strTableName);

            if (ctrl != null)
            {
                BusinessObject obj = ctrl.GetObjectByID(ID);
                if (obj != null)
                {
                    String strPartnerFKCol = DataStructureProvider.GetForeignKeyOfTableName(strTableName, "MAPartners");
                    if (String.IsNullOrWhiteSpace(strPartnerFKCol) == false)
                    {
                        Guid partnerID = ABCHelper.DataConverter.ConvertToGuid(ABCDynamicInvoker.GetValue(obj, strPartnerFKCol));
                        if (partnerID != Guid.Empty && !lstPartnerIDs.Contains(partnerID))
                        {
                            lstPartnerIDs.Add(partnerID);
                        }
                    }

                    foreach (GEVoucherItemsInfo voucherItem in VoucherProvider.GetConfigItems(strTableName, ""))
                    {
                        strPartnerFKCol = DataStructureProvider.GetForeignKeyOfTableName(voucherItem.ItemTableName, "MAPartners");
                        if (String.IsNullOrWhiteSpace(strPartnerFKCol) == false)
                        {
                            Guid partnerID = ABCHelper.DataConverter.ConvertToGuid(ABCDynamicInvoker.GetValue(obj, strPartnerFKCol));
                            if (partnerID != Guid.Empty && !lstPartnerIDs.Contains(partnerID))
                            {
                                lstPartnerIDs.Add(partnerID);
                            }
                        }
                    }
                }
            }
            foreach (Guid partnerID in lstPartnerIDs)
            {
                CreditProvider.CalculateCredit(partnerID);
            }
        }
Пример #4
0
        public static String GetAlertQueryString(Guid alertID)
        {
            if (AlertList == null)
            {
                GetAlertConfigs(ABCUserProvider.CurrentUser.ADUserID);
            }

            if (AlertList.ContainsKey(alertID) == false)
            {
                return(String.Empty);
            }

            if (AlertQueryList.ContainsKey(alertID))
            {
                return(AlertQueryList[alertID]);
            }

            GEAlertsInfo alertInfo = AlertList[alertID];

            if (alertInfo == null || alertInfo.GetID() == null)
            {
                return(String.Empty);
            }

            String strQuery = QueryGenerator.GenSelect(alertInfo.TableName, "*", false);

            strQuery = QueryGenerator.AddCondition(strQuery, alertInfo.ConditionString);

            #region Filter with current User

            if (alertInfo.ByUser)
            {
                String strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "ADUsers");
                if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentUser != null)
                {
                    strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} = '{1}'", strFK, ABCUserProvider.CurrentUser.ADUserID));
                }
            }
            if (alertInfo.ByUserGroup)
            {
                String strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "ADUsers");
                if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentUser != null)
                {
                    if (ABCUserProvider.CurrentUserGroup != null)
                    {
                        String strQueryUserID = QueryGenerator.AddEqualCondition(QueryGenerator.GenSelect("ADUsers", "ADUserID", false), "FK_ADUserGroupID", ABCUserProvider.CurrentUserGroup.ADUserGroupID);
                        strQuery = QueryGenerator.AddCondition(strQuery, String.Format("{0} IN ({1})", strFK, strQueryUserID));
                    }
                }
                else
                {
                    strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "ADUserGroups");
                    if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentUserGroup != null)
                    {
                        strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} = '{1}'", strFK, ABCUserProvider.CurrentUserGroup.ADUserGroupID));
                    }
                }
            }
            if (alertInfo.ByEmployee)
            {
                String strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "HREmployees");
                if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentEmployee != null)
                {
                    strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} = '{1}'", strFK, ABCUserProvider.CurrentEmployee.HREmployeeID));
                }
            }
            if (alertInfo.ByCompanyUnit)
            {
                String strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "GECompanyUnits");
                if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentCompanyUnit != null)
                {
                    strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} = '{1}'", strFK, ABCUserProvider.CurrentCompanyUnit.GECompanyUnitID));
                }
                else
                {
                    if (!String.IsNullOrWhiteSpace(strFK) && !String.IsNullOrWhiteSpace(DataStructureProvider.GetForeignKeyOfTableName("HREmployees", "GECompanyUnits")))
                    {
                        String strTemp = QueryGenerator.GenSelect("GECompanyUnits", DataStructureProvider.GetForeignKeyOfTableName("HREmployees", "GECompanyUnits"), false);
                        strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} IN ({1})", strFK, strTemp));
                    }
                }
            }
            #endregion


            if (DataStructureProvider.IsTableColumn(alertInfo.TableName, ABCCommon.ABCConstString.colDocumentDate))
            {
                strQuery = strQuery + String.Format(@" ORDER BY {0} DESC", ABCCommon.ABCConstString.colDocumentDate);
            }

            AlertQueryList.Add(alertID, strQuery);

            return(strQuery);
        }