Example #1
0
 public CrmCentMoneyMultiRule GetRule(int ruleID)
 {
     lock (RuleList)
     {
         foreach (CrmCentMoneyMultiRule rule in RuleList)
         {
             if (rule.RuleID == ruleID)
             {
                 return(rule);
             }
         }
         CrmCentMoneyMultiRule rule2 = CreateRule(ruleID);
         if (rule2 != null)
         {
             RuleList.Add(rule2);
         }
         return(rule2);
     }
 }
Example #2
0
        private CrmCentMoneyMultiRule CreateRule(int ruleID)
        {
            CrmCentMoneyMultiRule rule = null;
            DbConnection          conn = DbConnManager.GetDbConnection("CRMDB");
            DbCommand             cmd  = conn.CreateCommand();
            StringBuilder         sql  = new StringBuilder();

            sql.Append("select GZMC from JFBSGZ where GZID = ").Append(ruleID);
            cmd.CommandText = sql.ToString();
            try
            {
                conn.Open();
                DbDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    rule          = new CrmCentMoneyMultiRule();
                    rule.RuleID   = ruleID;
                    rule.RuleName = DbUtils.GetString(reader, 0);
                    reader.Close();

                    sql.Length = 0;
                    sql.Append("select XSJE,BS from JFBSGZITEM where GZID = ").Append(ruleID);
                    sql.Append("  and XSJE > 0 order by XSJE desc ");
                    cmd.CommandText = sql.ToString();
                    reader          = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        rule.AddItem(DbUtils.GetDouble(reader, 0), DbUtils.GetDouble(reader, 1));
                    }
                    reader.Close();
                }
                reader.Close();
            }
            finally
            {
                conn.Close();
            }
            return(rule);
        }