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.
 
 
 
 

205 lines
7.0 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PDAForm.Comm;
namespace PDAForm.Bill.Move
{
public partial class frmMoveScan : PDAForm.Bill.frmBillScanBase
{
public bool IsTrayScan = false; //拼器具
public F_TrayCode TrayCode = null; //如果不为空,就是整器具移库
public frmMoveScan()
{
InitializeComponent();
}
public string GetName()
{
if (IsTrayScan)
{
return "器具";
}
else
{
return "库位";
}
}
private void frmMoveScan_Load(object sender, EventArgs e)
{
}
public override void ScanBarCode(string _BarCode)
{
TrayCode = null;
IsTrayScan = false;
if (_BarCode.ToUpper().Substring(0, 1) == "R") //整器具移库
{
TrayCode = new F_TrayCode(_BarCode);
if (TrayCode.dsPackage.Tables[0].Rows.Count == 0) throw new Exception("器具中没有打包记录!");
BarCode = new F_BarCode(TrayCode.dsPackage.Tables[0].Rows[0]["ProductCode"].ToString() +
TrayCode.dsPackage.Tables[0].Rows[0]["Batch"].ToString() + "0001");
this.ctrProduct1.BarCode = BarCode;
this.ctrProduct1.InitData();
this.txtQty.Text = TrayCode.dsPackage.Tables[0].Rows[0]["Qty"].ToString();
this.txtQty.ReadOnly = true;
this.label3.Text = "原库位:";
this.label4.Text = "目标库位:";
this.txtLocationCodeSource.Focus();
this.txtLocationCodeSource.SelectAll();
}
else
{
base.ScanBarCode(_BarCode);
if (Convert.ToInt32(this.ctrProduct1.drProduct["IsPackage"]) == 1)
IsTrayScan = true;
else
IsTrayScan = false;
this.txtQty.ReadOnly = false;
this.label3.Text = "原" + GetName() + ":";
this.label4.Text = "目标" + GetName() + ":";
if (m_Base.dsBill.Tables["BillHead"].Rows[0]["BillTypeU8Code"].ToString() == "MK_YCL001"
|| m_Base.dsBill.Tables["BillHead"].Rows[0]["BillTypeU8Code"].ToString() == "MK_YCL003"
|| m_Base.dsBill.Tables["BillHead"].Rows[0]["BillTypeU8Code"].ToString() == "MK_YCL004") //原材料合格移位到正常库位
{
this.txtLocationCodeSource.ReadOnly = true;
this.txtLocationCodeSource.Text = m_Base.GetCheckLocation(this.ctrProduct1.BarCode.Code);
}
if (m_Base.dsBill.Tables["BillHead"].Rows[0]["BillTypeU8Code"].ToString() == "MK_YCL002") //原材料不合格移位退货库位
{
this.txtLocationCodeSource.ReadOnly = true;
this.txtLocationCodeSource.Text = m_Base.GetCheckLocation(this.ctrProduct1.BarCode.Code);
this.txtLocationCodeDest.ReadOnly = true;
this.txtLocationCodeDest.Text = m_Base.GetReturnLocation(this.ctrProduct1.BarCode.Code);
}
if (BarCode.BarCode.Substring(0, 2) == "YT")
{
this.txtQty.Text = "1";
this.txtLocationCodeSource.Focus();
this.txtLocationCodeSource.SelectAll();
}
}
}
public override void ScanQty(int _Qty)
{
base.ScanQty(_Qty);
this.txtLocationCodeSource.Focus();
this.txtLocationCodeSource.SelectAll();
}
public override void Save()
{
base.Save();
string LocationCodeSource = this.txtLocationCodeSource.Text.Trim().ToUpper();
string LocationCodeDest = this.txtLocationCodeDest.Text.Trim().ToUpper();
if (LocationCodeSource == "")
{
MyMessageBox.ShowErrorMessage("原" + GetName() + "不能为空!");
this.txtLocationCodeSource.Focus();
return;
}
if (LocationCodeDest == "")
{
MyMessageBox.ShowErrorMessage("目标" + GetName() + "不能为空!");
this.txtLocationCodeDest.Focus();
return;
}
if (IsTrayScan)
{
if (LocationCodeSource.Substring(0, 1) != "R")
{
MyMessageBox.ShowErrorMessage("器具条码扫描不正确!");
this.txtLocationCodeSource.Focus();
this.txtLocationCodeSource.SelectAll();
return;
}
if (LocationCodeDest.Substring(0, 1) != "R")
{
MyMessageBox.ShowErrorMessage("器具条码扫描不正确!");
this.txtLocationCodeDest.Focus();
this.txtLocationCodeDest.SelectAll();
return;
}
}
DataRow drData = m_Base.dsBill.Tables["BillDetail"].NewRow();
drData["BillNo"] = m_Base.dsBill.Tables["BillHead"].Rows[0]["BillNo"].ToString();
if (TrayCode != null)
{
drData["TrayCode"] = TrayCode.dsPackage.Tables[0].Rows[0]["Code"].ToString();
}
else
{
drData["TrayCode"] = "";
}
drData["ProductCode"] = this.ctrProduct1.BarCode.Code;
drData["Batch"] = this.ctrProduct1.BarCode.Batch;
drData["Qty"] = this.txtQty.Text.Trim();
drData["LocationCodeSource"] = this.txtLocationCodeSource.Text.Trim();
drData["LocationCodeDest"] = this.txtLocationCodeDest.Text.Trim();
drData["BarCode"] = this.ctrProduct1.BarCode.BarCode.Substring(0, 2) == "YT" ? this.ctrProduct1.BarCode.BarCode : "";
m_Base.BillDetailAdd(drData);
this.txtBarCode.Text = "";
this.txtQty.Text = "";
this.txtLocationCodeSource.Text = "";
this.txtLocationCodeDest.Text = "";
this.ctrProduct1.Clear();
this.txtBarCode.Focus();
BarCode = null;
TrayCode = null;
}
private void txtLocationCodeSource_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.txtLocationCodeDest.Focus();
this.txtLocationCodeDest.SelectAll();
}
}
private void txtLocationCodeDest_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Enter)
{
Save();
}
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
this.txtLocationCodeDest.Focus();
this.txtLocationCodeDest.SelectAll();
}
}
}
}