public CrmPromDecMoneyRuleItem AddItem(double saleMoney, double decMoney) { CrmPromDecMoneyRuleItem item = new CrmPromDecMoneyRuleItem(); item.SaleMoney = saleMoney; item.DecMoney = decMoney; return(item); }
private CrmPromDecMoneyRule CreateRule(int ruleId) { CrmPromDecMoneyRule rule = null; DbConnection conn = DbConnManager.GetDbConnection("CRMDB"); DbCommand cmd = conn.CreateCommand(); StringBuilder sql = new StringBuilder(); sql.Append("select QDJE,FFXE,BJ_TY from MBJZGZ where MBJZGZID = ").Append(ruleId); cmd.CommandText = sql.ToString(); try { try { conn.Open(); } catch (Exception e) { throw new MyDbException(e.Message, true); } try { DbDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { rule = new CrmPromDecMoneyRule(); rule.RuleId = ruleId; rule.MinSaleMoney = DbUtils.GetDouble(reader, 0); rule.MaxDecMoney = DbUtils.GetDouble(reader, 1); rule.IsNoDecMoney = (DbUtils.GetBool(reader, 2)); reader.Close(); sql.Length = 0; sql.Append("select XSJE,ZKJE from MBJZGZITEM where MBJZGZID = ").Append(ruleId); sql.Append(" and XSJE > 0 and ZKJE >= 0 order by XSJE desc "); cmd.CommandText = sql.ToString(); reader = cmd.ExecuteReader(); while (reader.Read()) { CrmPromDecMoneyRuleItem ruleItem = new CrmPromDecMoneyRuleItem(); rule.Items.Add(ruleItem); ruleItem.SaleMoney = DbUtils.GetDouble(reader, 0); ruleItem.DecMoney = DbUtils.GetDouble(reader, 1); } reader.Close(); } reader.Close(); } catch (Exception e) { if (e is MyDbException) { throw e; } else { throw new MyDbException(e.Message, cmd.CommandText); } } } finally { conn.Close(); } return(rule); }