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.
683 lines
28 KiB
683 lines
28 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 Stone.Common;
|
|
using Stone.Entity;
|
|
using Stone.WinModule.JISData;
|
|
using Stone.WinBiz.Standard;
|
|
using Gm_WMS.DataAccess.DataService;
|
|
using iTextSharp.text.pdf;
|
|
using iTextSharp.text.pdf.parser;
|
|
|
|
namespace Stone.WinModule.Standard
|
|
{
|
|
public partial class frmJISVDA : Stone.WinModule.BasicData.frmBaseMain
|
|
{
|
|
public frmJISVDA()
|
|
{
|
|
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.dgrdView.MultiSelect = true;
|
|
}
|
|
|
|
|
|
public override void Search(string code)
|
|
{
|
|
|
|
string d1 = MyDateTime.Format(this.dateTimePicker1.Value, MyDateTimeType.Date);
|
|
string d2 = MyDateTime.Format(this.dateTimePicker2.Value, MyDateTimeType.Date);
|
|
|
|
|
|
if (code == "")
|
|
{
|
|
strWhere = "1=1";
|
|
}
|
|
else
|
|
{
|
|
strWhere = " [PartNumber] like '%" + code + "%' or ";
|
|
strWhere += " [Description] like '%" + code + "%' or ";
|
|
strWhere += " [releaseId] like '%" + code + "%' or ";
|
|
strWhere += " [location] like '%" + code + "%' or ";
|
|
strWhere += " [locationCode] like '%" + code + "%' or ";
|
|
strWhere += " [filename] like '%" + code + "%' ";
|
|
}
|
|
|
|
strWhere = "[IsStandard]=1 and [startDate]>='" + d1 + "' and [startDate]<='" + d2 + "' and (" + strWhere + ")";
|
|
|
|
}
|
|
|
|
private void frmJISLog_Load(object sender, EventArgs e)
|
|
{
|
|
timer1.Enabled = true;
|
|
timer2.Interval = 60 * 1000; //1分钟刷新一次
|
|
timer2.Enabled = true;
|
|
|
|
ToolStripButton btnPrint = new ToolStripButton("号码预分配");
|
|
btnPrint.Image = this.imageList1.Images[0];
|
|
btnPrint.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnPrint.Click += new EventHandler(btnPrint_Click);
|
|
this.toolStrip1.Items.Insert(0, btnPrint);
|
|
|
|
ToolStripButton btnAddVDAPrint = new ToolStripButton("增加VDA");
|
|
btnAddVDAPrint.Image = this.imageList1.Images[0];
|
|
btnAddVDAPrint.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnAddVDAPrint.Click += new EventHandler(btnAddVDAPrint_Click);
|
|
this.toolStrip1.Items.Insert(1, btnAddVDAPrint);
|
|
|
|
ToolStripButton btnImportPDFVDA = new ToolStripButton("VDA导入-已校验");
|
|
btnImportPDFVDA.Image = this.imageList1.Images[1];
|
|
btnImportPDFVDA.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnImportPDFVDA.Click += new EventHandler(btnImportVDA_Click);
|
|
this.toolStrip1.Items.Insert(1, btnImportPDFVDA);
|
|
|
|
ToolStripButton btnImportPDFVDA2 = new ToolStripButton("VDA导入-未校验");
|
|
btnImportPDFVDA2.Image = this.imageList1.Images[1];
|
|
btnImportPDFVDA2.TextImageRelation = TextImageRelation.ImageAboveText;
|
|
btnImportPDFVDA2.Click += new EventHandler(btnImportVDA2_Click);
|
|
this.toolStrip1.Items.Insert(1, btnImportPDFVDA2);
|
|
|
|
}
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
this.timer1.Enabled = false;
|
|
|
|
try
|
|
{
|
|
DataSet dsData = m_Base.entityView.GetDataDistinct("partNumber", "(" + strWhere + ") and [IsStandard]=1 and [description] is null", "partNumber");
|
|
if (dsData.Tables[0].Rows.Count > 0)
|
|
{
|
|
|
|
frmTodNowProduct frm = new frmTodNowProduct();
|
|
frm.dgrdView.DataSource = dsData.Tables[0];
|
|
Stone.Common.MyGridViewStyle.SetDataGridRowNumber(frm.dgrdView);
|
|
Stone.Common.MyGridViewStyle.SetDataGridMenuCommon(frm.dgrdView);
|
|
frm.ShowDialog();
|
|
frm.Dispose();
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
}
|
|
|
|
#region old bak 2022-03-16
|
|
|
|
private void btnAddVDAPrint_Click(object sender, EventArgs e)
|
|
{
|
|
LastAutoCheck = this.chkAuto.Checked;
|
|
|
|
|
|
this.chkAuto.Checked = false;
|
|
this.chkAuto.Update();
|
|
try
|
|
{
|
|
if (this.dgrdView.SelectedRows.Count == 0)
|
|
{
|
|
throw new Exception("请选择要打印的记录");
|
|
}
|
|
|
|
if (this.dgrdView.SelectedRows[0].Cells["PackNumer"].Value == DBNull.Value)
|
|
{
|
|
throw new Exception(
|
|
"零件号:" + this.dgrdView.SelectedRows[0].Cells["PartNumber"].Value +
|
|
"没有基础资料,请先添加基础资料"
|
|
);
|
|
}
|
|
|
|
if (this.dgrdView.SelectedRows[0].Cells["IsStandard"].Value.ToString() != "1")
|
|
{
|
|
throw new Exception(
|
|
"零件号:" + this.dgrdView.SelectedRows[0].Cells["PartNumber"].Value +
|
|
"不是Standard零件号,不能打印"
|
|
);
|
|
}
|
|
|
|
string id = this.dgrdView.SelectedRows[0].Cells["ID"].Value.ToString();
|
|
Entity_v_JIS_Lab_List v_JIS_Lab = new Entity_v_JIS_Lab_List();
|
|
DataTable dtData = v_JIS_Lab.GetData($"[ID]={id}").Tables[0];
|
|
if (dtData.Rows.Count == 0)
|
|
throw new Exception("选择的记录不存在,请刷新数据");
|
|
|
|
string PartNumber = dtData.Rows[0]["PartNumber"].ToString();
|
|
int quantity = Convert.ToInt32(dtData.Rows[0]["quantity"]); //本次需求货数量
|
|
int quantity_transit = Convert.ToInt32(dtData.Rows[0]["quantity_transit"]); //在途数量
|
|
|
|
if(quantity_transit > 0 )
|
|
{
|
|
if (quantity_transit > quantity)
|
|
{
|
|
if (!MyMessageBox.ShowQuestion($"零件号 {PartNumber} 在途数量 {quantity_transit} 大于本次需求数量 {quantity} ,是否要继续?"))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
else if (quantity_transit < quantity)
|
|
{
|
|
if (MyMessageBox.ShowQuestion($"零件号 {PartNumber} 在途数量 {quantity_transit},是否将本次需求数量由 {quantity} 改为 {quantity - quantity_transit}?"))
|
|
{
|
|
quantity = quantity - quantity_transit;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
frmVDAPrint frm = new frmVDAPrint();
|
|
frm.f_JIS_VDA = (F_JIS_VDA)m_Base;
|
|
frm.LocatioCode = dtData.Rows[0]["LocationCode"].ToString();
|
|
|
|
frm.txtreleaseId.Text = dtData.Rows[0]["releaseId"].ToString();
|
|
frm.txtDescription.Text = dtData.Rows[0]["Description"].ToString();
|
|
frm.txtLocation.Text = dtData.Rows[0]["location"].ToString();
|
|
frm.txtPartNumber.Text = dtData.Rows[0]["PartNumber"].ToString();
|
|
frm.txtPackNumer.Text = dtData.Rows[0]["PackNumer"].ToString();
|
|
frm.txtQty.Text = Convert.ToString(Convert.ToDecimal(quantity) / Convert.ToDecimal(dtData.Rows[0]["PackNumer"]));
|
|
frm.txtDate.Value = Convert.ToDateTime(dtData.Rows[0]["StartDate"]);
|
|
frm.txtStandardNo.Text = dtData.Rows[0]["OrderNumber"].ToString();
|
|
frm.ShowDialog();
|
|
frm.Dispose();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
this.chkAuto.Checked = LastAutoCheck;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
private bool LastAutoCheck = true;
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
LastAutoCheck = this.chkAuto.Checked;
|
|
|
|
|
|
this.chkAuto.Checked = false;
|
|
this.chkAuto.Update();
|
|
try
|
|
{
|
|
int count = this.dgrdView.SelectedRows.Count;
|
|
|
|
if (count == 0) throw new Exception("请选择要打印的记录,可按Shift或Ctrl多选");
|
|
|
|
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);
|
|
|
|
Entity_v_JIS_Lab_List v_JIS_Lab = new Entity_v_JIS_Lab_List();
|
|
DataTable dtData = v_JIS_Lab.GetData("*, quantity as quantity_new", $"[ID] in({ids})", "[PartNumber] asc").Tables[0];
|
|
if (dtData.Rows.Count == 0) throw new Exception("记录不存在");
|
|
|
|
|
|
string msg1 = "";
|
|
string msg2 = "";
|
|
foreach (DataRow drData in dtData.Rows)
|
|
{
|
|
if (drData["PackNumer"] == DBNull.Value)
|
|
{
|
|
throw new Exception(
|
|
"零件号:" + drData["PartNumber"].ToString() +
|
|
"没有基础资料,请先添加基础资料"
|
|
);
|
|
}
|
|
|
|
if (drData["IsStandard"].ToString() != "1")
|
|
{
|
|
throw new Exception(
|
|
"零件号:" + drData["PartNumber"].ToString() +
|
|
"不是STD零件号,不能打印"
|
|
);
|
|
}
|
|
|
|
string PartNumber = dtData.Rows[0]["PartNumber"].ToString();
|
|
int quantity = Convert.ToInt32(dtData.Rows[0]["quantity"]); //本次需求货数量
|
|
int quantity_transit = Convert.ToInt32(dtData.Rows[0]["quantity_transit"]); //在途数量
|
|
|
|
if (quantity_transit > 0)
|
|
{
|
|
if (quantity_transit > quantity)
|
|
{
|
|
msg1 += $"零件号 {PartNumber} 在途数量 {quantity_transit} 大于本次需求数量 {quantity}\r\n";
|
|
|
|
}
|
|
else if (quantity_transit < quantity)
|
|
{
|
|
msg2 += $"零件号 {PartNumber} 在途数量 {quantity_transit},是否将本次需求数量由 {quantity} 改为 {quantity - quantity_transit}\r\n";
|
|
|
|
drData["quantity_new"] = quantity - quantity_transit;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if (msg1 != "")
|
|
{
|
|
if (!MyMessageBox.ShowQuestionPop("以下询问是否继续?\r\n" + msg1))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
bool quantity_new = false; //是否采用新的数量来计算
|
|
if (msg2 != "")
|
|
{
|
|
if (MyMessageBox.ShowQuestionPop("以下询问是否继续?\r\n" + msg2))
|
|
{
|
|
quantity_new = true;
|
|
}
|
|
}
|
|
|
|
CreateVDA(dtData, quantity_new);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
this.chkAuto.Checked = LastAutoCheck;
|
|
}
|
|
}
|
|
|
|
//号码预分配
|
|
private void CreateVDA(DataTable dtData, bool quantity_new)
|
|
{
|
|
LocalDBService db = null;
|
|
try
|
|
{
|
|
db = new LocalDBService();
|
|
db.BeginTrans();
|
|
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA(db);
|
|
Entity_t_Product t_Product = new Entity_t_Product();
|
|
Entity_t_Location t_Location = new Entity_t_Location();
|
|
|
|
string fileType = ((F_JIS_VDA)m_Base).fileType;
|
|
string PackageNos = "";
|
|
string LabelDate = MyDateTime.GetServerDateTime().ToString("yyyy-MM-dd HH:mm");
|
|
string Date = MyDateTime.GetServerDateTime().ToString("yyyy-MM-dd");
|
|
string AsnNumbers = "";
|
|
|
|
List<PartOutQty> lsPartOutQty = new List<PartOutQty>();
|
|
|
|
var lstSql = new List<string>();
|
|
var strsql = "";
|
|
|
|
foreach (DataRow drData in dtData.Rows)
|
|
{
|
|
string Location = drData["Location"].ToString();
|
|
if (Location == "") throw new Exception("卸货点不能为空");
|
|
|
|
#region 取ASN号
|
|
|
|
DataTable dtASN = t_JIS_VDA.GetData(
|
|
$"top 1 *",
|
|
$"[fileType]='{fileType}' and [Location]='{Location}' and [IsUpload]=0",
|
|
$"[ID] desc").Tables[0];
|
|
|
|
string AsnNumber = "";
|
|
if (dtASN.Rows.Count > 0)
|
|
{
|
|
AsnNumber = dtASN.Rows[0]["AsnNumber"].ToString();
|
|
}
|
|
else
|
|
{
|
|
AsnNumber = F_JIS_VDA_ASN.GetVDA_AsnNumber(db, fileType, 3);
|
|
}
|
|
|
|
if (AsnNumber.Substring(0, 3) != "ADT")
|
|
{
|
|
throw new Exception("ASN编号 必需以[ADT]开头");
|
|
}
|
|
|
|
if (AsnNumber.Length != 13)
|
|
{
|
|
throw new Exception("ASN编号 必需13长");
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
int PageQty = 0; //整箱数量
|
|
int Odd = 0; //零头数量
|
|
|
|
if (!quantity_new) //是否计算在途
|
|
{
|
|
PageQty = Convert.ToInt32(Math.Floor(Convert.ToDecimal(drData["quantity"]) /
|
|
Convert.ToDecimal(drData["PackNumer"])));
|
|
|
|
Odd = Convert.ToInt32(drData["quantity"]) -
|
|
Convert.ToInt32(PageQty * Convert.ToInt32(drData["PackNumer"])); //计算零头
|
|
}
|
|
|
|
|
|
for (int i = 1; i <= PageQty; i++)
|
|
{
|
|
DataRow drVDA = t_JIS_VDA.Table.NewRow();
|
|
drVDA["fileType"] = fileType;
|
|
drVDA["LabelDate"] = LabelDate;
|
|
drVDA["Date"] = Date;
|
|
drVDA["PackageNo"] = F_JIS_VDA_ASN.GetVDA_PackNumber(db, "ADT9", 10);
|
|
drVDA["AsnNumber"] = AsnNumber;
|
|
drVDA["PartNumber"] = drData["PartNumber"].ToString();
|
|
drVDA["Qty"] = drData["PackNumer"].ToString();
|
|
drVDA["location"] = drData["Location"].ToString();
|
|
drVDA["OrderNumber"] = drData["OrderNumber"].ToString();
|
|
drVDA["LocationCode"] = drData["LocationCode"].ToString();
|
|
drVDA["releaseId"] = drData["releaseId"].ToString();
|
|
|
|
t_JIS_VDA.Add(drVDA);
|
|
//增加已发货数量
|
|
|
|
strsql = "Update t_PartOutQty" +
|
|
" set PartOutQty += " + decimal.Parse(drData["PackNumer"].ToString()) + "" +
|
|
" where Code = '" + drData["PartNumber"].ToString() + "'";
|
|
db.Exec_NonQuery(strsql);
|
|
PackageNos += drVDA["PackageNo"].ToString() + ",";
|
|
}
|
|
|
|
if(Odd > 0)
|
|
{
|
|
DataRow drVDA = t_JIS_VDA.Table.NewRow();
|
|
drVDA["fileType"] = fileType;
|
|
drVDA["LabelDate"] = LabelDate;
|
|
drVDA["Date"] = Date;
|
|
drVDA["PackageNo"] = F_JIS_VDA_ASN.GetVDA_PackNumber(db, "ADT9", 10);
|
|
drVDA["AsnNumber"] = AsnNumber;
|
|
drVDA["PartNumber"] = drData["PartNumber"].ToString();
|
|
drVDA["Qty"] = Odd;
|
|
drVDA["location"] = drData["Location"].ToString();
|
|
drVDA["OrderNumber"] = drData["OrderNumber"].ToString();
|
|
drVDA["LocationCode"] = drData["LocationCode"].ToString();
|
|
drVDA["releaseId"] = drData["releaseId"].ToString();
|
|
t_JIS_VDA.Add(drVDA);
|
|
|
|
//增加已发货数量
|
|
strsql = "Update t_PartOutQty" +
|
|
" set PartOutQty += " + Odd + "" +
|
|
" where Code = '" + drData["PartNumber"].ToString() + "'";
|
|
db.Exec_NonQuery(strsql);
|
|
PackageNos += drVDA["PackageNo"].ToString() + ",";
|
|
}
|
|
|
|
}
|
|
|
|
//MyMessageBox.ShowInfoMessage($"ASN编号:{AsnNumber}\r\n装箱单号:{PackageNos} 生成完成!");
|
|
MyMessageBox.ShowInfoMessage($"装箱单号:{PackageNos} 生成完成!");
|
|
|
|
db.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (db != null) db.Rollback();
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
if (db != null) db.EndTrans();
|
|
}
|
|
|
|
}
|
|
|
|
private void timer2_Tick(object sender, EventArgs e)
|
|
{
|
|
this.timer2.Enabled = false;
|
|
try
|
|
{
|
|
if (chkAuto.Checked)
|
|
{
|
|
UpdateGridView();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
this.timer2.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private void chkAuto_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btnImportVDA_Click(object sender, EventArgs e)
|
|
{
|
|
LastAutoCheck = this.chkAuto.Checked;
|
|
this.chkAuto.Checked = false;
|
|
this.chkAuto.Update();
|
|
try
|
|
{
|
|
LocalDBService db = null;
|
|
db = new LocalDBService();
|
|
db.BeginTrans();
|
|
OpenFileDialog dialog = new OpenFileDialog();
|
|
dialog.Filter = "PDF文件(*.PDF)|*.PDF|所有文件|*.*";
|
|
dialog.ValidateNames = true;
|
|
dialog.CheckPathExists = true;
|
|
dialog.CheckFileExists = true;
|
|
|
|
var dr = dialog.ShowDialog();
|
|
if (dr != DialogResult.OK) return;
|
|
|
|
string strFileName = dialog.FileName;
|
|
PdfReader pdfReader = new PdfReader(strFileName);
|
|
int numberOfPages = pdfReader.NumberOfPages;
|
|
//读取PDF文件 生成ASN信息 和VDA信息
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA(db);
|
|
string fileType = ((F_JIS_VDA)m_Base).fileType;
|
|
string LabelDate = MyDateTime.GetServerDateTime().ToString("yyyy-MM-dd HH:mm");
|
|
string Date = MyDateTime.GetServerDateTime().ToString("yyyy-MM-dd");
|
|
var packageNo = "";
|
|
var asnNum = "";
|
|
var partNumber = "";
|
|
var qty = "";
|
|
var location = "";
|
|
var orderNumber = "";
|
|
var locationCode = "";
|
|
|
|
|
|
for (int i = 1; i <= numberOfPages; ++i)
|
|
{
|
|
//获取PDF文件的文本内容
|
|
var strPage = PdfTextExtractor.GetTextFromPage(pdfReader, i);
|
|
var lstStr = strPage.Split(new[] { "\n" }, StringSplitOptions.None).ToList();
|
|
if ((i & 1) == 1)
|
|
{
|
|
packageNo = lstStr[32].Split(new[] {"\n", " "}, StringSplitOptions.None)[0];
|
|
asnNum = lstStr[10].Split(new[] { "\n", " " }, StringSplitOptions.None)[0];
|
|
partNumber = lstStr[16].Split(new[] { "\n", " " }, StringSplitOptions.None)[0];
|
|
qty = lstStr[23].Split(new[] { "\n", " " }, StringSplitOptions.None)[0].Split('.')[0];
|
|
var lstLoc = lstStr[27].Split(new[] {"\n", " "}, StringSplitOptions.None);
|
|
if (lstLoc.Length < 2)
|
|
{
|
|
throw new Exception("PDF文件中Location解析失败!");
|
|
}
|
|
//todo location 的取值需要确定
|
|
location = lstStr[4].Split(new[] { "\n", " " }, StringSplitOptions.None)[0];
|
|
//todo orderNumber 的取值需要确定
|
|
orderNumber = "";
|
|
//todo locationCode 的取值需要确定
|
|
locationCode = lstStr[4].Split(new[] { "\n", " " }, StringSplitOptions.None)[0];
|
|
// .Replace("SNP工厂", string.Empty);
|
|
DataRow drVDA = t_JIS_VDA.Table.NewRow();
|
|
drVDA["fileType"] = fileType;
|
|
drVDA["LabelDate"] = LabelDate;
|
|
drVDA["Date"] = Date;
|
|
drVDA["PackageNo"] = packageNo;
|
|
drVDA["AsnNumber"] = asnNum;
|
|
drVDA["PartNumber"] = partNumber;
|
|
drVDA["Qty"] = qty;
|
|
drVDA["location"] = location;
|
|
drVDA["OrderNumber"] = orderNumber;
|
|
drVDA["LocationCode"] = locationCode;
|
|
drVDA["releaseId"] = "";
|
|
drVDA["IsPrintLabel"] = 1;
|
|
drVDA["IsPackingVerification"] = 1;
|
|
drVDA["IsShipingVerification"] = 1;
|
|
drVDA["IsPrintASN"] = 1;
|
|
drVDA["IsUpload"] = 1;
|
|
drVDA["UploadTime"] = DateTime.Now;
|
|
drVDA["PrintASNTime"] = DateTime.Now;
|
|
t_JIS_VDA.Add(drVDA);
|
|
}
|
|
}
|
|
|
|
pdfReader.Close();
|
|
MyMessageBox.ShowInfoMessage($"VDA导入完成!");
|
|
db.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
this.chkAuto.Checked = LastAutoCheck;
|
|
}
|
|
}
|
|
|
|
private void btnImportVDA2_Click(object sender, EventArgs e)
|
|
{
|
|
LastAutoCheck = this.chkAuto.Checked;
|
|
this.chkAuto.Checked = false;
|
|
this.chkAuto.Update();
|
|
try
|
|
{
|
|
LocalDBService db = null;
|
|
db = new LocalDBService();
|
|
db.BeginTrans();
|
|
|
|
OpenFileDialog dialog = new OpenFileDialog();
|
|
dialog.Filter = "PDF文件(*.PDF)|*.PDF|所有文件|*.*";
|
|
dialog.ValidateNames = true;
|
|
dialog.CheckPathExists = true;
|
|
dialog.CheckFileExists = true;
|
|
|
|
var dr = dialog.ShowDialog();
|
|
if (dr != DialogResult.OK) return;
|
|
|
|
string strFileName = dialog.FileName;
|
|
PdfReader pdfReader = new PdfReader(strFileName);
|
|
int numberOfPages = pdfReader.NumberOfPages;
|
|
//读取PDF文件 生成ASN信息 和VDA信息
|
|
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA(db);
|
|
string fileType = ((F_JIS_VDA)m_Base).fileType;
|
|
string LabelDate = MyDateTime.GetServerDateTime().ToString("yyyy-MM-dd HH:mm");
|
|
string Date = MyDateTime.GetServerDateTime().ToString("yyyy-MM-dd");
|
|
var packageNo = "";
|
|
var asnNum = "";
|
|
var partNumber = "";
|
|
var qty = "";
|
|
var location = "";
|
|
var orderNumber = "";
|
|
var locationCode = "";
|
|
|
|
|
|
for (int i = 1; i <= numberOfPages; ++i)
|
|
{
|
|
//获取PDF文件的文本内容
|
|
var strPage = PdfTextExtractor.GetTextFromPage(pdfReader, i);
|
|
var lstStr = strPage.Split(new[] { "\n" }, StringSplitOptions.None).ToList();
|
|
if ((i & 1) == 1)
|
|
{
|
|
packageNo = lstStr[32].Split(new[] { "\n", " " }, StringSplitOptions.None)[0];
|
|
asnNum = lstStr[10].Split(new[] { "\n", " " }, StringSplitOptions.None)[0];
|
|
partNumber = lstStr[16].Split(new[] { "\n", " " }, StringSplitOptions.None)[0];
|
|
qty = lstStr[23].Split(new[] { "\n", " " }, StringSplitOptions.None)[0].Split('.')[0];
|
|
var lstLoc = lstStr[27].Split(new[] { "\n", " " }, StringSplitOptions.None);
|
|
if (lstLoc.Length < 2)
|
|
{
|
|
throw new Exception("PDF文件中Location解析失败!");
|
|
}
|
|
//todo location 的取值需要确定
|
|
location = lstStr[4].Split(new[] { "\n", " " }, StringSplitOptions.None)[0];
|
|
//todo orderNumber 的取值需要确定
|
|
orderNumber = "";
|
|
//todo locationCode 的取值需要确定
|
|
locationCode = lstStr[4].Split(new[] { "\n", " " }, StringSplitOptions.None)[0];
|
|
// .Replace("SNP工厂", string.Empty);
|
|
DataRow drVDA = t_JIS_VDA.Table.NewRow();
|
|
drVDA["fileType"] = fileType;
|
|
drVDA["LabelDate"] = LabelDate;
|
|
drVDA["Date"] = Date;
|
|
drVDA["PackageNo"] = packageNo;
|
|
drVDA["AsnNumber"] = asnNum;
|
|
drVDA["PartNumber"] = partNumber;
|
|
drVDA["Qty"] = qty;
|
|
drVDA["location"] = location;
|
|
drVDA["OrderNumber"] = orderNumber;
|
|
drVDA["LocationCode"] = locationCode;
|
|
drVDA["releaseId"] = "";
|
|
drVDA["IsPrintLabel"] = 1;
|
|
// drVDA["IsPackingVerification"] = 1;
|
|
// drVDA["IsShipingVerification"] = 1;
|
|
drVDA["IsPrintASN"] = 1;
|
|
// drVDA["IsUpload"] = 1;
|
|
// drVDA["UploadTime"] = DateTime.Now;
|
|
// drVDA["PrintASNTime"] = DateTime.Now;
|
|
t_JIS_VDA.Add(drVDA);
|
|
}
|
|
}
|
|
|
|
pdfReader.Close();
|
|
MyMessageBox.ShowInfoMessage($"VDA导入完成!");
|
|
db.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
this.chkAuto.Checked = LastAutoCheck;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改t_PartOutQty表的数量
|
|
/// </summary>
|
|
/// <param name="code">零件号</param>
|
|
/// <param name="qty">数量</param>
|
|
//public void UpdatePartOutQty(string code, int qty)
|
|
//{
|
|
// Entity_t_PartOutQty partOutQty = new Entity_t_PartOutQty();
|
|
// partOutQty.GetData()[]
|
|
// partOutQty.Edit(part, qty);
|
|
//}
|
|
|
|
struct PartOutQty
|
|
{
|
|
string partcode;
|
|
int qty;
|
|
}
|
|
}
|
|
}
|
|
|