215 lines
7.4 KiB
C#
215 lines
7.4 KiB
C#
using EAS.Services;
|
|
using FastReport;
|
|
using SOH.BLL;
|
|
using SOH.Entities.DTO;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace SOH.ShouFei
|
|
{
|
|
public partial class frmprinttm : SOH.Window.baseChildForm
|
|
{
|
|
public bool showview = false;
|
|
public frmprinttm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 准备打印条码数据
|
|
/// </summary>
|
|
/// <param name="tm">用户条码</param>
|
|
/// <param name="v">0打印新的1补打</param>
|
|
/// <param name="jytm">补打时好用0补打全部其他补打指定</param>
|
|
public void init(int tm, int v, int jytm)
|
|
{
|
|
init(tm, v, jytm, null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 准备打印条码数据
|
|
/// </summary>
|
|
/// <param name="tm">用户条码</param>
|
|
/// <param name="v">0打印新的1补打</param>
|
|
/// <param name="jytm">补打时好用0补打全部其他补打指定</param>
|
|
/// <param name="nodytms">不需要打印的列表</param>
|
|
public void init(int tm, int v, int jytm, List<dto_tmdy> nodytms)
|
|
{
|
|
var vser = ServiceContainer.GetService<IShouFei>();
|
|
var gzb = vser.getgzbbytm(tm.ToString());
|
|
lbl_xm.Text = gzb.xm;
|
|
lbl_xb.Text = gzb.v_xb;
|
|
if (gzb.lx == 2)
|
|
lbl_tjtc.Text = gzb.tcmc;
|
|
else
|
|
{
|
|
var vtcser = ServiceContainer.GetService<ITaoCan>();
|
|
var tc = vtcser.GetModelBytcbm(gzb.tcbm);
|
|
lbl_tjtc.Text = gzb.tcmc = tc.tcmc;
|
|
}
|
|
//select '生化' as xmmc ,'抽血工作台' as wlks,'A01_02' as fjh, '餐前检查项目' xmlx
|
|
/*
|
|
select '郑志强' as xm,'男' as xb, '0000123456' as hyh,'1010123456' as tm,
|
|
30 as nl, '18653582965' as lxdh,'希望之星免费体检' tcmc,'希望之星' as gzdw,
|
|
'开发部' as ygbm,'已婚' as hyzk,
|
|
'生化全套' as jyxm,'012345678912' as jytm
|
|
*/
|
|
SOH.Data.OperationResult or;
|
|
if (jytm == 99999)
|
|
{
|
|
or = vser.gettm2(tm, v, jytm);
|
|
}
|
|
else
|
|
{
|
|
or = vser.gettm(tm, v, jytm);
|
|
}
|
|
|
|
if (or.State != 1)
|
|
{
|
|
MessageBox.Show(or.Message);
|
|
return;
|
|
}
|
|
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("xm", typeof(string));
|
|
dt.Columns.Add("xb", typeof(string));
|
|
dt.Columns.Add("hyh", typeof(string));
|
|
dt.Columns.Add("tm", typeof(string));
|
|
dt.Columns.Add("nl", typeof(int));
|
|
dt.Columns.Add("lxdh", typeof(string));
|
|
dt.Columns.Add("tcmc", typeof(string));
|
|
dt.Columns.Add("gzdw", typeof(string));
|
|
dt.Columns.Add("ygbm", typeof(string));
|
|
dt.Columns.Add("hyzk", typeof(string));
|
|
dt.Columns.Add("jyxm", typeof(string));
|
|
dt.Columns.Add("jytm", typeof(string));
|
|
dt.Columns.Add("color", typeof(string));
|
|
List<Entities.DTO.dto_tmdy> tms = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Entities.DTO.dto_tmdy>>(or.Tag);
|
|
if (!(nodytms == null || nodytms.Count == 0))
|
|
{
|
|
nodytms.ForEach(t =>
|
|
{
|
|
//var dtm = tms.FirstOrDefault(p => p.jytm == t.jytm && p.jymx == t.jymx);
|
|
var dtm = tms.FirstOrDefault(p => p.jymx == t.jymx);
|
|
if (dtm != null)
|
|
tms.Remove(dtm);
|
|
});
|
|
}
|
|
tms.ForEach(t =>
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["xm"] = gzb.xm;
|
|
dr["xb"] = gzb.v_xb;
|
|
dr["hyh"] = gzb.hyh.ToString("0000000000");
|
|
dr["tm"] = gzb.tm.ToString("0000000000");
|
|
dr["nl"] = gzb.nl;
|
|
dr["lxdh"] = gzb.ygdh;
|
|
dr["tcmc"] = gzb.tcmc;
|
|
dr["gzdw"] = gzb.dwmc;
|
|
dr["ygbm"] = gzb.ygbm;
|
|
dr["hyzk"] = gzb.v_hyzk;
|
|
dr["jyxm"] = t.jymx;
|
|
dr["jytm"] = t.jytm;
|
|
dr["color"] = t.color;
|
|
if (t.jymx == "早餐")
|
|
{
|
|
dt.Rows.InsertAt(dr, 0);
|
|
}
|
|
else
|
|
{
|
|
dt.Rows.Add(dr);
|
|
}
|
|
|
|
});
|
|
|
|
/*
|
|
List<dto_dxjm> dxjms = vser.getdjxmbytm(gzb.tm);
|
|
//select '生化' as xmmc ,'抽血工作台' as wlks,'A01_02' as fjh, '餐前检查项目' xmlx
|
|
DataTable dtxm = new DataTable();
|
|
dtxm.Columns.Add("xmmc", typeof(string));
|
|
dtxm.Columns.Add("fjh", typeof(string));
|
|
dtxm.Columns.Add("xmlx", typeof(string));
|
|
dtxm.Columns.Add("wlks", typeof(string));
|
|
dxjms.GroupBy(t => new { t.cqxm, t.wlks, t.quyu }).ToList().ForEach(t =>
|
|
{
|
|
DataRow drmx = dtxm.NewRow();
|
|
drmx["fjh"] = t.Key.quyu;
|
|
drmx["wlks"] = t.Key.wlks;
|
|
drmx["xmlx"] = t.Key.cqxm;
|
|
dxjms.Where(k => k.quyu == t.Key.quyu && k.wlks == t.Key.wlks && k.cqxm == t.Key.cqxm).ToList().ForEach(p =>
|
|
{
|
|
drmx["xmmc"] = drmx["xmmc"].ToString() + " " + p.zhmc;
|
|
});
|
|
dtxm.Rows.Add(drmx);
|
|
});*/
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
string reportflie = "\\report\\report_tm.frx";
|
|
Report r = new Report();
|
|
r.Load(System.Windows.Forms.Application.StartupPath + reportflie);
|
|
r.RegisterData(dt, "tm_jbxx");
|
|
|
|
r.Preview = printpreview;
|
|
r.Refresh();
|
|
//r.Print();
|
|
r.Show();
|
|
}
|
|
else
|
|
{
|
|
noprint = true;
|
|
}
|
|
}
|
|
bool noprint = false;
|
|
/// <summary>
|
|
/// 打印如果showview=true,显示打印预览界面
|
|
/// </summary>
|
|
public void print()
|
|
{
|
|
if (noprint)
|
|
return;
|
|
if (printpreview.Report == null)
|
|
{
|
|
MessageBox.Show("请先初始化数据!");
|
|
return;
|
|
}
|
|
|
|
if (showview)
|
|
{
|
|
if (!this.Visible)
|
|
{
|
|
this.Show();
|
|
//printpreview.Report.Show();
|
|
}
|
|
return;
|
|
}
|
|
btn_print_Click(null, null);
|
|
}
|
|
|
|
private void btn_print_Click(object sender, EventArgs e)
|
|
{
|
|
string printname = "";
|
|
System.Configuration.Configuration cm = System.Configuration.ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.BaseDirectory + "\\local.ext");
|
|
printname = cm.AppSettings.Settings["tmdyjmc"].Value;
|
|
if (!string.IsNullOrEmpty(printname))
|
|
{
|
|
printpreview.Report.PrintSettings.Printer = printname;
|
|
}
|
|
printpreview.Report.PrintSettings.ShowDialog = false;
|
|
printpreview.Report.Print();
|
|
}
|
|
|
|
private void frmprinttm_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|