コード例 #1
0
        //准备报表数据
        private void PrepareReport()
        {
            //取报表数据
            DataSet ds = new bllSO().GetReportData(txtNoFrom.Text, txtNoTo.Text, txtDateFrom.DateTime, txtDateTo.DateTime);

            //报表实例
            _report = new TfrxReportClass();
            _report.OnBeforePrint += new IfrxReportEventDispatcher_OnBeforePrintEventHandler(Report_OnBeforePrint);
            _report.OnAfterPrint  += new IfrxReportEventDispatcher_OnAfterPrintEventHandler(Report_OnAfterPrint);

            ds.Tables[0].TableName = "M";                      //Master 主表
            ds.Tables[1].TableName = "D";                      //Detail 明细
            dtSummary    = new FrxDataTable(ds.Tables[0]);     //创建主表的报表代理数据
            dtDetailView = new FrxDataView(ds.Tables[1], "D"); //创建明细表的报表代理数据

            //主从表数据需要绑定3个事件, 取主表的主键用于过滤明细数据
            dtSummary.FrxEventOnFirst += new FrxOnFirst(OnGetValueHandler); //对应Delphi的DataSet.First
            dtSummary.FrxEventOnNext  += new FrxOnNext(OnGetValueHandler);  //对应Delphi的DataSet.Next
            dtSummary.FrxEventOnPrior += new FrxOnPrior(OnGetValueHandler); //对应Delphi的DataSet.Prior

            _report.MainWindowHandle = (int)this.Handle;
            _report.LoadReportFromFile(GetReportFile("SO.fr3")); //从文件加载报表
            _report.ClearDatasets();

            dtSummary.AssignToReport(true, _report);               //绑定报表数据集
            dtDetailView.AssignToReport(true, _report);            //绑定报表数据集

            dtSummary.AssignToDataBand("MasterData1", _report);    //绑定主表Band
            dtDetailView.AssignToDataBand("DetailData1", _report); //绑定明细表Bank
        }
コード例 #2
0
        public void ExecutePreview()
        {
            this.Hide();

            DataSet ds = new DataSet();

            ds.Tables.Add(new bllUser().GetUsers().Copy());//取报表数据

            _report = new TfrxReportClass();
            _report.OnBeforePrint += new IfrxReportEventDispatcher_OnBeforePrintEventHandler(Report_OnBeforePrint);
            _report.OnAfterPrint  += new IfrxReportEventDispatcher_OnAfterPrintEventHandler(Report_OnAfterPrint);

            ds.Tables[0].TableName = "User";                        //设置表名,与FastReport报表内名称定义一致
            dtSummary = new FrxDataTable(ds.Tables[0]);             //创建报表代理数据

            _report.MainWindowHandle = (int)this.Handle;            //设置报表窗体的主窗体
            _report.LoadReportFromFile(GetReportFile("users.fr3")); //加载报表文件
            _report.ClearDatasets();                                //先清空报表数据

            dtSummary.AssignToReport(true, _report);                //设置报表的主数据源
            dtSummary.AssignToDataBand("MasterData1", _report);     //绑定主表的报表数据

            frmPrintViewerFR.ExecutePreview(this, _report);         //显示打印预览窗体

            this.Close();                                           //预览或打印完成关闭本窗体
        }
コード例 #3
0
ファイル: ExpensePrint.cs プロジェクト: H1LLStreaM/QTCT_3
        private void reportPrint(List <titletable> title, List <TB_EXPENSE> detail, List <foots> fs)
        {
            try
            {
                ReportTools     myReportTool;
                TfrxReportClass report;
                myReportTool = new ReportTools();
                report       = new TfrxReportClass();
                report.ClearDatasets();
                FrxDataTable titleable = new FrxDataTable("dtWorkTitle");      //概要
                myReportTool.ListToFrxTable(title, titleable);
                FrxDataTable detailtable = new FrxDataTable("dtWorkDetail");   //明细
                myReportTool.ListToFrxTable(detail, detailtable);
                FrxDataTable detailtable2 = new FrxDataTable("dtWorkDetail2"); //明细2
                myReportTool.ListToFrxTable(fs, detailtable2);
                report.LoadReportFromFile("ExpenseReport.fr3");

                detailtable.AssignToReport(true, report);
                titleable.AssignToReport(true, report);
                report.ShowReport();
            }
            catch (System.Exception ex)
            {
                MessageHelper.ShowMessage(ex.Message);
            }
        }
