private void frmSupplyReport_Load(object sender, EventArgs e) { Supply s = new Supply(); s.GetModel(_supplyID); if (string.IsNullOrEmpty(s.SupplyID)) { MessageBox.Show("该供货单不存在!"); return; } Agent _a = new Agent(s.AgentName); decimal _sum = 0; DataTable ds = GetGroupSupply(out _sum); ReportDataSource rds = new ReportDataSource("DataSet1_DataTable1", ds); reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(rds); string _barStr = ""; string sql = "SELECT Model,Barcode FROM SupplyDetail WHERE SupplyID='" + _supplyID + "' ORDER BY Model,Barcode ASC"; DataTable dt = SqlHelper.ExecuteDataTable(sql); if (dt != null&& dt.Rows.Count>0) { string _modelNow = ""; foreach (DataRow dr in dt.Rows) { string _m = dr["Model"].ToString(); if (_modelNow != _m) { _modelNow = _m; _barStr += "\n" + _modelNow + " 型号:\n"; } _barStr += dr["Barcode"].ToString()+"、"; } if (_barStr.Substring(0, 1) == "\n") { _barStr = _barStr.Substring(1); } } ReportParameter[] pas = new ReportParameter[] { new ReportParameter("pam_GoodsName", CommonService.GetParamValue("GoodsName")), new ReportParameter("pam_Company", CommonService.GetParamValue("Name")), new ReportParameter("pam_Address", CommonService.GetParamValue("Address")), new ReportParameter("pam_Phone", CommonService.GetParamValue("Phone")), new ReportParameter("pam_Remark", _barStr), new ReportParameter("pam_Date",s.CreateTime.ToString("yyyy年MM月dd日")), new ReportParameter("pam_NO", s.SupplyID), new ReportParameter("pam_SumSmall", _sum.ToString("0.00")), new ReportParameter("pam_SumAmount", CommonService.MoneyToChinese(_sum.ToString("0.00"))), new ReportParameter("pam_SupplyPhone",_a.Phone==null?"":_a.Phone), new ReportParameter("pam_SupplyTel",_a.Tel==null?"":_a.Tel), new ReportParameter("pam_SupplyAddress",_a.Address==null?"":_a.Address), new ReportParameter("pam_Supply", s.AgentName) }; reportViewer1.LocalReport.SetParameters(pas); this.reportViewer1.RefreshReport(); }
private void frmSupplyDetail_Load(object sender, EventArgs e) { dataGridView1.AutoGenerateColumns = false; Supply s = new Supply(_supplyID); lab_Name.Text = "客户名称:" + s.AgentName; lab_Price.Text = "每平米价格:" + s.Price.ToString("0.00") + "元"; lab_CreatTime.Text = "供货日期:" + s.CreateTime.ToString("yyyy-MM-dd"); lab_Operator.Text = "操作人员:" + s.Operator; lab_Sum.Text = "总计金额:" + s.SumPrice.ToString("0.00") + "元"; lab_SupplyID.Text = "(单号:" + _supplyID + ")"; DataSet sd = new SupplyDetail().GetList(" SupplyID = '" + _supplyID + "'"); dataGridView1.DataSource = sd.Tables[0]; }
public void BindDGV() { //int cnt = 0; //foreach (DataRow w in dt.Rows) //{ // sumMoney += decimal.Parse(w["SumPrice"].ToString()); //} //cnt = dt.Rows.Count; decimal _sumMoney = 0; int _count = 0; Supply s = new Supply(); DataSet ds = s.GetPageList(pagerControl1.PageSize, pagerControl1.PageIndex, _sqlWhere, out _count,out _sumMoney);//s.GetFilterList(sqlWhere); pagerControl1.DrawControl(_count); lab_Cnt.Text = _count.ToString(); lab_Sum.Text = _sumMoney.ToString("0.00") + "元"; dataGridView1.DataSource = null; dataGridView1.DataSource = ds.Tables[0]; }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["cDetail"].Index) { object v = dataGridView1.Rows[e.RowIndex].Cells["cSupplyID"].Value; if (v != null) { string supplyID = v.ToString(); //frmSupplyDetail f = new frmSupplyDetail(supplyID); frmSupplyReport f = new frmSupplyReport(supplyID); f.ShowDialog(); } } else if (e.ColumnIndex == dataGridView1.Columns["cDel"].Index) { if (MessageBox.Show(this, "删除后数据不能恢复,是否继续删除?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { object v = dataGridView1.Rows[e.RowIndex].Cells["cSupplyID"].Value; if (v != null) { Supply no = new Supply(); int re = no.Delete(v.ToString()); if (re > 0) { MessageBox.Show("删除成功!"); BindDGV(); } else { MessageBox.Show("删除失败!"); } } } } }
private void button1_Click(object sender, EventArgs e) { if (cbx_Agent.SelectedValue == null) { MessageBox.Show("请先选择客户!"); cbx_Agent.Focus(); return; } if (cbx_Level.SelectedValue == null) { MessageBox.Show("请先选择级别!"); cbx_Level.Focus(); return; } if (allOut.Count <= 0) { MessageBox.Show("没有要出货的成品!"); return; } if (MessageBox.Show("确定要生成供货单吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } List <SupplyDetail> list = new List <SupplyDetail>(); foreach (InW i in allOut) { SupplyDetail s = new SupplyDetail(); s.Barcode = i.Barcode; s.NormName = i.NormName; s.SumMoney = i.SumPrice; s.Length = i.Length; s.Model = i.Model; list.Add(s); } Supply m = new Supply(); m.SupplyID = GenSupplyID(); m.AgentName = cbx_Agent.SelectedValue.ToString(); m.Price = _price; m.Operator = Global.userName; m.SumPrice = decimal.Parse(lab_Sum.Text.Replace("元", "").Trim()); int re = m.Add(list); if (re > 0) { //MessageBox.Show("生成供应单成功!"); _price = 0; cbx_Agent.SelectedIndex = -1; cbx_Level.SelectedIndex = -1; txt_Price.Text = ""; txt_Barcode.Text = ""; allOut = new List <InW>(); BindDGV(); frmSupplyReport ff = new frmSupplyReport(m.SupplyID); ff.Text = "生成供应单成功"; ff.ShowDialog(); } else { MessageBox.Show("生成供应单失败!"); } }
private void frmSupplyReport_Load(object sender, EventArgs e) { Supply s = new Supply(); s.GetModel(_supplyID); if (string.IsNullOrEmpty(s.SupplyID)) { MessageBox.Show("该供货单不存在!"); return; } Agent _a = new Agent(s.AgentName); // 本项目 Service 文件夹内的 Agent 类(属于 Model 层) decimal _sum = 0; DataTable ds = GetGroupSupply(out _sum); // GetGroupSupply 自定义函数 ReportDataSource rds = new ReportDataSource("DataSet1_DataTable1", ds); // 动态链接库 Microsoft.Reporting.WinForms.DLL 内的类 reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(rds); string _barStr = ""; string sql = "SELECT Model,Barcode FROM SupplyDetail WHERE SupplyID='" + _supplyID + "' ORDER BY Model,Barcode ASC"; DataTable dt = SqlHelper.ExecuteDataTable(sql); // 项目 SqlServer 内的 SqlHelper 类 if (dt != null && dt.Rows.Count > 0) { string _modelNow = ""; foreach (DataRow dr in dt.Rows) { string _m = dr["Model"].ToString(); if (_modelNow != _m) { _modelNow = _m; _barStr += "\n" + _modelNow + " 型号:\n"; } _barStr += dr["Barcode"].ToString() + "、"; } if (_barStr.Substring(0, 1) == "\n") { _barStr = _barStr.Substring(1); } } ReportParameter[] pas = new ReportParameter[] { new ReportParameter("pam_GoodsName", CommonService.GetParamValue("GoodsName")), // 项目 Common 内的 CommonService 类 new ReportParameter("pam_Company", CommonService.GetParamValue("Name")), new ReportParameter("pam_Address", CommonService.GetParamValue("Address")), new ReportParameter("pam_Phone", CommonService.GetParamValue("Phone")), new ReportParameter("pam_Remark", _barStr), new ReportParameter("pam_Date", s.CreateTime.ToString("yyyy年MM月dd日")), new ReportParameter("pam_NO", s.SupplyID), new ReportParameter("pam_SumSmall", _sum.ToString("0.00")), new ReportParameter("pam_SumAmount", CommonService.MoneyToChinese(_sum.ToString("0.00"))), new ReportParameter("pam_SupplyPhone", _a.Phone == null?"":_a.Phone), new ReportParameter("pam_SupplyTel", _a.Tel == null?"":_a.Tel), new ReportParameter("pam_SupplyAddress", _a.Address == null?"":_a.Address), new ReportParameter("pam_Supply", s.AgentName) }; reportViewer1.LocalReport.SetParameters(pas); this.reportViewer1.RefreshReport(); }