tijian_jichuang/Code/KeFu/frmDaYinBaoGao.cs
2025-02-20 11:54:48 +08:00

332 lines
11 KiB
C#

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;
using SOH.Kernel;
using EAS.Services;
using SOH.BLL;
using SOH.Entities;
using SOH.Data;
using SOH.Common;
using System.Text.RegularExpressions;
using FastReport.Export.Pdf;
namespace SOH.KeFu
{
[ModuleAttribute(ModuleID = "907747F0-ADB4-4B42-B7F0-178ADB1C7DFE", ModuleName = "批量打印报告")]
public partial class frmDaYinBaoGao : SOH.Window.baseChildForm
{
private DataTable dtTj;
private DataTable dtGj;
private int mb;
public frmDaYinBaoGao()
{
InitializeComponent();
}
private void frmDaYinBaoGao_Load(object sender, EventArgs e)
{
GetAllDdyList();
}
public void GetAllDdyList()
{
var vservice = ServiceContainer.GetService<It_ttgzb>();
String dataTj = vservice.GetTjDdyList();
dtTj = Newtonsoft.Json.JsonConvert.DeserializeObject(dataTj, typeof(DataTable)) as DataTable;
String dataGj = vservice.GetGjDdyList();
dtGj = Newtonsoft.Json.JsonConvert.DeserializeObject(dataGj, typeof(DataTable)) as DataTable;
dtTj.Merge(dtGj);
dgvRight.DataSource = dtTj;
dgvRight.Refresh();
}
public void GetAllDdyListNew()
{
var vservice = ServiceContainer.GetService<It_ttgzb>();
String dataTj = vservice.GetTjDdyList();
dtTj = Newtonsoft.Json.JsonConvert.DeserializeObject(dataTj, typeof(DataTable)) as DataTable;
String dataGj = vservice.GetGjDdyList();
dtGj = Newtonsoft.Json.JsonConvert.DeserializeObject(dataGj, typeof(DataTable)) as DataTable;
dtTj.Merge(dtGj);
dgvRight.DataSource = dtTj;
dgvRight.Refresh();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
}
private void butSx_Click(object sender, EventArgs e)
{
GetAllDdyList();
}
private void butYldybg_Click(object sender, EventArgs e)
{
DataRowView o = dgvRight.Rows[dgvRight.CurrentRow.Index].DataBoundItem as DataRowView;
frmShowBaoGao fsb = new frmShowBaoGao();
fsb.init(o.Row["tm"].ToString(),0);
fsb.re.Show();
fsb.ShowDialog();
}
private void butDyyg_Click(object sender, EventArgs e)
{
DataRowView o = dgvRight.Rows[dgvRight.CurrentRow.Index].DataBoundItem as DataRowView;
frmShowYiGan fsy = new frmShowYiGan();
fsy.init(o.Row["tm"].ToString());
fsy.print();
}
private void butKsdybg_Click(object sender, EventArgs e)
{
int fddm = Convert.ToInt32(LoginUser.yydm);
DataRowView o = dgvRight.Rows[dgvRight.CurrentRow.Index].DataBoundItem as DataRowView;
frmShowBaoGao fsb = new frmShowBaoGao();
fsb.init(o.Row["tm"].ToString(),0);
fsb.print();
if (LoginUser.yydm == "2")
{
frmShowYiGan fsy = new frmShowYiGan();
fsy.init(o.Row["tm"].ToString());
fsy.print();
}
var vs = ServiceContainer.GetService<IZongJian>();
OperationResult or = vs.UpdateTmztzInDywc(o.Row["tm"].ToString(), LoginUser.username);
GetAllDdyList();
}
private void button1_Click(object sender, EventArgs e)
{
int fddm = Convert.ToInt32(LoginUser.yydm);
foreach (DataGridViewRow dr in dgvRight.Rows)
{
frmShowBaoGao fsb = new frmShowBaoGao();
fsb.init(((DataRowView)dr.DataBoundItem).Row["tm"].ToString(),0);
fsb.print();
if (LoginUser.yydm == "2")
{
frmShowYiGan fsy = new frmShowYiGan();
fsy.init(((DataRowView)dr.DataBoundItem).Row["tm"].ToString());
fsy.print();
}
var vs = ServiceContainer.GetService<IZongJian>();
OperationResult or = vs.UpdateTmztzInDywc(((DataRowView)dr.DataBoundItem).Row["tm"].ToString(), LoginUser.username);
}
GetAllDdyList();
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
var vservice = ServiceContainer.GetService<IZongJian>();
String data = vservice.GetCxDybgBytmh(this.txtTmh.Text.Trim());
if (data.Equals("1"))
{
MessageBox.Show("在团检记录和个检记录里都找不到当前条码。");
this.txtTmh.SelectAll();
this.txtTmh.Focus();
return;
}
else
{
DataTable dtcx;
dtcx = Newtonsoft.Json.JsonConvert.DeserializeObject(data, typeof(DataTable)) as DataTable;
if (dtcx.Rows.Count != 0)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (dataGridView1.Rows[i].Cells["tiaoma"].Value.ToString() == this.txtTmh.Text.Trim())
{
this.txtTmh.SelectAll();
this.txtTmh.Focus();
return;
}
}
int index = this.dataGridView1.Rows.Add();
this.dataGridView1.Rows[index].Cells["tiaoma"].Value = dtcx.Rows[0]["tm"].ToString();
this.dataGridView1.Rows[index].Cells["xingbie"].Value = dtcx.Rows[0]["xb1"].ToString();
this.dataGridView1.Rows[index].Cells["xingming"].Value = dtcx.Rows[0]["xm"].ToString();
this.dataGridView1.Rows[index].Cells["nianling"].Value = dtcx.Rows[0]["nl"].ToString();
this.dataGridView1.Rows[index].Cells["tijianriqi"].Value = dtcx.Rows[0]["tjrq"].ToString();
this.dataGridView1.Rows[index].Cells["danwei"].Value = dtcx.Rows[0]["dw"].ToString();
this.dataGridView1.Rows[index].Cells["chushengriqi"].Value = dtcx.Rows[0]["csrq"].ToString();
this.txtTmh.SelectAll();
this.txtTmh.Focus();
}
//dataGridView1.DataSource = dtcx;
}
}
}
private void button5_Click(object sender, EventArgs e)
{
DataRowView o = dataGridView1.Rows[dataGridView1.CurrentRow.Index].DataBoundItem as DataRowView;
string tm = dataGridView1.SelectedRows[0].Cells["tiaoma"].Value.ToString();
if (cb1.Checked == true)
{
mb = 1;
}
else if (cb2.Checked == true)
{
mb = 2;
}
else if (cb3.Checked == true)
{
mb = 3;
}else if(cb4.Checked == true)
{
mb = 5;
}
else if (cb5.Checked == true)
{
mb = 6;
}
else
{
mb = 0;
}
frmShowBaoGao fsb = new frmShowBaoGao();
fsb.init(tm,mb);
fsb.re.Show();
fsb.ShowDialog();
}
private void button4_Click(object sender, EventArgs e)
{
int fddm = Convert.ToInt32(LoginUser.yydm);
DataRowView o = dataGridView1.Rows[dataGridView1.CurrentRow.Index].DataBoundItem as DataRowView;
string tm = dataGridView1.SelectedRows[0].Cells["tiaoma"].Value.ToString();
if (cb1.Checked == true)
{
mb = 1;
}
else if (cb2.Checked == true)
{
mb = 2;
}
else if (cb3.Checked == true)
{
mb = 3;
}
else if (cb4.Checked == true)
{
mb = 4;
}
else if (cb5.Checked == true)
{
mb = 6;
}
else
{
mb = 0;
}
frmShowBaoGao fsb = new frmShowBaoGao();
fsb.init(tm,mb);
fsb.print();
if (LoginUser.yydm == "2")
{
frmShowYiGan fsy = new frmShowYiGan();
fsy.init(tm);
fsy.print();
}
var vs = ServiceContainer.GetService<IZongJian>();
OperationResult or = vs.UpdateTmztzInDywc(tm, LoginUser.username);
GetAllDdyList();
}
private void button3_Click(object sender, EventArgs e)
{
DataRowView o = dataGridView1.Rows[dataGridView1.CurrentRow.Index].DataBoundItem as DataRowView;
string tm = dataGridView1.SelectedRows[0].Cells["tiaoma"].Value.ToString();
frmShowYiGan fsy = new frmShowYiGan();
fsy.init(tm);
fsy.print();
}
private void button2_Click(object sender, EventArgs e)
{
int fddm = Convert.ToInt32(LoginUser.yydm);
if (cb1.Checked == true)
{
mb = 1;
}
else if (cb2.Checked == true)
{
mb = 2;
}
else if (cb3.Checked == true)
{
mb = 3;
}
else if (cb4.Checked == true)
{
mb = 4;
}
else if (cb5.Checked == true)
{
mb = 6;
}
else
{
mb = 0;
}
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
frmShowBaoGao fsb = new frmShowBaoGao();
fsb.init(dataGridView1.Rows[i].Cells["tiaoma"].Value.ToString(), mb);
if(mb!=4)
{
fsb.print();
}
if (LoginUser.yydm == "2")
{
frmShowYiGan fsy = new frmShowYiGan();
fsy.init(dataGridView1.Rows[i].Cells["tiaoma"].Value.ToString());
fsy.print();
}
var vs = ServiceContainer.GetService<IZongJian>();
OperationResult or = vs.UpdateTmztzInDywc(dataGridView1.Rows[i].Cells["tiaoma"].Value.ToString(), LoginUser.username);
if (or.State == 1)
{
dataGridView1.Rows.RemoveAt(i);
i--;
}
}
}
}
}