コード例 #4
0
        private void button7_Click(object sender, EventArgs e)
        {
            TfrxReportClass report;

            report = new TfrxReportClass();
            report.ReportOptions.ConnectionName = @"Database=database1;Data Source=127.0.0.1;User Id=root;Password="******"C:/Users/Asus/Desktop/2.fr3");
            // report.DesignReport(); редактирование отчета
            report.ShowReport();
            report.PrintOptions.PageNumbers = "";
            report.ExportToTXT("export2.txt", true, true, true, true);
        }
コード例 #5
0
ファイル: ProfilePrint.cs プロジェクト: H1LLStreaM/QTCT_3
 private void reportPrint(List <projProfileClass> summery, List <TB_EXPENSE> detail)
 {
     try
     {
         ReportTools     myReportTool;
         TfrxReportClass report;
         myReportTool = new ReportTools();
         report       = new TfrxReportClass();
         report.ClearDatasets();
         FrxDataTable summeryTable = new FrxDataTable("dtWorkTitle");  //概要
         myReportTool.ListToFrxTable(summery, summeryTable);
         FrxDataTable detailtable = new FrxDataTable("dtWorkDetail");  //明细
         myReportTool.ListToFrxTable(detail, detailtable);
         report.LoadReportFromFile("profileReport.fr3");
         summeryTable.AssignToReport(true, report);
         detailtable.AssignToReport(true, report);
         report.ShowReport();
     }
     catch (System.Exception ex)
     {
         MessageHelper.ShowMessage(ex.Message);
     }
 }
コード例 #6
0
ファイル: frmprintmodule.cs プロジェクト: rcw0125/XGWMS
        private void btn_lbdesign_Click(object sender, EventArgs e)
        {
            if (dgvm.SelectedRows.Count == 0)
            {
                return;
            }
            if (dgv.SelectedRows.Count == 0)
            {
                return;
            }
            string modename = dgvm.SelectedRows[0].Cells[0].Value.ToString();
            string lbname   = dgv.SelectedRows[0].Cells[0].Value.ToString();

            if (modename == "标准模板")
            {
                MessageBox.Show("标准模板不允许设计!", "系统提示");
                return;
            }
            string          filefullpath = Application.StartupPath + "\\report\\" + modename + "\\" + lbname;
            TfrxReportClass Report       = Report = new TfrxReportClass();

            if (!File.Exists(filefullpath))
            {
                MessageBox.Show("标签文件不存在!", "系统提示");
                return;
            }
            try
            {
                Report.LoadReportFromFile(filefullpath);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("加载打印模板错误,请联系系统管理员!" + ex.Message, "系统错误");
                return;
            }
            Report.DesignReport();
        }
