public CrmCentMultipleBill GetRuleBill(int billId) { lock (billList) { foreach (CrmCentMultipleBill bill in billList) { if (bill.BillId == billId) { return(bill); } } CrmCentMultipleBill bill2 = CreateRuleBill(billId); if (bill2 != null) { billList.Add(bill2); } return(bill2); } }
private CrmCentMultipleBill CreateRuleBill(int billId) { CrmCentMultipleBill bill = null; DbConnection conn = DbConnManager.GetDbConnection("CRMDB"); DbCommand cmd = conn.CreateCommand(); StringBuilder sql = new StringBuilder(); try { try { conn.Open(); } catch (Exception e) { throw new MyDbException(e.Message, true); } try { sql.Append("select KSRQ,JSRQ from HYTDJFDYD where JLBH = ").Append(billId); cmd.CommandText = sql.ToString(); DbDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { bill = new CrmCentMultipleBill(); bill.BillId = billId; bill.BeginTime = DbUtils.GetDateTime(reader, 0); bill.EndTime = DbUtils.GetDateTime(reader, 1); reader.Close(); sql.Length = 0; sql.Append("select GZBH,JFBS,BSFS,GRPID from HYTDJFDYD_GZSD where JLBH = ").Append(billId); sql.Append(" order by GZBH"); cmd.CommandText = sql.ToString(); reader = cmd.ExecuteReader(); while (reader.Read()) { if (bill.Items == null) { bill.Items = new List <CrmCentMultipleBillItem>(); } CrmCentMultipleBillItem item = new CrmCentMultipleBillItem(); bill.Items.Add(item); item.Inx = DbUtils.GetInt(reader, 0); item.Multiple = DbUtils.GetDouble(reader, 1); item.MultiMode = DbUtils.GetInt(reader, 2); item.VipGroup.GroupId = DbUtils.GetInt(reader, 3); } reader.Close(); if (bill.Items != null) { foreach (CrmCentMultipleBillItem item in bill.Items) { if (item.VipGroup.GroupId > 0) { CrmPubUtils.GetVipGroup(cmd, sql, item.VipGroup); } } } return(bill); } else { reader.Close(); } } catch (Exception e) { if (e is MyDbException) { throw e; } else { throw new MyDbException(e.Message, cmd.CommandText); } } } finally { conn.Close(); } return(null); }