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.
 
 
 
 

291 lines
11 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Stone.Common;
using Stone.Entity;
using Stone.WinBiz.JISAdmin;
using Gm_WMS.DataAccess.DataService;
namespace Stone.WinModule.JISAdmin
{
public partial class frmEdiPrintASN : Stone.WinModule.frmBase
{
public frmEdiPrintASN()
{
InitializeComponent();
}
private void frmEdiPrintASN_Load(object sender, EventArgs e)
{
this.cbFields.SelectedIndex = 0;
this.timer1.Interval = Convert.ToInt32(MyAppconfig.ReadValue("EDI显示刷新时间")) * 1000;
this.timer1.Enabled = true;
if (User.UserInfo.UserName == "admin")
{
this.btnAsnRe.Visible = true;
}
}
private void btnQuery_Click(object sender, EventArgs e)
{
try
{
string Fields = this.cbFields.SelectedItem.ToString();
string value = this.txtKey.Text.Trim();
string d1 = MyDateTime.Format(this.dateTimePicker1.Value, MyDateTimeType.Date) + " 00:00:00";
string d2 = MyDateTime.Format(this.dateTimePicker2.Value, MyDateTimeType.Date) + " 23:59:59";
string strWhere = "[IsPrintPackingList]=1 and [IsPrintASN]={0} and [SwetTime]>='{1}' and [SwetTime]<='{2}' {3}";
object[] obj = new object[10];
obj[0] = rbPrint1.Checked ? "1" : "0";
obj[1] = d1;
obj[2] = d2;
obj[3] = " and " + Fields + "='" + value + "'";
if (value == "") obj[3] = "";
strWhere = string.Format(strWhere, obj);
Entity_t_JIS_Seq5000 t_JIS_Seq5000 = new Entity_t_JIS_Seq5000();
this.dgrdView1.DataSource = t_JIS_Seq5000.GetData("", strWhere, "[SequenceNumber] asc, [SwetTime] asc").Tables[0];
MyGridViewStyle.SetDataGridRowNumber(this.dgrdView1);
MyGridViewStyle.SetDataGridMenuCommon(this.dgrdView1);
MyGridViewStyle.GetGridViewState(this.dgrdView1, "ASN");
this.dgrdView1.Columns["ID"].Visible = false;
this.dgrdView1.Columns["SequenceNumber"].HeaderText = "EINSTEIN Seq";
this.lblState.Text = "记录:" + this.dgrdView1.Rows.Count.ToString();
}
catch (Exception ex)
{
this.lblShow.Text = ex.Message;
}
}
private void btnPrintHand_Click(object sender, EventArgs e)
{
this.chkAuto.Checked = false;
this.btnPrintHand.Enabled = false;
this.Update();
try
{
frmEdiPrintASNSelect frm = new frmEdiPrintASNSelect();
if (frm.ShowDialog() == DialogResult.OK)
{
this.lblASNState.Text = "正在打印和上传数据...";
this.Update();
string strWhere = "[PackingListNumber] in (" + frm.PackingListNumber + ") and [PartsFamily] in(" + frm.PartsFamily + ")";
Entity_t_JIS_Seq5000 t_JIS_Seq5000 = new Entity_t_JIS_Seq5000();
//DataSet dsData = t_JIS_Seq5000.GetData("", strWhere, "[SequenceNumber] asc, [SwetTime] asc");
DataSet dsData = t_JIS_Seq5000.GetData("", strWhere, "PackageGroupName asc, SequenceNumber asc");
if (dsData.Tables[0].Rows.Count == 0) throw new Exception("没有可打印的数据");
if (dsData.Tables[0].Select("[IsPrintASN]=1").Length > 0)
throw new Exception("选择的记录中有已经打印的数据,请刷新数据!");
dsData.Tables[0].TableName = "BillHead";
Entity_t_JIS_Log t_JIS_Log = new Entity_t_JIS_Log();
DataRow drLog = t_JIS_Log.Table.NewRow();
drLog["FileType"] = "生成ASN文件";
drLog["StartTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
try
{
string AsnNumber = F_JIS5000_Print.GetASNNumber(new LocalDBService(), dsData.Tables[0].Rows[0]["PackageGroupName"].ToString());
drLog["FileName"] = AsnNumber;
drLog = t_JIS_Log.Add(drLog);
t_JIS_Seq5000.Edit("[IsPrintASN]=1, [AsnNumber]='" + AsnNumber + "'", strWhere);
F_JIS5000_Print.WriteASN(dsData, AsnNumber, true);
F_JIS5000_Print.PrintASNList(dsData, AsnNumber, false);
drLog["ProcessState"] = "Success";
drLog["EndTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
t_JIS_Log.Edit(drLog);
}
catch (Exception ex)
{
drLog["ProcessState"] = "Failed";
drLog["EndTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
drLog["Memo"] = ex.Message;
t_JIS_Log.Edit(drLog);
throw ex;
}
btnQuery_Click(new object(), new EventArgs());
}
frm.Dispose();
return;
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
finally
{
this.btnPrintHand.Enabled = true;
this.lblASNState.Text = "";
Application.DoEvents();
}
}
private void btnRePrint_Click(object sender, EventArgs e)
{
try
{
if (!MyMessageBox.ShowQuestion("是否要补打ASN?")) return;
if (this.dgrdView1.SelectedRows.Count == 0) throw new Exception("请选择要补打的记录!");
string AsnNumber = this.dgrdView1.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
if (AsnNumber == "") throw new Exception("只有已经打印过的才能补打!");
Entity_t_JIS_Seq5000 t_JIS_Seq5000 = new Entity_t_JIS_Seq5000();
DataSet dsData = t_JIS_Seq5000.GetData("", "[AsnNumber]='" + AsnNumber + "'", "PackageGroupName asc, SequenceNumber asc");
if (dsData.Tables[0].Select("[IsPrintASN]=0").Length > 0)
throw new Exception("没有可打印的数据");
dsData.Tables[0].TableName = "BillHead";
F_JIS5000_Print.PrintASNList(dsData, AsnNumber, true);
btnQuery_Click(new object(), new EventArgs());
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void btnSet_Click(object sender, EventArgs e)
{
MyGridViewStyle.Show(this.dgrdView1, "ASN");
}
private void btnOutPut_Click(object sender, EventArgs e)
{
try
{
frmEdiPrintASNOutNew frm = new frmEdiPrintASNOutNew();
frm.Text = "导出ASN";
frm.t_base = new Entity_t_JIS_ASN();
frm.ShowDialog();
frm.Dispose();
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void chkAuto_CheckedChanged(object sender, EventArgs e)
{
AutoUpdate();
}
private void AutoUpdate()
{
if (chkAuto.Checked)
{
this.lblShow.Text = "自动刷新中...";
this.Update();
btnQuery_Click(new object(), new EventArgs());
this.lblShow.Text = DateTime.Now.ToString() + " 自动刷新完成,下次刷新 " + Convert.ToString(this.timer1.Interval / 1000) + " 秒以后";
}
else
{
this.lblShow.Text = "自动刷新关闭";
}
}
private void timer1_Tick(object sender, EventArgs e)
{
AutoUpdate();
}
private void btnAsnRe_Click(object sender, EventArgs e)
{
this.chkAuto.Checked = false;
this.btnAsnRe.Enabled = false;
this.Update();
try
{
if (this.dgrdView1.SelectedRows.Count == 0) throw new Exception("请选择要重新生成的记录");
if (Convert.ToInt32(this.dgrdView1.SelectedRows[0].Cells["IsPrintASN"].Value) == 0) throw new Exception("请选择已经打印过ASN的记录");
string AsnNumber = this.dgrdView1.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
Entity_t_JIS_Seq5000 t_JIS_Seq5000 = new Entity_t_JIS_Seq5000();
DataSet dsData = t_JIS_Seq5000.GetData("", "[AsnNumber]='" + AsnNumber + "'", "[SequenceNumber] asc, [SwetTime] asc");
if (dsData.Tables[0].Rows.Count == 0) throw new Exception("没有可打印的数据");
if (dsData.Tables[0].Select("[IsPrintASN]=0").Length > 0)
throw new Exception("选择的记录中有未打印的数据,请刷新数据!");
dsData.Tables[0].TableName = "BillHead";
if (!MyMessageBox.ShowQuestion("是否要重新生成 " + AsnNumber + " 的文件?")) return;
this.lblASNState.Text = "正在重新生成和上传ASN数据...";
this.Update();
Entity_t_JIS_Log t_JIS_Log = new Entity_t_JIS_Log();
DataRow drLog = t_JIS_Log.Table.NewRow();
drLog["FileType"] = "重新生成ASN文件";
drLog["StartTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
drLog["FileName"] = AsnNumber;
drLog = t_JIS_Log.Add(drLog);
try
{
F_JIS5000_Print.WriteASN(dsData, AsnNumber, false);
drLog["ProcessState"] = "Success";
drLog["EndTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
t_JIS_Log.Edit(drLog);
}
catch (Exception ex)
{
drLog["ProcessState"] = "Failed";
drLog["EndTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
drLog["Memo"] = ex.Message;
t_JIS_Log.Edit(drLog);
throw ex;
}
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
finally
{
this.btnAsnRe.Enabled = true;
this.lblASNState.Text = "";
Application.DoEvents();
}
}
}
}