コード例 #7
0
ファイル: updatebarcodeFrm.cs プロジェクト: rcw0125/XGWMS
        private void printpq(string ph, string gg, string pch, string jz, string rq, string bb, string gh, string bz, string xlh, string tm, string sx, string pcxx, bool ckflg, string itype, string wlh, string heatid, string liaohao)
        {
            string  scriptstr = "";
            DataSet ds        = null;
            string  sqlstr    = "";
            Boolean nocheck   = false;
            string  printmodual;
            string  stpath;
            string  bzstr;
            string  tct;
            string  SX = cmbsx.Text;

            //if (SX == "") return;
            printmodual = Public.GetXmlValue("PrintModuleName");
            if (printmodual == "")
            {
                printmodual = "标准模板";
            }
            stpath = Application.StartupPath + "\\report\\" + printmodual + "\\";
            if (!Directory.Exists(stpath))
            {
                MessageBox.Show("标签模板不存在!", "系统提示");
                return;
            }
            if ((SX == "B2") || (SX == "C2"))
            {
                nocheck = false;
            }
            else
            {
                nocheck = true;
            }
            scriptstr = "begin" + "\r\n";
            if (SX == "CK")
            {
                Report.LoadReportFromFile(stpath + "ckcz.fr3");
                scriptstr += "memspec.Text:='" + pcxx + "';";
                if (PrintPCInfoCheckBox.Checked)
                {
                    scriptstr += "memspec.visible:=true;";
                }
                else
                {
                    scriptstr += "memspec.visible:=false;";
                }
            }
            else
            {
                switch (itype)
                {
                case "1":
                    Report.LoadReportFromFile(stpath + "ptcz1.fr3");
                    break;

                case "2":
                    Report.LoadReportFromFile(stpath + "ptcz2.fr3");
                    scriptstr += "memosx.text:='" + sx.Substring(0, 3) + "';";
                    if (!nocheck)
                    {
                        scriptstr += "memosx.visible:=false;";
                        scriptstr += "Shape1.visible:=false;";
                    }
                    else
                    {
                        scriptstr += "memosx.visible:=true;";
                        scriptstr += "Shape1.visible:=true;";
                    }
                    break;

                case "3":
                    Report.LoadReportFromFile(stpath + "ptcz3.fr3");
                    scriptstr += "memopcinfo.text:='" + pcxx + "';";
                    if (!nocheck)
                    {
                        scriptstr += "memopcinfo.visible:=false;";
                    }
                    else
                    {
                        scriptstr += "memopcinfo.visible:=true;";
                    }
                    break;

                case "4":
                    Report.LoadReportFromFile(stpath + "ptcz4.fr3");
                    scriptstr += "memopcinfo.text:='" + pcxx + "';";
                    if (!nocheck)
                    {
                        scriptstr += "memopcinfo.visible:=false;";
                        scriptstr += "Shape1.visible:=false;";
                    }
                    else
                    {
                        scriptstr += "memopcinfo.visible:=true;";
                        scriptstr += "Shape1.visible:=true;";
                    }
                    break;
                }
            }
            scriptstr += "Barcode1.text:='" + tm + "';";
            scriptstr += "memoph.text:='" + ph + "';";
            scriptstr += "memogg.text:='" + gg + "';";
            scriptstr += "memopch.text:='" + pch + "';";
            //scriptstr += "memojhzt.text:='" + getjhzt(wlh) + "';";
            double fjz = Math.Round(float.Parse(jz) * 1000, 1);

            scriptstr += "memojz.text:='" + fjz.ToString() + " kg';";
            scriptstr += "memorq.text:='" + rq + "';";
            scriptstr += "memogh.text:='" + gh + "';";
            //string bbtemp = "";
            //if (bb == "甲班") bbtemp = "A";
            //if (bb == "乙班") bbtemp = "B";
            //if (bb == "丙班") bbtemp = "C";
            //if (bb == "丁班") bbtemp = "D";
            //scriptstr += "memobb.text:='" + bbtemp + "';";

            if (liaohao != "")
            {
                string sql = " SELECT invinfo.WGDH FROM WMS_Bms_Inv_Info AS invinfo LEFT OUTER JOIN WMS_Bms_Rec_WGD AS wgd ON invinfo.PCH = wgd.PCH WHERE (invinfo.WLH = wgd.YWLH) AND (invinfo.vfree1 = wgd.vfree1) AND ";

                sql += "  (wgd.yvfree1 = wgd.vfree1) AND (invinfo.vfree2 = wgd.vfree2) AND  (wgd.yvfree2 = wgd.vfree2) AND (invinfo.vfree3 = wgd.vfree3) AND (wgd.yvfree3 = wgd.vfree3) AND (invinfo.SX IN ('AAA', 'AA', 'A', 'CK')) AND ";
                sql += " invinfo.barcode='" + lbbarcode.Text.Trim() + "'";
                DataSet dstable = DbEntry.Context.ExecuteDataset(sql);
                if ((dstable == null) || (dstable.Tables.Count == 0) || dstable.Tables[0].Rows.Count == 0)
                {
                    liaohao = "";
                }
            }

            if (liaohao != "")
            {
                scriptstr += "Memliao.text:='" + liaohao + "';";
                scriptstr += "Memliao.visible:=true;";
                scriptstr += "memliao1.visible:=true;";
                scriptstr += "Lineliao.visible:=true;";
            }

            //修改添加 炉次 删除班别
            scriptstr += "memobb.text:='" + heatid + "';";


            if (SX != "CK")
            {
                string bzstrf = "";
                bzstrf     = bz.Substring(bz.IndexOf('~') + 1);
                scriptstr += "memobz.text:='" + bzstrf + "';";
            }
            else
            {
                scriptstr += "memoxlh.text:='" + xlh + "';";
            }
            scriptstr        += "memowlh.text:='" + wlh.Substring(0, 3) + "';";
            scriptstr        += "end.";
            Report.ScriptText = scriptstr;

            Report.PrepareReport(true);



            int con = 2;

            Report.PrintOptions.ShowDialog = false;
            Report.PrintOptions.Copies     = con;

            try
            {
                Report.PrintReport();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("打印错误:" + ex.Message + ".请补打!");
            }
        }
