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.
431 lines
16 KiB
431 lines
16 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.Standard;
|
|
using Gm_WMS.DataAccess.DataService;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
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 btnPrint_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");
|
|
|
|
#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
|
|
|
|
foreach (DataRow drData in dtData.Rows)
|
|
{
|
|
string Location = drData["Location"].ToString();
|
|
if (Location == "") throw new Exception("卸货点不能为空");
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
PackageNos += drVDA["PackageNo"].ToString() + ",";
|
|
}
|
|
|
|
}
|
|
|
|
MyMessageBox.ShowInfoMessage($"ASN编号:{AsnNumber}\r\n装箱单号:{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)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|