public IEnumerable<PriceBook> Get(int level) { var helper = new SqlHelper(new SysConfigManager().Get().DbConfig.GetConnectionString()); helper.Open(); using (var rd = helper.Reader(Sql, new SqlParameter("@date", DateTime.Now.ToString("yyyy-MM-dd")))) { var list = new List<PriceBook>(); while (rd.Read()) { decimal price; decimal.TryParse(rd["price"].ToString(), out price); list.Add(new PriceBook { Code = rd["code"].ToString(), Price = price }); } rd.Close(); return list; } }
public IEnumerable<PriceBook> Get(int level) { if (level < 5)//5为普通客户价 { level++; } var helper = new SqlHelper(new SysConfigManager().Get().DbConfig.GetConnectionString()); helper.Open(); using (var rd = helper.Reader(string.Format(Sql, level))) { var list = new List<PriceBook>(); while (rd.Read()) { decimal price; decimal.TryParse(rd["invSCost" + level].ToString(), out price); list.Add(new PriceBook { Code = rd["code"].ToString(), Price = price }); } rd.Close(); return list; } }
private void 数据库配置ToolStripMenuItem_Click(object sender, EventArgs e) { _sysCfg = new SysConfigManager().Get(); var form = new DbConfig(); form.InitConfig(_sysCfg.DbConfig); var result = form.ShowDialog(); if (result != DialogResult.OK) return; form.SetConfig(_sysCfg.DbConfig); var sh = new SqlHelper(_sysCfg.DbConfig.GetConnectionString()); try { sh.Open(); new SysConfigManager().Set(_sysCfg); try { sh.Execute(_sysCfg.Excel2TplusHistorySql); } catch { } } catch { MessageBox.Show("数据库无法连接"); } finally { sh.Close(); } }
private void 安装历史记录表ToolStripMenuItem_Click(object sender, EventArgs e) { var sysCfg = new SysConfigManager().Get(); if (!sysCfg.HasDbConfig) { MessageBox.Show("请先设置数据库信息"); return; } if (MessageBox.Show("安装历史记录表将删除之前的历史记录,确定删除吗?", "注意", MessageBoxButtons.YesNo) == DialogResult.Yes) { var sqlHelper = new SqlHelper(sysCfg.DbConfig.GetConnectionString()); sqlHelper.Open(); sqlHelper.Execute(sysCfg.Excel2TplusHistorySql); sqlHelper.Close(); MessageBox.Show("安装成功"); } }