如题!最好是成熟可用代码

解决方案 »

  1.   


      private void btnPrint_Click(object sender, EventArgs e)
            {
                btnPrint.Focus();
                if (!ScreenCheck()) return;
                clsSale cs = new clsSale();
                clsParameter cp = new clsParameter();
                DataSet ds = new DataSet();
                cs.itemcd = txtItemCD.Value;
                //cs.typecd = txtTypeCD.Value;
                cs.trade = cmbTradeMark.Value;//add by hu 20100720 商标            switch (ComLibrary.GetRadioButton(pnlList)) //add by hu 20100705
                {
                    case "0": //报价单打印                    switch (ComLibrary.GetRadioButton(pnlPrintType))
                        {
                            case "0": //进售价单打印 
                                int rtn = 0;
                                rtn = cp.GetdataDetail(1);
                                if (rtn == ComConst.FAILED)
                                {
                                    ComLibrary.getMsg(cp.sqlmsg, "E", "错误");
                                    return;
                                }
                                if (ComLibrary.GetRadioButton(pnlType) == "0")  //单品打印
                                {
                                    if (cp.num1 == 0)
                                    {
                                        ds = cs.GetDataList(10);//实际进价
                                    }
                                    if (cp.num1 == 1)
                                    {
                                        ds = cs.GetDataList(12);//虚拟进价
                                    }
                                }
                                if (ComLibrary.GetRadioButton(pnlType) == "1")  //套餐打印
                                {
                                    ds = cs.GetDataList(11);
                                }
                                try
                                {
                                    if (ds.Tables[0].Rows.Count == 0)
                                    {
                                        lblMsg.Text = cm.GetMessage("E00009");
                                        lblMsg.ForeColor = Color.Red;
                                        return;
                                    }
                                    //打印
                                    this.Cursor = Cursors.WaitCursor;
                                    CsReport.CS038CLS report = new LMS.CsReport.CS038CLS();
                                    report.Viewer = true;
                                    report.ZoomLevel = 100;
                                    report.FormWindowState = FormWindowState.Maximized;
                                    report.SetDataSource(ds.Tables[0]);
                                    report.Publish();
                                    DataTable a = ds.Tables[0];
                                }
                                catch (Exception ew)
                                {
                                    ComLibrary.getMsg(ew.Message, "E", "错误");
                                }
                                finally
                                {
                                    this.Cursor = Cursors.Default;
                                }
                                break;
                            case "1": //进价单打印                            if (ComLibrary.GetRadioButton(pnlType) == "0")  //单品打印
                                {
                                    ds = cs.GetDataList(12);//进价
                                }
                                if (ComLibrary.GetRadioButton(pnlType) == "1")  //套餐打印
                                {
                                    ds = cs.GetDataList(11);
                                }
                                try
                                {
                                    if (ds.Tables[0].Rows.Count == 0)
                                    {
                                        lblMsg.Text = cm.GetMessage("E00009");
                                        lblMsg.ForeColor = Color.Red;
                                        return;
                                    }
                                    //打印
                                    this.Cursor = Cursors.WaitCursor;
                                    CsReport.CS0381CLS report = new LMS.CsReport.CS0381CLS();
                                    report.Viewer = true;
                                    report.ZoomLevel = 100;
                                    report.FormWindowState = FormWindowState.Maximized;
                                    report.SetDataSource(ds.Tables[0]);
                                    report.Publish();
                                }
                                catch (Exception ew)
                                {
                                    ComLibrary.getMsg(ew.Message, "E", "错误");
                                }
                                finally
                                {
                                    this.Cursor = Cursors.Default;
                                }
                                break;
                            case "2": //售价单打印                            if (ComLibrary.GetRadioButton(pnlType) == "0")  //单品打印
                                {
                                    ds = cs.GetDataList(12);//售价
                                }
                                if (ComLibrary.GetRadioButton(pnlType) == "1")  //套餐打印
                                {
                                    ds = cs.GetDataList(11);
                                }
                                try
                                {
                                    if (ds.Tables[0].Rows.Count == 0)
                                    {
                                        lblMsg.Text = cm.GetMessage("E00009");
                                        lblMsg.ForeColor = Color.Red;
                                        return;
                                    }
                                    //打印
                                    this.Cursor = Cursors.WaitCursor;
                                    CsReport.CS0382CLS report = new LMS.CsReport.CS0382CLS();
                                    report.Viewer = true;
                                    report.ZoomLevel = 100;
                                    report.FormWindowState = FormWindowState.Maximized;
                                    report.SetDataSource(ds.Tables[0]);
                                    report.Publish();
                                }
                                catch (Exception ew)
                                {
                                    ComLibrary.getMsg(ew.Message, "E", "错误");
                                }
                                finally
                                {
                                    this.Cursor = Cursors.Default;
                                }
                                break;
                            case "3": //商品目录单打印                            if (ComLibrary.GetRadioButton(pnlType) == "0")  //单品打印
                                {
                                    ds = cs.GetDataList(16);//售价
                                }
                                if (ComLibrary.GetRadioButton(pnlType) == "1")  //套餐打印
                                {
                                    ds = cs.GetDataList(11);
                                }
                                try
                                {
                                    if (ds.Tables[0].Rows.Count == 0)
                                    {
                                        lblMsg.Text = cm.GetMessage("E00009");
                                        lblMsg.ForeColor = Color.Red;
                                        return;
                                    }
                                    //打印
                                    this.Cursor = Cursors.WaitCursor;
                                    CsReport.CS0383CLS report = new LMS.CsReport.CS0383CLS();
                                    report.Viewer = true;
                                    report.ZoomLevel = 100;
                                    report.FormWindowState = FormWindowState.Maximized;
                                    report.SetDataSource(ds.Tables[0]);
                                    report.Publish();
                                }
                                catch (Exception ew)
                                {
                                    ComLibrary.getMsg(ew.Message, "E", "错误");
                                }
                                finally
                                {
                                    this.Cursor = Cursors.Default;
                                }                            break;
                        }
                        break;
                }
            }