天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

373 lines
14 KiB

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 CarSystem.Account.FileUtil;
using System.Configuration;
using DCS.Place;
using Model;
namespace QMAPP.WinForm.Forms.DisPatch
{
public partial class FrmItemList : Form
{
public FrmItemList()
{
InitializeComponent();
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
GetData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void GetData()
{
string strpasterno = txtPasteNO.Text;
string strbegindate = datbegindate.Text;
string strenddate = datenddate.Text;
string selectPlantCode = cmbtype.SelectedValue.ToString();//生产中心
string strOperator = txtOperator.Text;
//string vinLack = (cbVinLack.Checked) ? "1" : "0";
string vinLack = "0";
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tbl = agent.InvokeServiceFunction<DataTable>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardInfoWithVin.ToString(), strpasterno, strbegindate, strenddate, vinLack, selectPlantCode, strOperator);
if (tbl.Rows.Count <= 0)
{
DataTable dt = (DataTable)dgvList.DataSource;
if (dt != null)
{
dt.Rows.Clear();
}
}
else
{
dgvList.DataSource = tbl;
}
for (var i = 0; i < dgvList.Rows.Count; i++)
{
if (dgvList.Rows[i].Cells["PASTECARDDATE2"].Value.ToString() == "1900/1/1 0:00:00")
{
dgvList.Rows[i].Cells["PASTECARDDATE2"].Value = "";
}
for (var j = 0; j < dgvList.Rows[i].Cells.Count; j++)
{
dgvList.Columns[j].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
}
}
/// <summary>
/// 单击右键
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgvList_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
#region
if (e.Button == MouseButtons.Right && e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
try
{
dgvList.Rows[e.RowIndex].ContextMenuStrip = cmenuFunctions;
dgvList.Rows[e.RowIndex].Selected = true;
dgvList.CurrentCell = dgvList.Rows[e.RowIndex].Cells[e.ColumnIndex];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
#endregion
}
/// <summary>
/// 双击
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgvList_DoubleClick(object sender, EventArgs e)
{
if (dgvList.Rows.Count > 0)
{
int i = dgvList.CurrentRow.Index;
string fiskey = dgvList.Rows[i].Cells[0].Value.ToString();
FrmCarCardDetail frm = new FrmCarCardDetail(fiskey);
frm.ShowDialog();
}
}
/// <summary>
/// 显示行号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgvList_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
#region
try
{
if (dgvList.Rows.Count > 0)
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(), dgvList.DefaultCellStyle.Font,
new SolidBrush(dgvList.RowHeadersDefaultCellStyle.ForeColor),
e.RowBounds.Location.X + 15, e.RowBounds.Y + 5);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
#endregion
}
/// <summary>
/// 加载画面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FrmItemList_Load(object sender, EventArgs e)
{
#region
try
{
datbegindate.Value = DateTime.Now.AddDays(-1);
DataTable dt;
//QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
//dt = agent.InvokeServiceFunction<DataTable>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardIndex.ToString(),"","");
//this.cmbtype.DataSource = dt;
//this.cmbtype.DisplayMember = "PLANTNAME";
//this.cmbtype.ValueMember = "PLANTNAME";
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tblCodes = agent.InvokeServiceFunction<DataTable>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetWORKCENTERCODE.ToString());
IList<EProCodeInfo> proCodes = new List<EProCodeInfo>();
for (var i = 0; i < tblCodes.Rows.Count; i++)
{
EProCodeInfo epci = new EProCodeInfo();
epci._Name = tblCodes.Rows[i][0].ToString();
epci._Code = tblCodes.Rows[i][0].ToString();
proCodes.Add(epci);
}
cmbtype.DataSource = proCodes;
cmbtype.DisplayMember = "_Name";
cmbtype.ValueMember = "_Code";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
#endregion
}
/// <summary>
/// 明细双击
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmenuDisplay_Click(object sender, EventArgs e)
{
FrmCarCardPrintShow frm = new FrmCarCardPrintShow();
frm.ShowDialog();
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
}
/// <summary>
/// 导出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnExport_Click(object sender, EventArgs e)
{
if (dgvList.Rows.Count > 0)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
//SaveFileDialog dlg = new SaveFileDialog();
//dlg.Filter = "CSV (逗号分隔)(*.csv)|*.csv";
//dlg.Title = "导出文件";
//dlg.CheckPathExists = true;
// dlg.OverwritePrompt = true;
string sfilename = folderBrowserDialog1.SelectedPath;
//============================================
System.DateTime time = System.DateTime.Now;
string xlsName = " ";
string cellName1 = "";
string cellName2 = "";
List<string[]> listResult = new List<string[]>();
xlsName = "贴车单";
cellName1 = "贴车单";
string[] head = { "贴车单单号", "工作中心", "打印时间", "补打时间", "操作者", "底盘号间隔", "生产线名称", "创建日期" };
listResult.Add(head);
// -------------------------2017 02 27 崔法宝 end ---------------------
//sfilename = "贴车单";
sfilename = sfilename + @"\" + xlsName + "信息" + ".xls";
//判断文件是否存在
if (System.IO.File.Exists(sfilename) == false)
{
System.IO.StreamWriter sr = System.IO.File.CreateText(sfilename);
sr.Close();
}
for (var i = 0; i < dgvList.Rows.Count; i++)
{
string[] lstTmp = {
ExcelUtil.GetJoinedData(ExcelUtil.DataType.String, dgvList.Rows[i].Cells["PASTECARDNO"].Value.ToString()),
ExcelUtil.GetJoinedData(ExcelUtil.DataType.String, dgvList.Rows[i].Cells["PLANTNAME"].Value.ToString()),
ExcelUtil.GetJoinedData(ExcelUtil.DataType.String, dgvList.Rows[i].Cells["PASTECARDDATE"].Value.ToString()),
ExcelUtil.GetJoinedData(ExcelUtil.DataType.String, dgvList.Rows[i].Cells["PASTECARDDATE2"].Value.ToString().Replace("0001/1/1 0:00:00","")),
ExcelUtil.GetJoinedData(ExcelUtil.DataType.String, dgvList.Rows[i].Cells["OPERATOR"].Value.ToString()),
ExcelUtil.GetJoinedData(ExcelUtil.DataType.String, dgvList.Rows[i].Cells["VINLACK"].Value.ToString()),
ExcelUtil.GetJoinedData(ExcelUtil.DataType.String, dgvList.Rows[i].Cells["PRODUCTIONNAME"].Value.ToString()),
ExcelUtil.GetJoinedData(ExcelUtil.DataType.String, dgvList.Rows[i].Cells["CREATETIME"].Value.ToString())
};
listResult.Add(lstTmp);
}
ExcelUtil.WriteExcel(sfilename, "贴车单", listResult);
MessageBox.Show("导出成功!");
System.Diagnostics.Process.Start(sfilename);
}
}
else
{
MessageBox.Show("无数据导出!");
}
}
// 补打事件
private void btnPrint_Click(object sender, EventArgs e)
{
if (dgvList.Rows.Count > 0)
{
int i = dgvList.CurrentRow.Index;
string fiskey = dgvList.Rows[i].Cells[0].Value.ToString();
string PASTECARDNO = dgvList.Rows[i].Cells["PASTECARDNO"].Value.ToString();
string PRODUCTIONNAME = dgvList.Rows[i].Cells["PRODUCTIONNAME"].Value.ToString();
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tbl = agent.InvokeServiceFunction<DataTable>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPascardDetailsByPid.ToString(), fiskey);
int result = agent.InvokeServiceFunction<int>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_UpdatePasteCardPasteCardDate2Value.ToString(), PASTECARDNO, DateTime.Now.ToString(), ClientContext.LoginInfo.UserName.ToString());
Print(tbl, PASTECARDNO, PRODUCTIONNAME);
if (result > 0)
{
MessageBox.Show("补打成功!");
GetData();
}
else
{
MessageBox.Show("补打失败!");
}
}
else
{
MessageBox.Show("无补打数据!");
}
}
/// <summary>
/// 手动打印功能
/// </summary>
private void Print(DataTable tbl1, string PASTECARDNO, string PRODUCTIONNAME)
{
PrintPasteCard prin = new PrintPasteCard();
string strprodtype = "(" + PRODUCTIONNAME + ")";
DataTable dt = new DataTable();
dt.Columns.Add("ROWINDEX");
dt.Columns.Add("VWSEQ");
dt.Columns.Add("VIN");
dt.Columns.Add("PRODNO");
dt.Columns.Add("CARSETDESCCN");
dt.Columns.Add("CP5A");
dt.Columns.Add("PASTECARDNO");
dt.Columns.Add("SCANDATE");
dt.Columns.Add("PRODUCTIONNAME");
dt.Columns.Add("LINENO");
int index = 1;
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tbl = agent.InvokeServiceFunction<DataTable>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardDeatis.ToString());
// index = Convert.ToInt32(tbl.Rows[0][0].ToString());
for (var i = 0; i < tbl1.Rows.Count; i++)
{
DataRow ncsdr = dt.NewRow();
ncsdr["ROWINDEX"] = index.ToString(); ;
ncsdr["VWSEQ"] = tbl1.Rows[i]["VWSEQ"].ToString();
ncsdr["VIN"] = tbl1.Rows[i]["VIN"].ToString();
ncsdr["PRODNO"] = tbl1.Rows[i]["PRODNO"].ToString();
ncsdr["CARSETDESCCN"] = tbl1.Rows[i]["CARSETDESC_CN"].ToString();
ncsdr["CP5A"] = tbl1.Rows[i]["CP5A"].ToString();
ncsdr["PASTECARDNO"] = PASTECARDNO;
ncsdr["SCANDATE"] = DateTime.Now.ToString();
ncsdr["PRODUCTIONNAME"] = strprodtype;
ncsdr["LINENO"] = tbl1.Rows[i]["LINENO"].ToString();
dt.Rows.Add(ncsdr);
index++;
}
prin.Print(dt);
//MessageBox.Show("打印成功!");
}
}
}