public override void Print(ReportParameter[] parameters) { grdrpt.LoadFromFile(FullReportTemplateFileName); grdrpt.Printer.PrinterName = PrinterName; SetParameters(parameters); if (Preview) { grdrpt.PrintPreview(true); } else { grdrpt.Print(false); } }
/// <summary> /// 报表打印 /// </summary> private void ReportPrint(bool view) { if (dgvReport.Rows.Count == 0) { return; } if (dgvReport.DataSource == null) { return; } reportPrinter = new grproLib.GridppReport( ); string reportFile = System.Windows.Forms.Application.StartupPath + "\\report\\" + FormTitle + ".grf"; if (!System.IO.File.Exists(reportFile)) { MessageBox.Show("报表模板文件不存在,不能打印或预览!请下载或联系管理员增加该报表", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } reportPrinter.LoadFromFile(reportFile); string printerName = HIS_PublicManager.PublicPrintSet.GetPrinterNameByReport(FormTitle + ".grf"); reportPrinter.Printer.PrinterName = printerName; try { reportPrinter.Title = FormTitle; try { reportPrinter.ParameterByName("医院名称").AsString = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.WorkName; reportPrinter.ParameterByName("报表标题").AsString = FormTitle; reportPrinter.ParameterByName("统计时间").AsString = "统计日期:" + this.lblDate.Text; reportPrinter.ParameterByName("制表人").AsString = "制表人:" + currentUser.Name; reportPrinter.ParameterByName("备注").AsString = ""; } catch (Exception err) { throw new Exception("报表模板参数没有正确设置,请用设计器打开报表并设置好参数"); } reportPrinter.FetchRecord += new grproLib._IGridppReportEvents_FetchRecordEventHandler(report_FetchRecord); if (view) { reportPrinter.PrintPreview(false); } else { reportPrinter.Print(true); } } catch (Exception err) { MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
//打印住院发票 public static void Print(int CostMasterID) { grproLib.GridppReport Report = new grproLib.GridppReport(); string ReportPath; string PrinterName; Object invoice; //广东发票打印 //ReportPath = Constant.ApplicationDirectory + "\\report\\住院发票.grf"; //PrinterName = HIS_PublicManager.PublicPrintSet.GetPrinterNameByReport("住院发票.grf"); //invoice =InvoiceFactory.CreateInvoice(CostMasterID,"广东"); //湖南发票打印 ReportPath = Constant.ApplicationDirectory + "\\report\\住院发票_HN.grf"; PrinterName = HIS_PublicManager.PublicPrintSet.GetPrinterNameByReport("住院发票_HN.grf"); invoice = InvoiceFactory.CreateInvoice(CostMasterID, "湖南"); Report.LoadFromFile(ReportPath); Report.Printer.PrinterName = PrinterName; GWI_DesReport.HisReport.FillRecordToReport(Report, invoice); Report.ParameterByName("WorkName").AsString = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.WorkName; #region 发票项目 DataTable dt = ((AbstractInvoice)invoice).发票项目费用; for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 1; j <= Report.Parameters.Count; j++) { if (dt.Rows[i]["itemname"].ToString().Trim() == Report.Parameters[j].Name) { Report.Parameters[j].Value = dt.Rows[i]["Tolal_Fee"].ToString(); } } } #endregion if (Report.Printer.PrinterName == null || Report.Printer.PrinterName == "") { MessageBox.Show("请先设置好此报表的打印机!", "询问", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); return; } #if DEBUG Report.PrintPreview(false); #else //Report.PrintPreview(false); Report.Print(false); #endif }
//打印 private void toolSBPrint_Click(object sender, EventArgs e) { if (((DataTable)this.dgBill.DataSource).Rows.Count == 0) { return; } if (Convert.ToInt32(((DataTable)this.dgBill.DataSource).DefaultView.ToTable().Rows[this.dgBill.CurrentCell.RowIndex]["Record_Flag"]) != 0 || Convert.ToInt32(((DataTable)this.dgBill.DataSource).DefaultView.ToTable().Rows[this.dgBill.CurrentCell.RowIndex]["Delete_Flag"]) != 0) { MessageBox.Show("此条是做废记录或已经结算,不能打印!"); return; } if (MessageBox.Show("确定要打印吗?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { zy_ChargeList = (ZY_ChargeList)HIS.SYSTEM.PubicBaseClasses.ApiFunction.DataTableToObject(((DataTable)this.dgBill.DataSource).Copy(), this.dgBill.CurrentCell.RowIndex, zy_ChargeList); grproLib.GridppReport Report = new grproLib.GridppReport(); string reportPath = Constant.ApplicationDirectory + "\\report\\住院收费收据.grf"; Report.LoadFromFile(reportPath); GWI_DesReport.HisReport.FillRecordToReport(Report, zy_ChargeList); Report.ParameterByName("PatName").AsString = zy_PatList.patientInfo.PatName; Report.ParameterByName("DeptName").AsString = this.tbpatDept.Text; Report.ParameterByName("BedNO").AsString = zy_PatList.BedCode; Report.ParameterByName("Total_Fee1").AsString = zy_ChargeList.Total_Fee.ToString(); Report.ParameterByName("PrintPerson").AsString = base.currentUser.Name; Report.ParameterByName("WorkName").AsString = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.WorkName; Report.Printer.PrinterName = HIS_PublicManager.PublicPrintSet.GetPrinterNameByReport("住院收费收据.grf"); if (Report.Printer.PrinterName == null || Report.Printer.PrinterName == "") { MessageBox.Show("请先设置好此报表的打印机!", "询问", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); return; } if (this.printType.Checked) { Report.Print(false); } else { Report.PrintPreview(false); } } }
private void BtnNumber_Click(object sender, EventArgs e) { Button btn = (Button)sender; PassToStockEdit ors; switch (btn.Name) { case "Delete": try { SqlConnection conn = sqlcon.getcon(""); string strsql = "delete from BR_PassToStock where ID='" + WPHbROWDGV.Rows[WPHbROWDGV.CurrentCell.RowIndex].Cells["ID"].Value.ToString() + "'"; conn.Open(); SqlCommand sqlcom = new SqlCommand(strsql, conn); sqlcom.ExecuteNonQuery(); conn.Close(); sqlcom.Dispose(); MessageBox.Show("已删除!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "Edit": if (WPHbROWDGV.Rows.Count > 0) { ors = new PassToStockEdit(WPHbROWDGV.Rows[WPHbROWDGV.CurrentCell.RowIndex].Cells["ID"].Value.ToString(), "BR_PassToStock"); ors.ShowDialog(); } break; case "Excel": if (WPHbROWDGV.Rows.Count > 0) { //建立Excel对象 Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); excel.Application.Workbooks.Add(true); //生成字段名称 for (int i = 0; i < WPHbROWDGV.ColumnCount; i++) { excel.Cells[1, i + 1] = WPHbROWDGV.Columns[i].HeaderText; } //填充数据 for (int i = 0; i < WPHbROWDGV.RowCount; i++) { for (int j = 0; j < WPHbROWDGV.ColumnCount; j++) { if (WPHbROWDGV[j, i].Value == typeof(string)) { excel.Cells[i + 2, j + 1] = "" + WPHbROWDGV[i, j].Value.ToString(); } else { excel.Cells[i + 2, j + 1] = WPHbROWDGV[j, i].Value.ToString(); } } } excel.Visible = true; } else { MessageBox.Show("没有你要导的数据!!!"); } break; case "Pring": //数据参数新增 if (WPHbROWDGV.Rows.Count > 0) { grproLib.GridppReport Report = new grproLib.GridppReport(); DataTable dt = new DataTable(); SqlConnection conn = sqlcon.getcon(""); string strsql = " select BR_PassToStock.Cade,Cadedate,m_Factory.title files,Ordercade,BarCode,item_no as Item,S_COLOR as Color,CO_CODE as Code,m_product.photo," + "m_SizeDetails.cade as Sizecade,m_SizeDetails.[name] as Sizename,khdw,m_SizeDetails.Name as Size,Qty as Nomber,m_ProductSub.pid,username " + "from BR_PassToStock " + "left join m_Factory on m_Factory.id=BR_PassToStock.FID " + "left join m_product on m_product.id=BR_PassToStock.pid " + "left join m_ProductSub on m_ProductSub.id=BR_PassToStock.colourid " + "left join m_SizeDetails on m_SizeDetails.id=BR_PassToStock.sdid where BarCode='" + WPHbROWDGV[4, WPHbROWDGV.CurrentCell.RowIndex].Value.ToString() + "' and BR_PassToStock.Cade='" + WPHbROWDGV[0, WPHbROWDGV.CurrentCell.RowIndex].Value.ToString() + "'"; SqlDataAdapter sqlDaper = new SqlDataAdapter(strsql, conn); DataSet ds = new DataSet(); try { conn.Open(); sqlDaper.Fill(ds); conn.Close(); try { //下载打印图片 string strimageurl = "http://120.43.209.230:8082/" + ds.Tables[0].Rows[0]["photo"].ToString(); System.Net.WebClient webclient = new System.Net.WebClient(); webclient.DownloadFile(strimageurl, @"D:\迈途\ZXCPTP.jpg"); } catch (Exception ex) { if (File.Exists(@"D:\迈途\ZXCPTP.jpg")) //判断文件是不是存在 { File.Delete(@"D:\迈途\ZXCPTP.jpg"); //如果存在则删除 } Console.WriteLine(ex.Message); } Report.LoadFromFile(@rwos().ToString()); Report.ConnectionString = sqlcon.XMLIP(); Report.QuerySQL = " select BR_PassToStock.Cade,Cadedate,m_Factory.title files,Ordercade,BarCode,item_no as Item,S_COLOR as Color,CO_CODE as Code,m_product.photo," + "m_SizeDetails.cade as Sizecade,m_SizeDetails.[name] as Sizename,khdw,m_SizeDetails.Name as Size,Qty as Nomber,m_ProductSub.pid,username " + "from BR_PassToStock " + "left join m_Factory on m_Factory.id=BR_PassToStock.FID " + "left join m_product on m_product.id=BR_PassToStock.pid " + "left join m_ProductSub on m_ProductSub.id=BR_PassToStock.colourid " + "left join m_SizeDetails on m_SizeDetails.id=BR_PassToStock.sdid where BarCode='" + WPHbROWDGV[4, WPHbROWDGV.CurrentCell.RowIndex].Value.ToString() + "' and BR_PassToStock.Cade='" + WPHbROWDGV[0, WPHbROWDGV.CurrentCell.RowIndex].Value.ToString() + "'"; //Report.Print(false); DialogResult result = MessageBox.Show("“是”直接打印,“否”打印预览", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { Report.Print(false); } else { Report.PrintPreview(true); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { MessageBox.Show("没有你要打印的数据!!"); } break; } }
private void btnPackintBarCode_Click(object sender, EventArgs e) { try { grproLib.GridppReport Report = new grproLib.GridppReport(); DataSet ds = new DataSet(); SqlConnection conn = sqlcon.getcon(""); try { string sqlstr = ""; for (int i = 0; i < WPHbROWDGV.Rows.Count; i++) { if (WPHbROWDGV.Rows[i].Cells["Cade"].Value.ToString() != "合计") { sqlstr += " insert into Wph_PackingPrint(Cade,BarCode,Item,Size,Colour,Nomber,[ADd],Special) values ('" + WPHbROWDGV.Rows[i].Cells["Cade"].Value.ToString() + "','" + WPHbROWDGV.Rows[i].Cells["BarCode"].Value.ToString() + "','" + WPHbROWDGV.Rows[i].Cells["Item_no"].Value.ToString() + "','" + WPHbROWDGV.Rows[i].Cells["SDname"].Value.ToString() + "','" + WPHbROWDGV.Rows[i].Cells["s_color"].Value.ToString() + "','" + WPHbROWDGV.Rows[i].Cells["NO"].Value.ToString() + "','" + WPHbROWDGV.Rows[i].Cells["stname"].Value.ToString() + "','" + WPHbROWDGV.Rows[i].Cells["Special"].Value.ToString() + "');"; } } conn.Open(); SqlCommand cmd = new SqlCommand(sqlstr, conn); cmd.ExecuteNonQuery(); sqlstr = ""; SqlDataAdapter sqlDaper = new SqlDataAdapter("select cade,[add],Special,count(1) as counts from Wph_PackingPrint group by cade,[add],Special", conn); sqlDaper.Fill(ds); try { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { // % Convert.ToInt32(txtRows.Text.ToString()) for (int row = Convert.ToInt32(ds.Tables[0].Rows[i]["counts"].ToString()); row < 16; row++) { sqlstr += " insert into Wph_PackingPrint(Cade,[ADd],Special) values ('" + ds.Tables[0].Rows[i]["cade"].ToString() + "','" + ds.Tables[0].Rows[i]["ADd"].ToString() + "','" + ds.Tables[0].Rows[i]["Special"].ToString() + "');"; } } cmd = new SqlCommand(sqlstr, conn); cmd.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } //唯品汇条码打印 DataTable dt = new DataTable(); string Rouet = Application.StartupPath + "\\PrintRoute.xml"; string printR = ""; dt = xmldate.CXmlToDataTable(Rouet); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["FormID"].ToString() == "唯品汇条码打印") { printR = dt.Rows[i]["Route"].ToString(); } } Report.LoadFromFile(@printR); Report.ConnectionString = sqlcon.XMLIP(); Report.QuerySQL = "select * from Wph_PackingPrint"; conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (MessageBox.Show("\n“是”直接打印,“否”打印预览!!", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Report.Print(true); } else { Report.PrintPreview(true); } //if() //Report.PrintPreview(true); //Report.Print(true); conn.Open(); SqlCommand cmdd = new SqlCommand("delete from Wph_PackingPrint", conn); cmdd.ExecuteNonQuery(); conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
//打印主功能 private void PrintMain(bool IsPreview, string presdeptcode) { Report = new grproLib.GridppReport(); IcostManager icM = ObjectFactory.GetObject <IcostManager>(typeof(ZY_CostMaster)); icM.PatListID = zy_pat.PatListID; PatFee patFee = icM.GetPatFee(this.dtpE.Value.Date); if (this.radioButton1.Checked) { Report.LoadFromFile(Constant.ApplicationDirectory + "\\report\\住院费用清单_汇总.grf"); } else if (this.radioButton2.Checked) { Report.LoadFromFile(Constant.ApplicationDirectory + "\\report\\住院费用清单_核算.grf"); } else if (this.radioButton3.Checked) { Report.LoadFromFile(Constant.ApplicationDirectory + "\\report\\住院费用清单.grf"); } else if (this.radioButton4.Checked) { Report.LoadFromFile(Constant.ApplicationDirectory + "\\report\\住院费用清单_汇总分组.grf"); } else if (this.radioButton5.Checked) { Report.LoadFromFile(Constant.ApplicationDirectory + "\\report\\住院费用一日清单.grf"); } if (checkBox1.Checked == true) { Report.ParameterByName("费用时间").AsString = this.dtpB.Value.ToString("yyyy-MM-dd HH:mm:ss") + "至" + this.dtpE.Value.ToString("yyyy-MM-dd HH:mm:ss"); } else { string date1, date2; if (zy_pat.OutDate.Date.ToString("yyyy-MM-dd") == "0001-01-01") { date2 = "至今"; } else { date2 = zy_pat.OutDate.Date.ToString("yyyy-MM-dd") + " 23:59:59"; } date1 = zy_pat.CureDate.ToString("yyyy-MM-dd HH:mm:ss"); Report.ParameterByName("费用时间").AsString = date1 + "至" + date2; } if (this.radioButton5.Checked) { Report.ParameterByName("费用时间").AsString = this.dtpB.Value.ToString("yyyy-MM-dd HH:mm:ss"); } Report.ParameterByName("CureNo").AsString = zy_pat.CureNo; Report.ParameterByName("PatCaseNo").AsString = zy_pat.patientInfo.PatCaseNo; Report.ParameterByName("PatName").AsString = zy_pat.patientInfo.PatName; string DateStr = zy_pat.OutDate.Date.ToString("yyyy-MM-dd"); if (DateStr == "0001-01-01") { DateStr = zy_pat.CureDate.Date.ToString("yyyy-MM-dd"); } else { DateStr = zy_pat.CureDate.Date.ToString("yyyy-MM-dd") + "至" + DateStr; } Report.ParameterByName("MarkDate").AsString = DateStr; Report.ParameterByName("BedCode").AsString = zy_pat.BedCode; if (presdeptcode == null) { Report.ParameterByName("住院科室").AsString = BaseNameFactory.GetName(baseNameType.科室名称, zy_pat.CurrDeptCode); } else { Report.ParameterByName("住院科室").AsString = BaseNameFactory.GetName(baseNameType.科室名称, presdeptcode); } Report.ParameterByName("WorkName").AsString = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.WorkName; if (zy_pat.PatType == "4" || zy_pat.PatType == "5") { //Report.ParameterByName("累计交费").AsString = "0"; //try //{ // ZY_CostMaster zyCM = new ZY_CostMaster(); // Report.ParameterByName("农合医保记账").AsString = zyCM.GetSumVillage_Fee(zy_pat.PatListID).ToString("0.00"); //} //catch { } //Report.ParameterByName("余额").AsString = "0"; icM = icM.GetCostMaster(zy_pat.PatListID); Report.ParameterByName("累计交费").AsString = icM.Deptosit_Fee.ToString(); Report.ParameterByName("累计记账").AsString = icM.Total_Fee.ToString(); Report.ParameterByName("余额").AsString = Convert.ToString(icM.Deptosit_Fee - icM.Total_Fee); } else { Report.ParameterByName("累计交费").AsString = patFee.chargeFee.ToString(); Report.ParameterByName("累计记账").AsString = patFee.costFee.ToString(); Report.ParameterByName("余额").AsString = patFee.surplusFee.ToString(); } //ShowItemData(); 移动在Print()中 try { Report.ParameterByName("甲类总金额").AsString = firstFee.ToString(); Report.ParameterByName("乙类总金额").AsString = secondFee.ToString(); Report.ParameterByName("本次优惠").AsString = AllDec.ToString(); Report.ParameterByName("担保金额").AsString = zy_pat.DbFee.ToString("0.00"); //Report.ParameterByName("自付金额").AsString = Convert.ToString(patFee.costFee - firstFee - secondFee); } catch { } if (this.radioButton5.Checked) { for (int i = 0; i < ItemDt.Rows.Count; i++) { for (int j = 1; j <= Report.Parameters.Count; j++) { if (ItemDt.Rows[i]["itemname"].ToString().Trim() == Report.Parameters[j].Name) { Report.Parameters[j].Value = ItemDt.Rows[i]["Tolal_Fee"].ToString(); } } } } else { Report.FetchRecord += new grproLib._IGridppReportEvents_FetchRecordEventHandler(Report_FetchRecord); } if (IsPreview) { Report.PrintPreview(false); } else { Report.Print(false); } }