コード例 #8
0
        private void printpq(string barcode, string strJz)
        {
            string scriptstr = "";
            string ph, gg, pch, jz, rq, bb, gh, bz, xlh, tm, ckcxh, sx, pcxx, bzstr, bbtemp, printmodual, stpath, tct, wlh;
            bool   ckflg, nocheck;
            int    iType;

            if (chkTSXX.Checked)
            {
                if (chkCPDJ.Checked)
                {
                    iType = 4;
                }
                else
                {
                    iType = 3;
                }
            }
            else
            {
                if (chkCPDJ.Checked)
                {
                    iType = 2;
                }
                else
                {
                    iType = 1;
                }
            }
            printmodual = Public.GetXmlValue("PrintModuleName");
            if (printmodual == "")
            {
                printmodual = "标准模板";
            }
            stpath = Application.StartupPath + "\\report\\" + printmodual + "\\";
            if (!Directory.Exists(stpath))
            {
                MessageBox.Show("标签模板不存在!", "系统提示");
                return;
            }



            string  strSql = "select * from " + tablename + " where barcode='" + barcode.Trim() + "'";
            DataSet ds     = DbEntry.Context.ExecuteDataset(strSql);

            ph   = ds.Tables[0].Rows[0]["PH"].ToString();
            gg   = ds.Tables[0].Rows[0]["GG"].ToString();
            pch  = ds.Tables[0].Rows[0]["PCH"].ToString();
            jz   = strJz;
            rq   = ds.Tables[0].Rows[0]["ProduceData"].ToString();
            bb   = ds.Tables[0].Rows[0]["bb"].ToString();
            pcxx = ds.Tables[0].Rows[0]["pcinfo"].ToString();
            gh   = Convert.ToInt32(ds.Tables[0].Rows[0]["gh"]).ToString().PadLeft(2, '0');
            sx   = ds.Tables[0].Rows[0]["SX"].ToString();
            if (sx.ToUpper() == "CK")
            {
                bz = ds.Tables[0].Rows[0]["GH"].ToString().PadLeft(2, '0');
            }
            else
            {
                bz = ds.Tables[0].Rows[0]["bz"].ToString();
            }
            xlh   = this.txtLSH.Text;
            tm    = barcode;
            wlh   = ds.Tables[0].Rows[0]["wlh"].ToString();
            ckcxh = ds.Tables[0].Rows[0]["ckcxh"].ToString();

            if ((sx == "B2") || (sx == "C2"))
            {
                nocheck = false;
            }
            else
            {
                nocheck = true;
            }

            TfrxReportClass Report = new TfrxReportClass();

            scriptstr = "begin" + "\r\n";
            if (sx == "CK")
            {
                Report.LoadReportFromFile(stpath + "ckcz.fr3");
                scriptstr += "memspec.Text:='" + pcxx + "';";
                if (this.chkTSXX.Checked)
                {
                    scriptstr += "memspec.visible:=true;";
                }
                else
                {
                    scriptstr += "memspec.visible:=false;";
                }
            }
            else
            {
                switch (iType)
                {
                case 1:
                    Report.LoadReportFromFile(stpath + "ptcz1.fr3");
                    break;

                case 2:
                    Report.LoadReportFromFile(stpath + "ptcz2.fr3");
                    scriptstr += "memosx.text:='" + sx + "';";
                    if (!nocheck)
                    {
                        scriptstr += "memosx.visible:=false;";
                        scriptstr += "Shape1.visible:=false;";
                    }
                    else
                    {
                        scriptstr += "memosx.visible:=true;";
                        scriptstr += "Shape1.visible:=true;";
                    }
                    break;

                case 3:
                    Report.LoadReportFromFile(stpath + "ptcz3.fr3");
                    scriptstr += "memopcinfo.text:='" + pcxx + "';";
                    if (!nocheck)
                    {
                        scriptstr += "memopcinfo.visible:=false;";
                    }
                    else
                    {
                        scriptstr += "memopcinfo.visible:=true;";
                    }
                    break;

                case 4:
                    Report.LoadReportFromFile(stpath + "ptcz4.fr3");
                    scriptstr += "memopcinfo.text:='" + pcxx + "';";
                    if (!nocheck)
                    {
                        scriptstr += "memopcinfo.visible:=false;";
                        scriptstr += "Shape1.visible:=false;";
                    }
                    else
                    {
                        scriptstr += "memopcinfo.visible:=true;";
                        scriptstr += "Shape1.visible:=true;";
                    }
                    break;
                }
            }

            scriptstr += "Barcode1.text:='" + tm + "';";
            scriptstr += "memoph.text:='" + ph + "';";
            scriptstr += "memogg.text:='" + gg + "';";
            scriptstr += "memopch.text:='" + pch + "';";
            double fjz = Convert.ToDouble(jz);;

            scriptstr += "memojz.text:='" + fjz.ToString() + " kg';";
            scriptstr += "memorq.text:='" + rq + "';";
            scriptstr += "memogh.text:='" + gh + "';";
            //bbtemp = "";
            //if (bb == "甲班") bbtemp = "A";
            //if (bb == "乙班") bbtemp = "B";
            //if (bb == "丙班") bbtemp = "C";
            //if (bb == "丁班") bbtemp = "D";
            //scriptstr += "memobb.text:='" + bbtemp + "';";

            //如果炉号为空,则再次查询nc
            if (txtheatid.Text.Trim() == "")
            {
                string loadSql = "";
                loadSql += "select mm_wr_b.pch,getbilletbatchcode(mm_wr_b.pch) billet_heat_number,";
                loadSql += " mm_po.xsddh customer_material_number";
                loadSql += " from mm_wr_b mm_wr_b, mm_mo mm_mo, mm_mosource mm_mosource, mm_po mm_po";
                loadSql += "  where mm_wr_b.scddid = mm_mo.pk_moid and mm_mo.pk_moid = mm_mosource.scddid";
                loadSql += "  and mm_mosource.lyid = mm_po.pk_poid  and mm_po.pk_corp = '1001'";
                loadSql += " and mm_po.dr = 0  and mm_mosource.pk_corp = '1001' and mm_mosource.dr = 0 ";
                loadSql += "  and mm_mo.pk_corp = '1001' and mm_mo.dr = 0 and mm_wr_b.pk_corp = '1001'";
                loadSql += "  and mm_wr_b.dr = 0  and mm_wr_b.pch = '" + pch + "'";
                //OracleConnection conn = new OracleConnection("Data Source=192.168.2.221/orcl;User ID=nctest;Password=nctest;");

                //OracleConnection conn = new OracleConnection("Data Source=nctest;User ID=nctest;Password=nctest;");
                OracleConnection conn = new OracleConnection("Data Source=ncv5;User ID=xgerp50;Password=xgerp204212350;");
                conn.Open();
                OracleCommand selectCmd = conn.CreateCommand();
                selectCmd.CommandText = loadSql;
                // selectCmd.BindByName = true;

                OracleDataAdapter oradap = new OracleDataAdapter(selectCmd);
                DataSet           ds1    = new DataSet();
                oradap.Fill(ds1);
                conn.Close();
                if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
                {
                }
                else
                {
                    txtheatid.Text   = ds1.Tables[0].Rows[0]["billet_heat_number"].ToString();
                    txtGgHeatid.Text = ds1.Tables[0].Rows[0]["billet_heat_number"].ToString();
                    txtliaohao.Text  = ds1.Tables[0].Rows[0]["customer_material_number"].ToString();
                }
            }


            //库内补打 料号判断  异常情况料号置空
            if ((txtliaohao.Text.ToString().Trim() != "") && (tablename == "WMS_Bms_Inv_Info"))
            {
                string sql = " SELECT invinfo.WGDH FROM WMS_Bms_Inv_Info AS invinfo LEFT OUTER JOIN WMS_Bms_Rec_WGD AS wgd ON invinfo.PCH = wgd.PCH WHERE (invinfo.WLH = wgd.YWLH) AND (invinfo.vfree1 = wgd.vfree1) AND ";

                sql += "  (wgd.yvfree1 = wgd.vfree1) AND (invinfo.vfree2 = wgd.vfree2) AND  (wgd.yvfree2 = wgd.vfree2) AND (invinfo.vfree3 = wgd.vfree3) AND (wgd.yvfree3 = wgd.vfree3) AND (invinfo.SX IN ('AAA', 'AA', 'A', 'CK')) AND ";
                sql += " invinfo.barcode='" + barcode.Trim() + "'";
                DataSet dstable = DbEntry.Context.ExecuteDataset(sql);
                if ((dstable == null) || (dstable.Tables.Count == 0) || dstable.Tables[0].Rows.Count == 0)
                {
                    txtliaohao.Text = "";
                }
            }

            if (txtliaohao.Text.ToString().Trim() != "")
            {
                scriptstr += "Memliao.text:='" + txtliaohao.Text.ToString().Trim() + "';";
                scriptstr += "Memliao.visible:=true;";
                scriptstr += "memliao1.visible:=true;";
                scriptstr += "Lineliao.visible:=true;";
            }

            //修改添加 炉次 删除班别
            scriptstr += "memobb.text:='" + txtheatid.Text.ToString().Trim() + "';";


            if (sx != "CK")
            {
                string bzstrf = "";
                bzstrf     = bz.Substring(bz.IndexOf('~') + 1);
                scriptstr += "memobz.text:='" + bzstrf + "';";
            }
            else
            {
                scriptstr += "memoxlh.text:='" + xlh + "';";
            }
            scriptstr        += "memowlh.text:='" + wlh.Substring(0, 3) + "';";
            scriptstr        += "end.";
            Report.ScriptText = scriptstr;
            Report.PrepareReport(true);
            int con = 2;

            if (this.numTxt.Value > 0)
            {
                con = int.Parse(numTxt.Value.ToString());
            }
            Report.PrintOptions.ShowDialog = false;
            Report.PrintOptions.Copies     = con;
            try
            {
                if (this.chkBowse.Checked)
                {
                    Report.ShowReport();
                }
                else
                {
                    Report.PrintReport();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("打印错误:" + ex.Message + ".请补打!");
            }
        }