示例#1
0
        //打印清单
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            SetInitlocalsetting(hdMac.Text);//取mac地址

            try
            {
                if (gvList.Rows.Count <= 0 || gvList.SelectedRowIndexArray.Length <= 0)
                {
                    return;
                }

                //获取勾选的记录
                string ordernums = GetGridViewIds();

                DataSet ds = new DataSet();

                //hashtable保存财务报表头尾信息
                Hashtable htinfo = new Hashtable();
                htinfo["begindate"]    = dtpStart.Text;
                htinfo["enddate"]      = dtpEnd.Text;
                htinfo["customertype"] = "项目";
                htinfo["titleName"]    = ViewState["dictlabname"].ToString();


                //设置打印报表数据
                ds = comm.ConvertToDataSet(htinfo, ordernums, "billhead", null, null, "");

                CommonReport commonReport = new CommonReport();
                Report       report       = new Report();
                report = commonReport.GetReportByDataset("20", ds, 1);
                commonReport.PrintReport2(report.SaveToString(), commonReport.dsGetReportData.Copy(), Userinfo);

                ExtAspNet.PageContext.RegisterStartupScript(string.Format(" PrintReport(\'{0}\',\'{1}\',\'{2}\');", CommonReport.printer, CommonReport.json, CommonReport.dsjson));
            }
            catch (Exception ex)
            {
                MessageBoxShow(ex.Message, MessageBoxIcon.Error);
            }
        }
示例#2
0
        //打印明细
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            SetInitlocalsetting(hdMac.Text);//获取打印机配置信息
            try
            {
                if (gvDetail.Rows.Count <= 0 || gvDetail.SelectedRowIndexArray.Length <= 0)
                {
                    return;
                }

                int currentrowindex = (int)ViewState["currentrowindex"];

                //hashtable保存报表头尾信息
                Hashtable htinfo = new Hashtable();
                htinfo["customername"] = gvList.Rows[currentrowindex].Values[1].ToString();
                htinfo["salename"]     = gvList.Rows[currentrowindex].Values[5].ToString();
                htinfo["begindate"]    = gvList.Rows[currentrowindex].Values[7].Trim() == "" ? "" : DateTime.Parse(gvList.Rows[currentrowindex].Values[7].Trim()).ToString("yyyy-MM-dd");
                htinfo["enddate"]      = gvList.Rows[currentrowindex].Values[8].ToString() == "" ? "" : DateTime.Parse(gvList.Rows[currentrowindex].Values[8].ToString()).ToString("yyyy-MM-dd");
                htinfo["customertype"] = gvList.Rows[currentrowindex].Values[9].ToString() == "0" ? "项目" : "外包项目";
                htinfo["titleName"]    = ViewState["dictlabname"].ToString();


                double?dictlabid   = null;
                double?checkbillid = null;
                if (!string.IsNullOrEmpty(gvList.Rows[currentrowindex].Values[6].ToString()))
                {
                    checkbillid = double.Parse(gvList.Rows[currentrowindex].Values[6].ToString());
                }
                dictlabid = double.Parse(ViewState["dictlabid"].ToString());

                //设置打印报表数据
                string  billheadid = gvList.Rows[currentrowindex].Values[0].ToString();
                DataSet ds         = new DataSet();
                ds = comm.ConvertToDataSet(htinfo, billheadid, "billdetail", checkbillid, dictlabid, ViewState["flag"].ToString());

                //打印
                Report report = new Report();
                report = commonReport.GetReportByDataset("20", ds, 1);
                commonReport.PrintReport2(report.SaveToString(), commonReport.dsGetReportData.Copy(), Userinfo);

                ExtAspNet.PageContext.RegisterStartupScript(string.Format(" PrintReport(\'{0}\',\'{1}\',\'{2}\');", CommonReport.printer, CommonReport.json, CommonReport.dsjson));
            }
            catch (Exception ex)
            {
                MessageBoxShow(ex.Message, MessageBoxIcon.Error);
            }
        }
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            Hashtable htinfo = new Hashtable();

            htinfo["Ordernum"]    = tbxOrdernum.Text.Trim();
            htinfo["Realname"]    = tbxName.Text.Trim();
            htinfo["Productname"] = ViewState["testname"];
            htinfo["Finalprice"]  = tbxModifytotalprice.Text + "(元)";
            htinfo["Billbyname"]  = Userinfo.userId;
            htinfo["Billbydate"]  = System.DateTime.Now.Year + "年" + System.DateTime.Now.Month + "月" + System.DateTime.Now.Day + "日";
            htinfo["titleName"]   = Request["dictlabname"] == null ? "" : Request["dictlabname"];
            DataSet ds = comm.ConvertToDataSet(htinfo);

            //打印
            SetInitlocalsetting(hdMac.Text);//获取打印机配置信息
            CommonReport commonReport = new CommonReport();
            Report       report       = new Report();

            report = commonReport.GetReportByDataset("30", ds, 1);
            commonReport.PrintReport2(report.SaveToString(), commonReport.dsGetReportData, Userinfo);
            ExtAspNet.PageContext.RegisterStartupScript(string.Format(" PrintReport(\'{0}\',\'{1}\',\'{2}\');", CommonReport.printer, CommonReport.json, CommonReport.dsjson));
            btnPrint.Enabled = false;
            gvList.Rows.Clear();
        }