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.

167 lines
5.3 KiB

3 years ago
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.WinBiz.JISAdmin;
using Stone.WinBiz.Standard;
namespace Stone.WinModule.Standard
{
public partial class frmVDAPrint : Form
{
public Stone.WinBiz.Standard.F_JIS_VDA f_JIS_VDA = null;
public string LocatioCode = "";
public frmVDAPrint()
{
InitializeComponent();
}
private void frmVDAPrint_Load(object sender, EventArgs e)
{
try
{
string Location = this.txtLocation.Text.Trim();
if (Location == "")
throw new Exception("卸货点不能为空");
Entity_t_JIS_VDA t_JIS_VDA = new Entity_t_JIS_VDA();
DataSet dsData = t_JIS_VDA.GetData(
$"top 1 *",
$"[fileType]='{f_JIS_VDA.fileType}' and [Location]='{Location}' and [IsUpload]=0",
$"[ID] desc");
if (dsData.Tables[0].Rows.Count > 0)
{
this.txtAsnNumber.Text = dsData.Tables[0].Rows[0]["AsnNumber"].ToString();
}
else
{
this.txtAsnNumber.Text = F_JIS_VDA_ASN.GetVDA_AsnNumberPre(f_JIS_VDA.fileType, 3);
}
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void btnPrint_Click(object sender, EventArgs e)
{
this.btnPrint.Enabled = false;
this.btnPrint.Update();
string PackageNos = "";
Gm_WMS.DataAccess.DataService.LocalDBService db = null;
try
{
if (!MyValidator.IsEmpty(this.txtAsnNumber, "")) return;
if (!MyValidator.IsEmpty(this.txtPackNumer, "")) return;
if (!MyValidator.IsNumeric(this.txtPackNumer, "")) return;
if (!MyValidator.IsEmpty(this.txtQty, "")) return;
if (!MyValidator.IsNumeric(this.txtQty, "")) return;
db = new Gm_WMS.DataAccess.DataService.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 Location = this.txtLocation.Text.Trim();
if (Location == "")
throw new Exception("卸货点不能为空");
DataSet dsData = t_JIS_VDA.GetData(
$"top 1 *",
$"[fileType]='{f_JIS_VDA.fileType}' and [Location]='{Location}' and [IsUpload]=0",
$"[ID] desc");
if (dsData.Tables[0].Rows.Count > 0)
{
this.txtAsnNumber.Text = dsData.Tables[0].Rows[0]["AsnNumber"].ToString();
}
else
{
this.txtAsnNumber.Text = F_JIS_VDA_ASN.GetVDA_AsnNumber(db, f_JIS_VDA.fileType, 3);
}
string AsnNumber = this.txtAsnNumber.Text.Trim().ToUpper();
if (AsnNumber.Substring(0, 3) != "ADT")
{
throw new Exception("ASN编号 必需以[ADT]开头");
}
if (AsnNumber.Length != 13)
{
throw new Exception("ASN编号 必需13长");
}
int PageQty = Convert.ToInt32(this.txtQty.Text.Trim());
for (int i = 1; i <= PageQty; i++)
{
DataRow drVDA = t_JIS_VDA.Table.NewRow();
drVDA["fileType"] = f_JIS_VDA.fileType;
drVDA["LabelDate"] = this.txtLabelDate.Value.ToString("yyyy-MM-dd HH:mm");
drVDA["Date"] = this.txtDate.Value.ToString("yyyy-MM-dd");
drVDA["PackageNo"] = F_JIS_VDA_ASN.GetVDA_PackNumber(db, "ADT9", 10);
drVDA["AsnNumber"] = AsnNumber;
drVDA["PartNumber"] = this.txtPartNumber.Text.Trim();
drVDA["Qty"] = this.txtPackNumer.Text.Trim();
drVDA["location"] = this.txtLocation.Text.Trim();
drVDA["OrderNumber"] = this.txtStandardNo.Text.Trim();
drVDA["LocationCode"] = LocatioCode;
drVDA["releaseId"] = this.txtreleaseId.Text;
t_JIS_VDA.Add(drVDA);
PackageNos += drVDA["PackageNo"].ToString() + ",";
}
db.Commit();
MyMessageBox.ShowInfoMessage($"ASN编号:{AsnNumber}\r\n装箱单号:{PackageNos} 生成完成!");
this.Close();
}
catch (Exception ex)
{
if (db != null) db.Rollback();
MyMessageBox.ShowErrorMessage(ex.Message);
}
finally
{
if (db != null) db.EndTrans();
this.btnPrint.Enabled = true;
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}