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.
840 lines
32 KiB
840 lines
32 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.WinModule.JISData;
|
|
using Stone.WinBiz.JISAdmin;
|
|
using Stone.WinBiz.JISData;
|
|
using Gm_WMS.DataAccess.DataService;
|
|
using Stone.WinBiz.Standard;
|
|
|
|
namespace Stone.WinModule.Standard
|
|
{
|
|
public partial class frmJISVDAASN : Stone.WinModule.BasicData.frmBaseMain
|
|
{
|
|
public string asn_file = Application.StartupPath + "\\Report\\ASN.grf";
|
|
public frmJISVDAASN()
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.tlbSelect.Visible = false;
|
|
this.tlbAdd.Visible = false;
|
|
this.tlbAddCopy.Visible = false;
|
|
this.tlbEdit.Visible = false;
|
|
//this.tlbDelete.Visible = false;
|
|
this.tlbInput.Visible = false;
|
|
this.tlbFilter.Visible = false;
|
|
this.tlbExit.Visible = false;
|
|
|
|
base.dgrdView.MultiSelect = true;
|
|
|
|
this.toolStrip1.Padding = new Padding(0, 0, 460, 0);
|
|
}
|
|
|
|
public override void init()
|
|
{
|
|
Search("");
|
|
base.init();
|
|
|
|
}
|
|
|
|
public override void Search(string code)
|
|
{
|
|
|
|
string d1 = MyDateTime.Format(this.dateTimePicker1.Value, MyDateTimeType.Date) + " 00:00:00";
|
|
string d2 = MyDateTime.Format(this.dateTimePicker2.Value, MyDateTimeType.Date) + " 23:59:59";
|
|
|
|
|
|
if (code == "")
|
|
{
|
|
strWhere = "1=1";
|
|
}
|
|
else
|
|
{
|
|
strWhere = " [partNumber] like '%" + code + "%' or ";
|
|
strWhere += " [AsnNumber] like '%" + code + "%' or ";
|
|
strWhere += " [PackageNo] like '%" + code + "%'";
|
|
}
|
|
|
|
if (this.chkUpload.Checked)
|
|
{
|
|
strWhere += " and [IsUpload]=0";
|
|
}
|
|
else
|
|
{
|
|
strWhere = "[LabelDate]>='" + d1 + "' and [LabelDate]<='" + d2 + "'";
|
|
}
|
|
|
|
strWhere += " and (" + strWhere + ")";
|
|
}
|
|
|
|
private void frmJISLog_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
ToolStripButton btnCancel = new ToolStripButton("撤销ASN");
|
|
btnCancel.Image = this.imageList1.Images[2];
|
|
btnCancel.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnCancel.Click += BtnCancel_Click;
|
|
this.toolStrip1.Items.Insert(4, btnCancel);
|
|
|
|
ToolStripButton btnUploadRe = new ToolStripButton("补传ASN");
|
|
btnUploadRe.Image = this.imageList1.Images[4];
|
|
btnUploadRe.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnUploadRe.Click += BtnUploadRe_Click;
|
|
this.toolStrip1.Items.Insert(0, btnUploadRe);
|
|
|
|
ToolStripButton btnUpload = new ToolStripButton("上传ASN");
|
|
btnUpload.Image = this.imageList1.Images[3];
|
|
btnUpload.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnUpload.Click += BtnUpload_Click;
|
|
this.toolStrip1.Items.Insert(0, btnUpload);
|
|
|
|
ToolStripButton btnPrintRe = new ToolStripButton("补打ASN");
|
|
btnPrintRe.Image = this.imageList1.Images[0];
|
|
btnPrintRe.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnPrintRe.Click += new EventHandler(btnPrintRe_Click);
|
|
this.toolStrip1.Items.Insert(0, btnPrintRe);
|
|
|
|
ToolStripButton btnPrint = new ToolStripButton("打印ASN");
|
|
btnPrint.Image = this.imageList1.Images[0];
|
|
btnPrint.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnPrint.Click += new EventHandler(btnPrint_Click);
|
|
this.toolStrip1.Items.Insert(0, btnPrint);
|
|
|
|
ToolStripButton btnPrintVDARight = new ToolStripButton("补打02标签");
|
|
btnPrintVDARight.Image = this.imageList1.Images[0];
|
|
btnPrintVDARight.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnPrintVDARight.Click += new EventHandler(btnPrintVDARight_Click);
|
|
this.toolStrip1.Items.Insert(0, btnPrintVDARight);
|
|
|
|
ToolStripButton btnPrintVDA = new ToolStripButton("补打01标签");
|
|
btnPrintVDA.Image = this.imageList1.Images[0];
|
|
btnPrintVDA.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnPrintVDA.Click += new EventHandler(btnPrintVDA_Click);
|
|
this.toolStrip1.Items.Insert(0, btnPrintVDA);
|
|
|
|
ToolStripButton btnPrintLabel = new ToolStripButton("打印VDA标签");
|
|
btnPrintLabel.Image = this.imageList1.Images[0];
|
|
btnPrintLabel.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnPrintLabel.Click += btnPrintLabel_Click;
|
|
this.toolStrip1.Items.Insert(0, btnPrintLabel);
|
|
|
|
ToolStripButton btnPREDN = new ToolStripButton("PRE-DN生成");
|
|
btnPREDN.Image = this.imageList1.Images[1];
|
|
btnPREDN.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnPREDN.Click += btnPREDN_Click;
|
|
this.toolStrip1.Items.Insert(0, btnPREDN);
|
|
|
|
|
|
}
|
|
|
|
private void BtnUploadRe_Click(object sender, EventArgs e)
|
|
{
|
|
string LogID = "0";
|
|
try
|
|
{
|
|
if (this.dgrdView.SelectedRows.Count == 0) throw new Exception("请选择要补传的ASN");
|
|
|
|
string AsnNumber = this.dgrdView.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
|
|
|
|
if (!ShowQuestionPop($"是否要补传 {AsnNumber} ?"))
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
LogID = F_JIS_Log.WriteLogsStart($"补传ASN {AsnNumber}");
|
|
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA();
|
|
Entity_v_JIS_VDA v_JIS_VDA = new Entity_v_JIS_VDA();
|
|
|
|
DataSet dsData = v_JIS_VDA.GetData($"[AsnNumber]='{AsnNumber}'");
|
|
if (dsData.Tables[0].Rows.Count == 0)
|
|
throw new Exception($"{AsnNumber} 不存在");
|
|
|
|
if (dsData.Tables[0].Select("[IsUpload]<>True").Length > 0)
|
|
throw new Exception(AsnNumber + " 未上传,不能补传");
|
|
|
|
string filename = F_JIS5000_Print.WriteASN_VDA(new LocalDBService(), dsData, AsnNumber);
|
|
|
|
F_JIS_Log.WriteLogsEnd(LogID, true, filename);
|
|
|
|
MyMessageBox.ShowInfoMessage($"{AsnNumber} 补传成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
F_JIS_Log.WriteLogsEnd(LogID, false, ex.Message);
|
|
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
private void BtnUpload_Click(object sender, EventArgs e)
|
|
{
|
|
Gm_WMS.DataAccess.DataService.LocalDBService db = null;
|
|
string LogID = "0";
|
|
try
|
|
{
|
|
if (this.dgrdView.SelectedRows.Count == 0) throw new Exception("请选择要上传的ASN");
|
|
|
|
string AsnNumber = this.dgrdView.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
|
|
|
|
if (!MyMessageBox.ShowQuestion($"是否要上传 {AsnNumber} ?")) return;
|
|
|
|
if (!CheckASN(AsnNumber)) return;
|
|
|
|
LogID = F_JIS_Log.WriteLogsStart($"上传ASN {AsnNumber}");
|
|
|
|
db = new Gm_WMS.DataAccess.DataService.LocalDBService();
|
|
db.BeginTrans();
|
|
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA(db);
|
|
Entity_v_JIS_VDA v_JIS_VDA = new Entity_v_JIS_VDA(db);
|
|
|
|
DataSet dsData = v_JIS_VDA.GetData($"[AsnNumber]='{AsnNumber}'");
|
|
if (dsData.Tables[0].Rows.Count == 0)
|
|
throw new Exception($"{AsnNumber} 不存在");
|
|
|
|
if (dsData.Tables[0].Select("[IsUpload]=True").Length > 0)
|
|
throw new Exception(AsnNumber + " 已经上传");
|
|
|
|
if (dsData.Tables[0].Select("[IsPrintASN]=False").Length > 0)
|
|
throw new Exception(AsnNumber + " 未打印");
|
|
|
|
if (dsData.Tables[0].Select("[IsPackingVerification]=False").Length > 0)
|
|
throw new Exception(AsnNumber + " 未完成装箱校验");
|
|
|
|
if (dsData.Tables[0].Select("[IsShipingVerification]=False").Length > 0)
|
|
throw new Exception(AsnNumber + " 未完成装车校验");
|
|
|
|
|
|
DateTime UploadTime = t_JIS_VDA.GetDateTime();
|
|
for (int i = 0; i < dsData.Tables[0].Rows.Count; i++)
|
|
{
|
|
dsData.Tables[0].Rows[i]["UploadTime"] = UploadTime;
|
|
}
|
|
|
|
t_JIS_VDA.Edit(
|
|
$"[UploadTime]='{UploadTime.ToString("yyyy-MM-dd HH:mm:ss")}', [IsUpload]=1",
|
|
$"[AsnNumber]='{AsnNumber}'");
|
|
|
|
|
|
string filename = F_JIS5000_Print.WriteASN_VDA(db, dsData, AsnNumber);
|
|
|
|
#region 计算累计发货数量
|
|
var strsql = "";
|
|
var dtPartOutQty = new DataTable();
|
|
strsql = "select * from t_PartOutQty";
|
|
dtPartOutQty = db.Exec_DataSet(strsql).Tables[0];
|
|
foreach (DataRow drData in dsData.Tables[0].Rows)
|
|
{
|
|
var code = drData["PartNumber"].ToString();
|
|
var outQty = decimal.Parse(drData["Qty"].ToString());
|
|
var asnNum = drData["AsnNumber"].ToString();
|
|
strsql = CreatePartOutSql(db,code, outQty, dtPartOutQty, asnNum,out dtPartOutQty);
|
|
if (!string.IsNullOrEmpty(strsql))
|
|
{
|
|
db.Exec_NonQuery(strsql);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
db.Commit();
|
|
try
|
|
{
|
|
UpdateGridView();
|
|
}
|
|
catch { }
|
|
|
|
F_JIS_Log.WriteLogsEnd(LogID, true, filename);
|
|
|
|
MyMessageBox.ShowInfoMessage($"{AsnNumber} 上传成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
F_JIS_Log.WriteLogsEnd(LogID, false, ex.Message);
|
|
|
|
if (db != null) db.Rollback();
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (db != null) db.EndTrans();
|
|
|
|
}
|
|
}
|
|
|
|
private bool CheckASN(string AsnNumber)
|
|
{
|
|
bool ret = true;
|
|
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA();
|
|
DataTable dtASN = t_JIS_VDA.GetData(
|
|
$"PartNumber, Date, Sum(Qty) as Qty",
|
|
$"AsnNumber='{AsnNumber}' group by PartNumber, Date",
|
|
$"PartNumber asc").Tables[0];
|
|
|
|
string msg = "";
|
|
|
|
Entity_t_JIS_Lab t_JIS_Lab = new Entity_t_JIS_Lab();
|
|
foreach (DataRow drASN in dtASN.Rows)
|
|
{
|
|
string PartNumber = drASN["PartNumber"].ToString();
|
|
string Date = Convert.ToDateTime(drASN["Date"]).ToString("yyyy-MM-dd");
|
|
int Qty = Convert.ToInt32(drASN["Qty"]);
|
|
|
|
DataTable dtLab = t_JIS_Lab.GetData(
|
|
$"[fileType]='{((F_JIS_VDA_ASN)m_Base).fileType}' " + "" +
|
|
$" and [PartNumber]='{PartNumber}' and [StartDate]='{Date}'").Tables[0];
|
|
|
|
if (dtLab.Rows.Count == 0)
|
|
{
|
|
msg += $"{PartNumber} {Date} 在LAB中不存在\r\n";
|
|
}
|
|
else if (Convert.ToInt32(dtLab.Rows[0]["quantity"]) != Qty)
|
|
{
|
|
msg += $"{PartNumber} {Date} 发货数量 {Qty} 和LAB需求数量 {dtLab.Rows[0]["quantity"]} 不一样\r\n";
|
|
}
|
|
|
|
}
|
|
|
|
string LogID = F_JIS_Log.WriteLogsStart($"检查ASN {AsnNumber}");
|
|
if (msg != "")
|
|
{
|
|
string show_str = "检测ASN发货数据时发现以下问题,是否要继续上传ASN?\r\n" + msg;
|
|
|
|
if (!ShowQuestionPop(show_str))
|
|
{
|
|
ret = false;
|
|
|
|
F_JIS_Log.WriteLogsEnd(LogID, false, "您选择了取消上传【" + msg + "】");
|
|
}
|
|
else
|
|
{
|
|
F_JIS_Log.WriteLogsEnd(LogID, false, "您选择了继续上传【" + msg + "】");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
F_JIS_Log.WriteLogsEnd(LogID, true, "");
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
|
|
}
|
|
|
|
public bool ShowQuestionPop(string MessageInfo)
|
|
{
|
|
bool result = false;
|
|
|
|
frmMessageQuestion frm = new frmMessageQuestion();
|
|
if (frm.ShowQuestion(MessageInfo) == DialogResult.OK)
|
|
{
|
|
result = true;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
private void BtnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
string LogID = "0";
|
|
try
|
|
{
|
|
if (this.dgrdView.SelectedRows.Count == 0)
|
|
throw new Exception("请选择一行记录");
|
|
|
|
string AsnNumber = this.dgrdView.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
|
|
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA();
|
|
DataTable dtData = t_JIS_VDA.GetData($"[AsnNumber]='{AsnNumber}'").Tables[0];
|
|
if (dtData.Rows.Count == 0)
|
|
throw new Exception($"{AsnNumber} 在系统中不存在");
|
|
|
|
|
|
if (!Convert.ToBoolean(dtData.Rows[0]["IsUpload"]))
|
|
throw new Exception($"{AsnNumber} 未上传不能撤销");
|
|
|
|
string location = dtData.Rows[0]["location"].ToString();
|
|
string fileType = dtData.Rows[0]["fileType"].ToString();
|
|
|
|
DataTable dtLast = t_JIS_VDA.GetData(
|
|
$"top 1 *",
|
|
$"[fileType]='{fileType}' and [location]='{location}'",
|
|
$"[AsnNumber] desc").Tables[0];
|
|
|
|
if (dtLast.Rows.Count > 0)
|
|
{
|
|
if (dtLast.Rows[0]["AsnNumber"].ToString() != AsnNumber)
|
|
throw new Exception($"只能撤销最后一个ASN {dtLast.Rows[0]["AsnNumber"]}");
|
|
}
|
|
|
|
if (MyMessageBox.ShowQuestion($"是否要撤销 {AsnNumber} ?"))
|
|
{
|
|
LogID = F_JIS_Log.WriteLogsStart($"撤销ASN {AsnNumber}");
|
|
|
|
CancelASN(AsnNumber);
|
|
|
|
//计算累计发货数量
|
|
var strSql = "UPDATE t_PartOutQty " +
|
|
" set PartOutQty -= LastOutQty," +
|
|
" LastOutQty = 0," +
|
|
" LastOutTime = null," +
|
|
" AsnNum = ''" +
|
|
" where AsnNum = '" + AsnNumber + "'";
|
|
var db = new LocalDBService();
|
|
db.Exec_NonQuery(strSql);
|
|
|
|
F_JIS_Log.WriteLogsEnd(LogID, true, "");
|
|
|
|
MyMessageBox.ShowInfoMessage($"{AsnNumber} 撤销成功");
|
|
}
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
F_JIS_Log.WriteLogsEnd(LogID, false, ex.Message);
|
|
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void CancelASN(string AsnNumber)
|
|
{
|
|
LocalDBService db = null;
|
|
try
|
|
{
|
|
db = new LocalDBService();
|
|
db.BeginTrans();
|
|
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA(db);
|
|
|
|
t_JIS_VDA.Edit($"[IsUpload]=0, [UploadTime]=null,IsShipingVerification = 0,IsPrintASN = 0", $"[AsnNumber]='{AsnNumber}'");
|
|
|
|
db.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (db != null) db.Rollback();
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
if (db != null) db.EndTrans();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void btnPREDN_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.dgrdView.SelectedRows.Count == 0)
|
|
throw new Exception("请选择要生成的ASN");
|
|
|
|
string AsnNumber = this.dgrdView.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
|
|
|
|
if (!CheckASN(AsnNumber)) return;
|
|
|
|
Entity_v_JIS_VDA v_JIS_VDA = new Entity_v_JIS_VDA();
|
|
DataTable dtData = v_JIS_VDA.GetData("", $"[AsnNumber]='{AsnNumber}'", "[PackageNo] asc").Tables[0];
|
|
if (dtData.Rows.Count == 0) throw new Exception("打印的数据不存在");
|
|
|
|
if (dtData.Rows[0]["IsPrintASN"].ToString() == "1")
|
|
throw new Exception($"{AsnNumber}已经完成,不能生成PREDN");
|
|
|
|
var frmPickUpDate = new frmPickUpDate();
|
|
frmPickUpDate.dtSwetDate = Convert.ToDateTime(dtData.Rows[0]["Date"]);
|
|
frmPickUpDate.ShowDialog();
|
|
frmPickUpDate.Dispose();
|
|
frmPREDN frm = new frmPREDN();
|
|
frm.dtPickUpTime = frmPickUpDate.dtPickUp;
|
|
frm.dtData = dtData;
|
|
frm.ShowDialog();
|
|
frm.Dispose();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void btnPrintLabel_Click(object sender, EventArgs e)
|
|
{
|
|
Gm_WMS.DataAccess.DataService.LocalDBService db = null;
|
|
string LogID = "0";
|
|
try
|
|
{
|
|
if (this.dgrdView.SelectedRows.Count == 0) throw new Exception("请选择要打印标签的ASN");
|
|
|
|
string AsnNumber = this.dgrdView.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
|
|
|
|
if (!MyMessageBox.ShowQuestion($"是否要打印【{AsnNumber}】的所有未打印的标签?")) return;
|
|
|
|
|
|
|
|
db = new Gm_WMS.DataAccess.DataService.LocalDBService();
|
|
db.BeginTrans();
|
|
|
|
Entity_v_JIS_VDA t_JIS_VDA = new Entity_v_JIS_VDA(db);
|
|
Entity_v_JIS_VDA v_JIS_VDA = new Entity_v_JIS_VDA(db);
|
|
DataTable dtData = v_JIS_VDA.GetData(
|
|
"",
|
|
$"[AsnNumber]='{AsnNumber}' and [IsPrintLabel]=0",
|
|
"[PackageNo] asc").Tables[0];
|
|
|
|
if (dtData.Rows.Count == 0) throw new Exception("没有可打印的数据,如果需要请使用补打功能!");
|
|
|
|
LogID = F_JIS_Log.WriteLogsStart($"打印 {dtData.Rows.Count} 个VDA标签 {AsnNumber} ");
|
|
|
|
int ret = PrintLabel(dtData, new List<string> { "01", "02" });
|
|
|
|
t_JIS_VDA.Edit($"[IsPrintLabel]=1", $"[AsnNumber]='{AsnNumber}'");
|
|
|
|
db.Commit();
|
|
|
|
F_JIS_Log.WriteLogsEnd(LogID, true, "");
|
|
|
|
MyMessageBox.ShowInfoMessage($"{ret}个VDA标签打印完成!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (db != null) db.Rollback();
|
|
|
|
F_JIS_Log.WriteLogsEnd(LogID, false, ex.Message);
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
Gm_WMS.DataAccess.DataService.LocalDBService db = null;
|
|
try
|
|
{
|
|
if (this.dgrdView.SelectedRows.Count == 0) throw new Exception("请选择要打印的记录");
|
|
|
|
string AsnNumber = this.dgrdView.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
|
|
|
|
if (!MyMessageBox.ShowQuestion($"是否要打印 {AsnNumber} ?")) return;
|
|
|
|
db = new Gm_WMS.DataAccess.DataService.LocalDBService();
|
|
db.BeginTrans();
|
|
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA(db);
|
|
Entity_v_JIS_VDA v_JIS_VDA = new Entity_v_JIS_VDA(db);
|
|
|
|
DataSet dsData = v_JIS_VDA.GetData($"[AsnNumber]='{AsnNumber}'");
|
|
if (dsData.Tables[0].Rows.Count == 0)
|
|
throw new Exception($"{AsnNumber} 不存在");
|
|
|
|
if (dsData.Tables[0].Select("[IsPackingVerification]=False").Length > 0)
|
|
throw new Exception(AsnNumber + " 所属VDA未完成装箱校验");
|
|
|
|
if (dsData.Tables[0].Select("[IsPrintASN]=True").Length == dsData.Tables[0].Rows.Count)
|
|
throw new Exception(AsnNumber + " 已经打印过了");
|
|
|
|
// if (dsData.Tables[0].Select("[IsShipingVerification]=False").Length > 0)
|
|
// {
|
|
// throw new Exception(AsnNumber + " 有数据做发货校验");
|
|
// }
|
|
|
|
DateTime PrintASNTime = t_JIS_VDA.GetDateTime();
|
|
for (int i = 0; i < dsData.Tables[0].Rows.Count; i++)
|
|
{
|
|
dsData.Tables[0].Rows[i]["PrintASNTime"] = PrintASNTime;
|
|
}
|
|
|
|
t_JIS_VDA.Edit(
|
|
$"[PrintASNTime]='{PrintASNTime.ToString("yyyy-MM-dd HH:mm:ss")}', [IsPrintASN]=1",
|
|
$"[AsnNumber]='{AsnNumber}'");
|
|
|
|
|
|
//F_JIS5000_Print.WriteASN_VDA(db, dsData, AsnNumber);
|
|
|
|
PrintASN(dsData);
|
|
|
|
db.Commit();
|
|
try
|
|
{
|
|
UpdateGridView();
|
|
}
|
|
catch { }
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (db != null) db.Rollback();
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (db != null) db.EndTrans();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void PrintASN(DataSet dsData)
|
|
{
|
|
Entity_t_Location t_Location = new Entity_t_Location();
|
|
|
|
DataTable dtHead = new DataTable();
|
|
dtHead.Columns.Add("ASNNo");
|
|
dtHead.Columns.Add("ASNNo_New");
|
|
dtHead.Columns.Add("DNNumber");
|
|
dtHead.Columns.Add("Date");
|
|
dtHead.Columns.Add("Time");
|
|
dtHead.Columns.Add("DispatchDate");
|
|
dtHead.Columns.Add("DispatchTime");
|
|
dtHead.Columns.Add("PlantCode");
|
|
dtHead.Columns.Add("Address1");
|
|
dtHead.Columns.Add("Address2");
|
|
dtHead.Columns.Add("Address3");
|
|
dtHead.Columns.Add("SwetDate");
|
|
dtHead.Columns.Add("SwetTime");
|
|
|
|
DataRow drHead = dtHead.NewRow();
|
|
drHead["ASNNo"] = dsData.Tables[0].Rows[0]["AsnNumber"].ToString();
|
|
drHead["ASNNo_New"] = dsData.Tables[0].Rows[0]["AsnNumber"].ToString().Replace("ADT", "");
|
|
drHead["DNNumber"] = dsData.Tables[0].Rows[0]["AsnNumber"].ToString().Replace("ADT", "");
|
|
drHead["Date"] = Convert.ToDateTime(dsData.Tables[0].Rows[0]["LabelDate"]).ToString("dd.MM.yyyy");
|
|
drHead["Time"] = Convert.ToDateTime(dsData.Tables[0].Rows[0]["LabelDate"]).ToString("HH:mm:ss");
|
|
drHead["DispatchDate"] = Convert.ToDateTime(dsData.Tables[0].Rows[0]["PrintASNTime"]).ToString("dd.MM.yyyy");
|
|
drHead["DispatchTime"] = Convert.ToDateTime(dsData.Tables[0].Rows[0]["PrintASNTime"]).ToString("HH:mm:ss");
|
|
drHead["PlantCode"] = dsData.Tables[0].Rows[0]["fileType"].ToString();
|
|
|
|
DataTable dtLocation = t_Location.GetData("[Code]='" + dsData.Tables[0].Rows[0]["Location"].ToString() + "'").Tables[0];
|
|
if (dtLocation.Rows.Count > 0)
|
|
{
|
|
drHead["Address1"] = dtLocation.Rows[0]["Address1"].ToString();
|
|
drHead["Address2"] = dtLocation.Rows[0]["Address2"].ToString();
|
|
drHead["Address3"] = dtLocation.Rows[0]["Address3"].ToString();
|
|
}
|
|
drHead["SwetDate"] = Convert.ToDateTime(dsData.Tables[0].Rows[0]["Date"]).ToString("dd.MM.yyyy");
|
|
|
|
dtHead.Rows.Add(drHead);
|
|
|
|
MyReport6 report = new MyReport6(asn_file, dtHead, dsData.Tables[0]);
|
|
report.Report.Printer.PrinterName = MyAppconfig.ReadValue("默认打印机");
|
|
report.Report.Print(false);
|
|
}
|
|
|
|
private void btnPrintRe_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
try
|
|
{
|
|
if (this.dgrdView.SelectedRows.Count == 0) throw new Exception("请选择要补打的记录");
|
|
|
|
string ID = this.dgrdView.SelectedRows[0].Cells["ID"].Value.ToString();
|
|
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA();
|
|
Entity_v_JIS_VDA v_JIS_VDA = new Entity_v_JIS_VDA();
|
|
|
|
DataSet dsData = v_JIS_VDA.GetData("[ID]=" + ID);
|
|
if (dsData.Tables[0].Rows.Count == 0) throw new Exception("补打的ASN不存在");
|
|
if (!Convert.ToBoolean(dsData.Tables[0].Rows[0]["IsPrintASN"]))
|
|
throw new Exception("选择的记录未打印,不能补打");
|
|
|
|
string AsnNumber = dsData.Tables[0].Rows[0]["AsnNumber"].ToString();
|
|
|
|
if (!MyMessageBox.ShowQuestion("是否要补打 " + AsnNumber + " ?")) return;
|
|
|
|
dsData = v_JIS_VDA.GetData("[AsnNumber]='" + AsnNumber + "'");
|
|
|
|
|
|
PrintASN(dsData);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
|
|
private void btnPrintVDA_Click(object sender, EventArgs e)
|
|
{
|
|
PrintReLabel("01");
|
|
}
|
|
|
|
private void btnPrintVDARight_Click(object sender, EventArgs e)
|
|
{
|
|
PrintReLabel("02");
|
|
}
|
|
|
|
//补打VDA标签
|
|
private void PrintReLabel(string num)
|
|
{
|
|
string LogID = "0";
|
|
try
|
|
{
|
|
int n = this.dgrdView.SelectedRows.Count;
|
|
if (n == 0) throw new Exception("请选择要补打VDA标签的记录(可多选)");
|
|
if (!MyMessageBox.ShowQuestion($"是否要补打选择的【{n}】个VDA {num} 标签?")) return;
|
|
|
|
string AsnNumber = this.dgrdView.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
|
|
|
|
string ids = "";
|
|
for (int i = 0; i < this.dgrdView.SelectedRows.Count; i++)
|
|
{
|
|
ids += this.dgrdView.SelectedRows[i].Cells["ID"].Value.ToString() + ",";
|
|
}
|
|
if (ids.Length > 0) ids = ids.Substring(0, ids.Length - 1);
|
|
|
|
LogID = F_JIS_Log.WriteLogsStart($"补打{n}个VDA {num} 标签 {AsnNumber}");
|
|
Entity_v_JIS_VDA v_JIS_VDA = new Entity_v_JIS_VDA();
|
|
DataTable dtData = v_JIS_VDA.GetData($"[ID] in ({ids})").Tables[0];
|
|
if (dtData.Rows.Count == 0) throw new Exception("补打的记录不存在");
|
|
|
|
PrintLabel(dtData, new List<string> { num });
|
|
|
|
F_JIS_Log.WriteLogsEnd(LogID, true, "");
|
|
|
|
MyMessageBox.ShowInfoMessage("补打完成");
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
F_JIS_Log.WriteLogsEnd(LogID, false, ex.Message);
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
}
|
|
|
|
//打印VDA标签的(打印)函数
|
|
private int PrintLabel(DataTable dtData, List<string> lst_num)
|
|
{
|
|
Entity_t_Location t_Location = new Entity_t_Location();
|
|
|
|
DataTable dtPrint = dtData.Clone();
|
|
dtPrint.Columns.Add("Address1"); //左上角三行地址
|
|
dtPrint.Columns.Add("Address2");
|
|
dtPrint.Columns.Add("Address3");
|
|
dtPrint.Columns.Add("PackageNoNew"); //新的koli号,后面加“-01”或“-02”
|
|
dtPrint.Columns.Add("PackageNoNum"); //显示01或02
|
|
dtPrint.Columns.Add("AI"); //零件AI号,零件号的最后两位
|
|
|
|
int ret = 0;
|
|
foreach (DataRow drData in dtData.Rows)
|
|
{
|
|
foreach (string num in lst_num)
|
|
{
|
|
DataRow drNew = dtPrint.NewRow();
|
|
foreach (DataColumn dc in dtData.Columns)
|
|
{
|
|
drNew[dc.ColumnName] = drData[dc.ColumnName];
|
|
}
|
|
drNew["PackageNoNew"] = drData["PackageNo"].ToString() + "-" + num;
|
|
drNew["PackageNoNum"] = num;
|
|
drNew["AI"] = drData["PartNumber"].ToString().Substring(drData["PartNumber"].ToString().Length - 2, 2);
|
|
DataTable dtLocation = t_Location.GetData("[Code]='" + drData["Location"].ToString() + "'").Tables[0];
|
|
if (dtLocation.Rows.Count > 0)
|
|
{
|
|
drNew["Address1"] = dtLocation.Rows[0]["Address1"].ToString();
|
|
drNew["Address2"] = dtLocation.Rows[0]["Address2"].ToString();
|
|
drNew["Address3"] = dtLocation.Rows[0]["Address3"].ToString();
|
|
}
|
|
dtPrint.Rows.Add(drNew);
|
|
|
|
|
|
}
|
|
|
|
ret++;
|
|
}
|
|
|
|
|
|
string PrinterName = MyAppconfig.ReadValue("默认条码打印机");
|
|
string labelfile = Application.StartupPath + "\\Report\\VDA.grf";
|
|
|
|
MyReport6 report = new MyReport6(labelfile, new DataTable(), dtPrint);
|
|
report.Report.Printer.PrinterName = PrinterName;
|
|
report.Report.Print(false);
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
}
|
|
|
|
private void chkUpload_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (chkUpload.Checked)
|
|
{
|
|
this.dateTimePicker1.Enabled = false;
|
|
this.dateTimePicker2.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
this.dateTimePicker1.Enabled = true;
|
|
this.dateTimePicker2.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private static string CreatePartOutSql(LocalDBService db,string PartCode, decimal outQty, DataTable dt, string asnNum,out DataTable dtPartOutQty)
|
|
{
|
|
dtPartOutQty = dt;
|
|
string strsql = "";
|
|
if (dtPartOutQty.Select(" Code = '" + PartCode + "'").Length > 0)
|
|
{
|
|
//继续校验该ASN是否维护累计发货数量信息
|
|
if (dtPartOutQty.Select(" Code = '" + PartCode + "' and AsnNum = '" + asnNum + "'").Length > 0)
|
|
{
|
|
strsql = "Update t_PartOutQty" +
|
|
" set PartOutQty += " + outQty + "," +
|
|
" LastOutQty += " + outQty +
|
|
" where Code = '" + PartCode + "'" +
|
|
" and AsnNum = '" + asnNum + "'";
|
|
}
|
|
else
|
|
{
|
|
strsql = "Update t_PartOutQty" +
|
|
" set PartOutQty += " + outQty + "," +
|
|
" LastOutQty = " + outQty + "," +
|
|
" LastOutTime = getdate()," +
|
|
" AsnNum = '" + asnNum + "'" +
|
|
" where Code = '" + PartCode + "'";
|
|
db.Exec_NonQuery(strsql);
|
|
//DT重新赋值
|
|
strsql = "select * from t_PartOutQty";
|
|
dtPartOutQty = db.Exec_DataSet(strsql).Tables[0];
|
|
strsql = "";
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//该零件未维护累计发货数量信息
|
|
strsql = "Insert into t_PartOutQty(Code,PartOutQty,LastOutQty,LastOutTime,AsnNum) values ('" + PartCode + "'," + outQty + "," + outQty + ",getdate(),'"+ asnNum + "')";
|
|
db.Exec_NonQuery(strsql);
|
|
//DT重新赋值
|
|
strsql = "select * from t_PartOutQty";
|
|
dtPartOutQty = db.Exec_DataSet(strsql).Tables[0];
|
|
strsql = "";
|
|
}
|
|
|
|
return strsql;
|
|
}
|
|
}
|
|
}
|
|
|