using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
using gregn6Lib;
|
using SQLHelper;
|
using DBUtility;
|
using System.Threading;
|
using System.IO;
|
using Pub_Class;
|
|
namespace WarM
|
{
|
public partial class Kf_WeighToBarCode_StationOutBill : Form
|
{
|
public Kf_WeighToBarCode_StationOutBill()
|
{
|
InitializeComponent();
|
}
|
public frmBillQueryCondition_New frmCondition;
|
public string ModCaption = "涤纶半成品生成条码";
|
public const string ModName = "85";
|
public Int64 HInterID = 0;
|
public string HBillNo = "";
|
public string HBillType = "1202";
|
public Int64 HUnitID = 0;
|
public Int64 HSourceInterID = 0;
|
public Int64 HSourceEntryID = 0;
|
public string HSourceBillNo = "";
|
public string HSourceBillType = "";
|
public Int64 HProcessExchangeInterID = 0;
|
public Int64 HProcessExchangeEntryID = 0;
|
public Int64 HSupID = 0;
|
public double HSourceQty = 0;
|
public double HMaterWeight = 0; //物料克重
|
public string HCusMaterName = ""; //客户物料名称
|
public string HCusModel = ""; //客户规格型号
|
public string HMaker = DBUtility.ClsPub.CurUserName;
|
public Int64 HStockOrgID = DBUtility.ClsPub.HOrgID;
|
public DateTime HDate = DateTime.Today;
|
public long PrintQty = 0; //允许条码打印次数
|
public string PrintQtyCtl = ""; //条码打印次数控制
|
public string UpdatePrintQtyCtl = ""; //条码打印次数更新
|
public string sBarCodeItemID = ""; //条码自增列
|
public DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
|
#region //固定代码
|
|
//清空界面
|
public void Sub_ClearBill()
|
{
|
cmbHBarCodeType.Items.Clear();
|
cmbHBarCodeType.Items.Add("唯一条码");
|
DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
|
txtHBarCode.Text = "";
|
grdMain.DataSource = null;
|
grdSub.DataSource = null;
|
chkHDYFlag.Checked = true;
|
}
|
|
//窗体加载
|
private void Kf_WeighToBarCode_StationOutBill_Load(object sender, EventArgs e)
|
{
|
frmCondition = new frmBillQueryCondition_New();
|
this.Text = ModCaption;
|
Sub_GetSystemParameter();
|
}
|
|
private void initGrid()
|
{
|
DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name);
|
DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub");
|
}
|
|
//获取系统参数信息
|
private void Sub_GetSystemParameter()
|
{
|
//获取系统参数
|
ClsXt_SystemParameter oSystemParameter = new ClsXt_SystemParameter();
|
if (oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo) == false)
|
{
|
MessageBox.Show("获取系统参数失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
else
|
{
|
PrintQty = oSystemParameter.omodel.BarCode_PrintQty;
|
PrintQtyCtl = oSystemParameter.omodel.BarCode_PrintQtyCtl;
|
UpdatePrintQtyCtl = oSystemParameter.omodel.BarCode_UpdatePrintQtyCtl;
|
}
|
}
|
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
initGrid();
|
this.Sub_ClearBill();//清空界面
|
|
//获取条码ID
|
DataSet Ds = oCn.RunProcReturn("exec h_p_KF_GetBCPWeighSource_TempList '" + HMaker + "'," + HStockOrgID.ToString(), "h_p_KF_GetBCPWeighSource_TempList");
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo); //得到新单据ID
|
}
|
else if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HBack"]) == 1)
|
{
|
HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo); //得到新单据ID
|
}
|
else
|
{
|
HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
|
}
|
Source_Display();
|
BarCode_Display();
|
if (grdSub.Rows.Count > 0)
|
{
|
grdSub.Rows[0].Selected = true;
|
SourceBill();
|
txtHQty.Focus();
|
}
|
else
|
{
|
txtHBarCode.Focus();
|
}
|
}
|
|
private void grdMain_Paint(object sender, PaintEventArgs e)
|
{
|
GraphicsGrid();
|
}
|
|
private void GraphicsGrid()
|
{
|
DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
|
}
|
|
private void grdSub_Paint(object sender, PaintEventArgs e)
|
{
|
GraphicsGridSub();
|
}
|
|
private void GraphicsGridSub()
|
{
|
DBUtility.Xt_BaseBillFun.GraphicsGrid(grdSub);
|
}
|
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
|
}
|
|
private Int32 Fun_GetSubCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdSub);
|
}
|
|
//保存列宽
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub");
|
}
|
|
//默认列宽
|
private void mrlk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub");
|
}
|
|
#endregion
|
|
#region //刷新
|
|
private void sx_Click_1(object sender, EventArgs e)
|
{
|
timer1.Enabled = true;
|
}
|
|
#endregion
|
|
#region //打印
|
|
GridppReport Report;
|
|
private void dy_Click_1(object sender, EventArgs e)
|
{
|
//打印前判断条码是否超过允许可打印次数
|
if (ReportPrintBegin())
|
{
|
return;
|
}
|
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.Print(false);
|
Thread.Sleep(1000);
|
}
|
}
|
|
//打印前判断条码是否超过允许可打印次数
|
private bool ReportPrintBegin()
|
{
|
DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
string sHRemark = "";
|
sBarCodeItemID = "";
|
for (int i = 0; i < grdMain.SelectedRows.Count; i++)
|
{
|
sBarCodeItemID = sBarCodeItemID + "," + DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
|
}
|
sBarCodeItemID = sBarCodeItemID.Remove(0, 1);
|
|
if (PrintQtyCtl == "Y")
|
{
|
if (oBar.Set_CheckPrintQty(sBarCodeItemID, PrintQty, ref sHRemark))
|
{
|
MessageBox.Show(sHRemark);
|
return true;
|
}
|
return false;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
private void Sub_SetReport(string sOpenTmp)
|
{
|
//判断行数
|
for (int i = 0; i < grdMain.Rows.Count; i++)
|
{
|
grdMain.Rows[i].Cells[0].Value = "";
|
}
|
for (int i = 0; i < grdMain.SelectedRows.Count; i++)
|
{
|
grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[0].Value = "*";
|
}
|
//
|
Report = new GridppReport();
|
Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here .
|
Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
|
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
|
Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
|
}
|
|
//填入单据表头信息
|
private void ReportBeforePostRecord()//your report?kao
|
{
|
try
|
{
|
//Report.FieldByName("物料代码").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("物料代码")].Value.ToString();
|
//Report.FieldByName("物料名称").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("物料名称")].Value.ToString();
|
//Report.FieldByName("规格型号").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("规格型号")].Value.ToString();
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表头:" + e.Message);
|
}
|
}
|
|
//填入单据表体信息
|
private void ReportFetchRecordByDataTable()
|
{
|
try
|
{
|
DataTable ds = new DataTable();
|
BLL.Utility.FillRecordToReport_Sel(Report, grdMain, ds, Fun_GetCol("选择"));
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表体:" + e.Message);
|
}
|
}
|
|
//打印结束后回填条码打印次数
|
private void ReportPrintEnd()
|
{
|
DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
if (UpdatePrintQtyCtl == "Y")
|
{
|
oBar.Set_UpdatePrintQty(sBarCodeItemID);
|
}
|
}
|
|
#endregion
|
|
#region //生单
|
|
private void hb_Click(object sender, EventArgs e)
|
{
|
this.Sub_SaveBill();
|
timer1.Enabled = true;
|
}
|
|
private bool Sub_SaveBill()
|
{
|
//条码记录列表是否有记录判断
|
bool b = false;
|
for (int i = 0; i < grdMain.RowCount; i++)
|
{
|
b = true;
|
break;
|
}
|
if (b == false)
|
{
|
MessageBox.Show("当前条码记录列表无数据,不允许生成单据!", "提示");
|
return false;
|
}
|
|
//判断会计期是否合理
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
MessageBox.Show(s, "提示");
|
return false;
|
}
|
|
try
|
{
|
oCn.BeginTran();
|
DataSet Ds = oCn.RunProcReturn("exec h_p_KF_GetBCPWeighSource_StationOutBill " + HInterID.ToString(), "h_p_KF_GetBCPWeighSource_StationOutBill");
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
oCn.RollBack();
|
MessageBox.Show("生成工序出站汇报单失败,当前条码记录列表无数据!", "提示");
|
return false;
|
}
|
else
|
{
|
for (int y = 0; y < Ds.Tables[0].Rows.Count; y++)
|
{
|
Int64 sInterID = 0;
|
string sBillNo = "";
|
string sBillType = "3791";
|
sInterID = DBUtility.ClsPub.CreateBillID(sBillType, ref DBUtility.ClsPub.sExeReturnInfo); //得到新单据ID
|
sBillNo = DBUtility.ClsPub.CreateBillCode(sBillType, ref DBUtility.ClsPub.sExeReturnInfo, true); //得到新单据号
|
|
Int64 sHBarCodeInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HInterID"]);
|
Int64 sHMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HMaterID"]);
|
Int64 sHUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HUnitID"]);
|
string sHBatchNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[y]["HBatchNo"]);
|
Int64 sHSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HSupID"]);
|
Int64 sHGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HGroupID"]);
|
Int64 sHDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HDeptID"]);
|
Int64 sHProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HProcID"]);
|
Int64 sHCenterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HCenterID"]);
|
Int64 sHSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HSourceID"]);
|
Int64 sHProcNo = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HLayerNumber"]);
|
Double sHQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[y]["HQty"]);
|
Double sHICMOQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[y]["HReadyQty"]);
|
Int64 sHICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HSourceInterID"]);
|
Int64 sHICMOEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HSourceEntryID"]);
|
string sHICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[y]["HSourceBillNo"]);
|
Int64 sHProcExchInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HOrderInterID"]);
|
Int64 sHProcExchEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HOrderEntryID"]);
|
string sHProcExchBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[y]["HOrderBillNo"]);
|
|
//生成工序出站汇报单 (条码ID存入HMainInterID字段)
|
oCn.RunProc("Insert Into Sc_StationOutBillMain " +
|
"(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HMouldNum" +
|
",HYear,HPeriod,HRemark,HSourceName,HPieceQty,HWasterQty,HPlanPieceQty,HBadPNL" +
|
",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
|
",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID,HPayProcID" +
|
",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSourceID2,HSourceID3,HSourceID4,HSourceID5" +
|
",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" +
|
",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" +
|
",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID" +
|
",HPersonNums,HMachineNums,HEmpNum,HMainInterID,HPRDORGID" +
|
") " +
|
" values('" + sBillType + "','" + sBillType + "'," + sInterID.ToString() + ",'" + sBillNo + "',0,getdate(),'" + DBUtility.ClsPub.CurUserName + "',getdate(),''" +
|
"," + sYear.ToString() + "," + sPeriod.ToString() + ",'涤纶半成品生成条码模块生单生成','',0,0,0,0" +
|
"," + sHICMOInterID.ToString() + "," + sHICMOEntryID.ToString() + ",'" + sHICMOBillNo + "',0,0,''," + sHProcExchInterID.ToString() + "," + sHProcExchEntryID.ToString() +
|
",'" + sHProcExchBillNo + "'," + sHMaterID.ToString() + "," + sHProcID.ToString() + "," + sHICMOQty.ToString() + "," + sHICMOQty.ToString() + ",getdate()," + sHSourceID.ToString() + ",0" +
|
"," + sHGroupID.ToString() + "," + sHDeptID.ToString() + ",0,'','','',getdate(),0,0,0,0" +
|
"," + sHSupID.ToString() + "," + sHQty.ToString() + ",0,0,0," + sHCenterID.ToString() + "," + sHProcNo.ToString() + ",'',''" +
|
",0,'','',0" +
|
",0,0,0,0,0,0,0,0,0" +
|
",0,0,''," + sHBarCodeInterID.ToString() + "," + HStockOrgID.ToString() +
|
") ");
|
|
////回填流转卡关联数量
|
//oCn.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Out " + sInterID + ",1");
|
}
|
//回填已生单状态
|
oCn.RunProc("Update KF_BCPWeighSource_Temp set HRelationInterID=1 where HInterID= " + HInterID.ToString());
|
MessageBox.Show("生成工序出站汇报单成功!", "提示");
|
oCn.Commit();
|
return true;
|
}
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
MessageBox.Show("生成工序出站汇报单失败!" + e.Message);
|
return false;
|
}
|
}
|
|
#endregion
|
|
#region //退出
|
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
#endregion
|
|
#region //扫描条码
|
|
private void txtHBarCode_KeyPress(object sender, KeyPressEventArgs e)
|
{
|
if (e.KeyChar == (char)Keys.Return)
|
{
|
if (!AddSource())
|
{
|
txtHBarCode.Focus();
|
txtHBarCode.SelectAll();
|
return;
|
}
|
Source_Display();
|
grdSub.Rows[0].Selected = true;
|
DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
|
SourceBill();
|
txtHBarCode.Text = "";
|
txtHQty.Focus();
|
}
|
}
|
|
private void cmdOK_Click(object sender, EventArgs e)
|
{
|
if (!AddSource())
|
{
|
txtHBarCode.Focus();
|
txtHBarCode.SelectAll();
|
return;
|
}
|
Source_Display();
|
grdSub.Rows[0].Selected = true;
|
DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
|
SourceBill();
|
txtHBarCode.Text = "";
|
txtHQty.Focus();
|
}
|
|
private bool AddSource()
|
{
|
//将扫描单据号写入临时表
|
DataSet ds = oCn.RunProcReturn("exec h_p_Kf_AddSource_BCPWeighToBarCode " + HInterID.ToString() + ",'" + HBillNo + "','" + txtHBarCode.Text.Trim() + "','" + HMaker + "'," + HStockOrgID.ToString(), "h_p_Kf_AddSource_BCPWeighToBarCode");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("扫描条码写入临时表发生错误!", "提示");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 1)
|
{
|
MessageBox.Show(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]), "提示");
|
return false;
|
}
|
else
|
{
|
return true;
|
}
|
}
|
|
#endregion
|
|
#region //选单
|
|
private void cmdSourceBillNo_Click(object sender, EventArgs e)
|
{
|
//初始化右边表头信息
|
cmbHBarCodeType.Items.Clear();
|
cmbHBarCodeType.Items.Add("唯一条码");
|
DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
|
|
if (grdSub.CurrentRow == null)
|
{
|
MessageBox.Show("请在左边单据列表中选择一行单据!", "提示");
|
return;
|
}
|
else if (grdSub.SelectedRows.Count != 1)
|
{
|
MessageBox.Show("不允许同时选择多行单据,请重新选择单据!");
|
return;
|
}
|
else
|
{
|
SourceBill();
|
txtHQty.Focus();
|
}
|
}
|
|
#endregion
|
|
#region //保存
|
|
private void cmdSave_Click(object sender, EventArgs e)
|
{
|
if (!Sub_AllowSave())
|
{
|
return;
|
}
|
SaveBarCode();
|
BarCode_Display();
|
grdMain.Rows[0].Selected = true;
|
|
sBarCodeItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[0].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
|
//自动打印
|
if (chkHDYFlag.Checked == true)
|
{
|
//打印条码
|
Sub_SetReport("半成品条码");
|
Report.Print(false);
|
Thread.Sleep(1000);
|
}
|
else
|
{
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.Print(false);
|
Thread.Sleep(1000);
|
}
|
}
|
|
txtHQty.Text = "";
|
txtHWeightQyt.Text = "";
|
txtHBarcodeNo.Text = "";
|
txtHQty.Focus();
|
}
|
|
//条码生成前判断
|
private bool Sub_AllowSave()
|
{
|
//判断当前单据ID是否已上传生成单据
|
DataSet Ds = oCn.RunProcReturn("select top 1 1 from KF_BCPWeighSource_Temp with(nolock) where HInterID=" + HInterID.ToString() + " and HRelationInterID=1 ", "KF_BCPWeighSource_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
}
|
else
|
{
|
MessageBox.Show("当前条码记录已被上传生成单据,请退出后重新进入该模块进行条码生成操作!", "提示");
|
return false;
|
}
|
|
if (HInterID==0)
|
{
|
MessageBox.Show("获取条码对应单据ID失败,请重新刷新界面!", "提示");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(txtHMaterNumber.Tag) == 0)
|
{
|
MessageBox.Show("请先扫描工序流转卡号!", "提示");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isDoule(txtHQty.Text) == 0)
|
{
|
MessageBox.Show("请输入正确米数!", "提示");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isDoule(txtHWeightQyt.Text) == 0)
|
{
|
MessageBox.Show("请输入正确重量!", "提示");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isInt(txtHBarcodeNo.Text) == 0)
|
{
|
MessageBox.Show("请输入包号!", "提示");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(txtHProcID.Tag) == 0)
|
{
|
MessageBox.Show("工序不允许为空,请先输入流水号后回车确认!", "提示");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isInt(txtHProcNo.Text) == 0)
|
{
|
MessageBox.Show("请输入正确流水号!", "提示");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(txtHSourceID.Tag) == 0)
|
{
|
MessageBox.Show("生产资源不允许为空,请先选择生产资源!", "提示");
|
return false;
|
}
|
|
//实际克重=重量/米数*1000,实际克重超出物料维护克重的百分之二十或不足物料维护克重的百分之八十,预警提示
|
double sQty = 0; //实际克重
|
sQty = DBUtility.ClsPub.isDoule(txtHWeightQyt.Text) / DBUtility.ClsPub.isDoule(txtHQty.Text) * 1000;
|
|
if (sQty > HMaterWeight * 1.2 || sQty < HMaterWeight * 0.8)
|
{
|
if (MessageBox.Show("物料维护克重为:" + HMaterWeight.ToString() + ",实际克重为:" + sQty.ToString() + ",所输入实际克重超出物料维护克重的百分之二十或不足物料维护克重的百分之八十,请检查输入的数据是否正确!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
//return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
//条码生成前控制判断
|
double HNowQty = 0; //米数
|
double HWeightQyt = 0; //重量
|
HNowQty = DBUtility.ClsPub.isDoule(txtHQty.Text);
|
HWeightQyt = DBUtility.ClsPub.isDoule(txtHWeightQyt.Text);
|
|
DataSet oDsCheck = oCn.RunProcReturn("exec h_p_Kf_WeighToBarCode_StationOutBill_AddBarCodeCheck " + HInterID.ToString() + "," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + "," + HProcessExchangeInterID.ToString() + "," + HProcessExchangeEntryID.ToString() + "," + HSourceQty.ToString() + "," + HNowQty.ToString() + "," + HWeightQyt.ToString(), "h_p_Kf_WeighToBarCode_StationOutBill_AddBarCodeCheck");
|
//
|
if (oDsCheck == null && oDsCheck.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("条码生成前判断错误!");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0][0]) == "1")
|
{
|
MessageBox.Show(DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0]["HRemark"]), "提示");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0][0]) == "2")
|
{
|
if (MessageBox.Show(DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0]["HRemark"]), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
else
|
{
|
return true;
|
}
|
}
|
|
//生成条码
|
private void SaveBarCode()
|
{
|
int LSHlen = 6; //流水号长度
|
Int64 LSH = 0; //流水号
|
string LSH2 = ""; //流水号转换成字符
|
string HMaterID = ""; //物料内码
|
string HBatchNo = ""; //批次
|
string sDate = ""; //日期
|
string sYear = ""; //年
|
string sPeriod = ""; //月
|
string sDay = ""; //日
|
string sTMNumber = ""; //条码自定义前缀
|
string TM = ""; //条码编号
|
DataSet Ds;
|
|
HMaterID = DBUtility.ClsPub.isStrNull(txtHMaterNumber.Tag);
|
HBatchNo = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text);
|
//日期获取方式
|
sDate = dtpHDate.Value.ToShortDateString();
|
sYear = DBUtility.ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
|
sPeriod = "0" + DBUtility.ClsPub.isDate(sDate).Month.ToString();
|
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
|
sDay = "0" + DBUtility.ClsPub.isDate(sDate).Day.ToString();
|
sDay = sDay.Substring(sDay.Length - 2, 2);
|
//==================================
|
if (cmbHBarCodeType.Text == "唯一条码")
|
{
|
//条码前缀 = 组织代码 + 物料内码 + 年 + 月 + 日
|
sTMNumber = DBUtility.ClsPub.HOrgNumber + HMaterID + sYear + sPeriod + sDay;
|
Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //获取最大流水号
|
LSH = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
|
LSH = LSH + 1;
|
LSH2 = LSH.ToString();
|
while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0
|
{
|
LSH2 = "0" + LSH2;
|
}
|
TM = sTMNumber + LSH2;
|
}
|
else if (cmbHBarCodeType.Text == "品种条码")
|
{
|
TM = DBUtility.ClsPub.HOrgNumber + HMaterID;
|
}
|
else if (cmbHBarCodeType.Text == "批次条码")
|
{
|
TM = DBUtility.ClsPub.HOrgNumber + HMaterID + HBatchNo;
|
}
|
else
|
{
|
MessageBox.Show("错误的条码类型,不能生成条码!");
|
return;
|
}
|
|
string HBarCode = "";
|
string HBarCodeType = "";
|
Int64 HMaterID2 = 0;
|
double HQty = 0; //米数
|
double HMaterialJQty = 0; //重量
|
Int64 HGroupID = 0;
|
Int64 HDeptID = 0;
|
string HProcessExchangeBillNo = "";
|
Int64 HBarcodeNo = 0; //包数
|
string HMaterName = "";
|
string HMaterModel = "";
|
Int64 HProcID = 0;
|
Int64 HCenterID = 0;
|
Int64 HSourceID = 0;
|
Int64 HProcNo = 0;
|
|
HBarCode = TM;
|
HBarCodeType = DBUtility.ClsPub.isStrNull(cmbHBarCodeType.Text);
|
HMaterID2 = DBUtility.ClsPub.isLong(txtHMaterNumber.Tag);
|
HQty = DBUtility.ClsPub.isDoule(txtHQty.Text);
|
HMaterialJQty = DBUtility.ClsPub.isDoule(txtHWeightQyt.Text);
|
HGroupID = DBUtility.ClsPub.isLong(txtHGroupID.Tag);
|
HDeptID = DBUtility.ClsPub.isLong(txtHDeptName.Tag);
|
HProcessExchangeBillNo = DBUtility.ClsPub.isStrNull(txtHBillNo.Text);
|
HBarcodeNo = DBUtility.ClsPub.isLong(txtHBarcodeNo.Text);
|
HMaterName = DBUtility.ClsPub.isStrNull(txtHMaterName.Text);
|
HMaterModel = DBUtility.ClsPub.isStrNull(txtHMaterModel.Text);
|
HProcID = DBUtility.ClsPub.isLong(txtHProcID.Tag);
|
HCenterID = DBUtility.ClsPub.isLong(txtHCenterID.Tag);
|
HSourceID = DBUtility.ClsPub.isLong(txtHSourceID.Tag);
|
HProcNo = DBUtility.ClsPub.isLong(txtHProcNo.Text);
|
|
try
|
{
|
oCn.BeginTran();
|
//写入条码档案 (客户物料名称HCusMaterName存入HMaterialModel字段,客户规格型号HCusModel存入HCusModel字段,流水号存入HLayerNumber字段,源单数量存入HReadyQty字段)
|
oCn.RunProc("Insert into Gy_BarCodeBill " +
|
"(HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
|
",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
|
",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
|
",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate,HMaterialJQty,HMaterialMQty " +
|
",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HGiveAwayFlag " +
|
",HOrderInterID,HOrderEntryID,HOrderBillNo,HCustomQty1,HMaterialModel,HCusModel " +
|
",HProcID,HCenterID,HSourceID,HLayerNumber,HReadyQty " +
|
",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HLogo " +
|
") Values ("
|
+ " '" + HBarCode + "','" + HBarCodeType + "'," + HMaterID2.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
|
+ ",'" + HBatchNo + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + HMaker + "',getdate(),0," + HQty.ToString()
|
+ ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "',''"
|
+ ", 1," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + ",0,0,''"
|
+ ", 0,'',getdate(),'','" + sDate + "'," + HMaterialJQty.ToString() + ",0"
|
+ ", " + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",''," + HInterID.ToString() + ",0"
|
+ ", " + HProcessExchangeInterID.ToString() + "," + HProcessExchangeEntryID.ToString() + ",'" + HProcessExchangeBillNo + "',0,'" + HCusMaterName + "','" + HCusModel + "'"
|
+ ", " + HProcID.ToString() + "," + HCenterID.ToString() + "," + HSourceID.ToString() + "," + HProcNo.ToString() + "," + HSourceQty.ToString()
|
+ ",'" + HMaterName + "','" + HMaterModel + "','',0,'','','1')");
|
|
//回填最大流水号
|
oCn.RunProc("exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "',1 ");
|
//回填源单临时表HInterID
|
oCn.RunProc("update a set a.HInterID=" + HInterID.ToString() + ",a.HRelationInterID= 0 from KF_BCPWeighSource_Temp a where a.HInterID<>" + HInterID.ToString() + " and a.HMaker='" + HMaker + "' and a.HSourceBillNo='" + HProcessExchangeBillNo + "'");
|
oCn.Commit();
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
MessageBox.Show("条码生成失败!" + e.Message);
|
}
|
}
|
|
#endregion
|
|
#region //返回信息
|
|
//返回源单列表信息
|
private void SourceBill()
|
{
|
txtHBillNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("单据号")].Value);
|
txtHDeptName.Tag = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HDeptID")].Value);
|
txtHDeptName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("车间")].Value);
|
txtHMaterNumber.Tag = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HMaterID")].Value);
|
txtHMaterNumber.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("物料代码")].Value);
|
txtHMaterName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("物料名称")].Value);
|
txtHMaterModel.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("规格型号")].Value);
|
txtHBatchNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("批号")].Value);
|
txtHICMOBillNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("生产订单")].Value);
|
HUnitID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HUnitID")].Value);
|
HSourceInterID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceInterID")].Value);
|
HSourceEntryID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceEntryID")].Value);
|
HSourceBillNo = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("生产订单")].Value);
|
HSourceBillType = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceBillType")].Value);
|
HSourceQty = DBUtility.ClsPub.isDoule(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("数量")].Value);
|
HProcessExchangeInterID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HProcessExchangeInterID")].Value);
|
HSupID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSupID")].Value);
|
HMaterWeight = DBUtility.ClsPub.isDoule(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HMaterWeight")].Value);
|
HCusMaterName = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HCusMaterName")].Value);
|
HCusModel = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HCusModel")].Value);
|
}
|
|
//返回源单列表信息
|
private void Source_Display()
|
{
|
DataSet DSet = oCn.RunProcReturn("exec h_p_KF_GetBCPWeighSource_TempList '" + HMaker + "'," + HStockOrgID.ToString(), "h_p_KF_GetBCPWeighSource_TempList");
|
grdSub.DataSource = DSet.Tables[0].DefaultView;
|
//冻结
|
int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
|
string s = frmCondition.cmbHComplete.Text;
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol);
|
//画线
|
GraphLine();
|
}
|
|
//返回条码记录列表信息
|
private void BarCode_Display()
|
{
|
DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " order by HItemID desc", "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
|
grdMain.DataSource = DSet.Tables[0].DefaultView;
|
//冻结
|
int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
|
string s = frmCondition.cmbHComplete.Text;
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol);
|
//画线
|
GraphLine();
|
}
|
|
private void GraphLine()
|
{
|
int MainIDCol = Fun_GetCol("hmainid");
|
int SubIDCol = Fun_GetCol("hsubid");
|
string s = frmCondition.cmbHComplete.Text;
|
long n = 0;
|
DBUtility.Xt_BaseBillFun.GraphLine(grdMain, MainIDCol, SubIDCol, s, ref n);
|
|
int MainIDCol2 = Fun_GetSubCol("hmainid");
|
int SubIDCol2 = Fun_GetSubCol("hsubid");
|
string s2 = frmCondition.cmbHComplete.Text;
|
long n2 = 0;
|
DBUtility.Xt_BaseBillFun.GraphLine(grdSub, MainIDCol2, SubIDCol2, s2, ref n2);
|
}
|
|
#endregion
|
|
#region //作废
|
private void cmdZF_Click(object sender, EventArgs e)
|
{
|
if (grdMain.CurrentRow == null)
|
{
|
MessageBox.Show("请先选择需要作废的条码!", "提示");
|
return;
|
}
|
else
|
{
|
if (MessageBox.Show("确定要作废所选条码?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
{
|
return;
|
}
|
else
|
{
|
string HRemark = "";
|
string HItemID = "";
|
string HBarCode = "";
|
string HBarCode2 = "";
|
for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
|
{
|
HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
|
HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value) + "'";
|
if (i != 0 && i % 100 == 0)
|
{
|
HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
|
}
|
else
|
{
|
HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
|
}
|
if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("作废标记")].Value) != "")
|
{
|
HRemark = HRemark + "、" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
|
}
|
}
|
if (HRemark != "")
|
{
|
MessageBox.Show("所选条码编号:"+ HRemark.Remove(0, 1)+" 已作废,不允许重复作废!", "提示");
|
return;
|
}
|
HItemID = HItemID.Remove(0, 1); //去掉字符串第一个字符
|
HBarCode = HBarCode.Remove(0, 1);
|
HBarCode2 = HBarCode2.Remove(0, 1);
|
|
try
|
{
|
oCn.BeginTran();
|
string[] NewBarCode;
|
NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
|
|
//作废条码
|
oCn.RunProc("update Gy_BarCodeBill set HStopflag=1,HDeleteMan='" + DBUtility.ClsPub.CurUserName + "',HDeleteDate=getdate() where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//写入系统日志
|
for (int i = 0; i <= NewBarCode.Length - 1; i++)
|
{
|
oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','作废条码:" + NewBarCode[i] + "','涤纶半成品生成条码模块','" + DBUtility.ClsPub.IPAddress + "','作废'", ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
oCn.Commit();
|
}
|
catch (Exception e2)
|
{
|
oCn.RollBack();
|
MessageBox.Show("作废条码失败!" + e2.Message, "提示");
|
return;
|
}
|
//刷新条码记录列表信息
|
BarCode_Display();
|
MessageBox.Show("所选条码编号:" + HBarCode.Remove(0, 1) + " 作废成功!", "提示");
|
}
|
}
|
}
|
|
#endregion
|
|
#region //反作废
|
private void cmdFZF_Click(object sender, EventArgs e)
|
{
|
if (grdMain.CurrentRow == null)
|
{
|
MessageBox.Show("请先选择需要反作废的条码!", "提示");
|
return;
|
}
|
else
|
{
|
if (MessageBox.Show("确定要反作废所选条码?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
{
|
return;
|
}
|
else
|
{
|
string HRemark = "";
|
string HItemID = "";
|
string HBarCode = "";
|
string HBarCode2 = "";
|
for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
|
{
|
HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
|
HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value) + "'";
|
if (i != 0 && i % 100 == 0)
|
{
|
HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
|
}
|
else
|
{
|
HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
|
}
|
if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("作废标记")].Value) == "")
|
{
|
HRemark = HRemark + "、" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
|
}
|
}
|
if (HRemark != "")
|
{
|
MessageBox.Show("所选条码编号:" + HRemark.Remove(0, 1) + " 未作废,不允许反作废!", "提示");
|
return;
|
}
|
HItemID = HItemID.Remove(0, 1); //去掉字符串第一个字符
|
HBarCode = HBarCode.Remove(0, 1);
|
HBarCode2 = HBarCode2.Remove(0, 1);
|
|
try
|
{
|
oCn.BeginTran();
|
string[] NewBarCode;
|
NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
|
|
//反作废条码
|
oCn.RunProc("update Gy_BarCodeBill set HStopflag=0,HDeleteMan='',HDeleteDate=null where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
|
//写入系统日志
|
for (int i = 0; i <= NewBarCode.Length - 1; i++)
|
{
|
oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','反作废条码:" + NewBarCode[i] + "','涤纶半成品生成条码模块','" + DBUtility.ClsPub.IPAddress + "','反作废'", ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
oCn.Commit();
|
}
|
catch (Exception e2)
|
{
|
oCn.RollBack();
|
MessageBox.Show("反作废条码失败!" + e2.Message, "提示");
|
return;
|
}
|
//刷新条码记录列表信息
|
BarCode_Display();
|
MessageBox.Show("所选条码编号:" + HBarCode.Remove(0, 1) + " 反作废成功!", "提示");
|
}
|
}
|
}
|
|
|
#endregion
|
|
#region //流水号扫描
|
private void txtHProcNo_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Return)
|
{
|
if (DBUtility.ClsPub.isLong(txtHProcNo.Text) == 0)
|
{
|
MessageBox.Show("流水号为空或所输入流水号不正确,请重新输入流水号!");
|
return;
|
}
|
//根据转卡主ID、流水号带出流转卡上相应工序、班组、工作中心、生产资源
|
DataSet Ds = oCn.RunProcReturn("exec h_p_KF_GetBCPWeighSource_HProcNo2 " + HProcessExchangeInterID.ToString() + "," + DBUtility.ClsPub.isLong(txtHProcNo.Text) + ",'" + DBUtility.ClsPub.CurUserID + "'", "h_p_KF_GetBCPWeighSource_HProcNo2");
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
txtHProcNo.Text = "";
|
txtHProcID.Tag = 0;
|
txtHProcID.Text = "";
|
txtHCenterID.Tag = 0;
|
txtHCenterID.Text = "";
|
txtHGroupID.Tag = 0;
|
txtHGroupID.Text = "";
|
txtHSourceID.Tag = 0;
|
txtHSourceID.Text = "";
|
MessageBox.Show("所输入流水号不在当前工序流转卡下或用户未关联该流水号所对应相关工序,请重新输入流水号!");
|
return;
|
}
|
else
|
{
|
HProcessExchangeEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceEntryID"]);
|
txtHProcNo.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcNo"]);
|
txtHProcID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcID"]);
|
txtHProcID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcName"]);
|
txtHCenterID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCenterID"]);
|
txtHCenterID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCenterName"]);
|
txtHGroupID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]);
|
txtHGroupID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HGroupName"]);
|
txtHSourceID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]);
|
txtHSourceID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceName"]);
|
}
|
}
|
}
|
|
#endregion
|
|
#region //工序选择
|
|
private void cmdHProcID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Process_View oProcess = new DAL.ClsGy_Process_View();
|
if (oProcess.RefreshView())
|
{
|
this.txtHProcID.Text = oProcess.oModel.HName;
|
this.txtHProcID.Tag = oProcess.oModel.HItemID.ToString();
|
}
|
|
if(oProcess.oModel.HItemID!=0 && HProcessExchangeInterID != 0)
|
{
|
//根据转卡主ID、工序带出流转卡上相应流水号、班组、工作中心、生产资源
|
DataSet Ds = oCn.RunProcReturn("exec h_p_KF_GetBCPWeighSource_ProcID " + HProcessExchangeInterID.ToString() + "," + oProcess.oModel.HItemID.ToString(), "h_p_KF_GetBCPWeighSource_ProcID");
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
this.txtHProcID.Text = "";
|
this.txtHProcID.Tag = 0;
|
MessageBox.Show("所选工序不在当前工序流转卡下,请重新选择正确工序!");
|
return;
|
}
|
else
|
{
|
HProcessExchangeEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceEntryID"]);
|
txtHProcNo.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcNo"]);
|
txtHCenterID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCenterID"]);
|
txtHCenterID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCenterName"]);
|
txtHGroupID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]);
|
txtHGroupID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HGroupName"]);
|
txtHSourceID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]);
|
txtHSourceID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceName"]);
|
}
|
}
|
}
|
|
private void txtHProcID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHProcID);
|
}
|
|
#endregion
|
|
#region //生产资源选择
|
|
private void txtHSourceID_KeyPress(object sender, KeyPressEventArgs e)
|
{
|
if (e.KeyChar == (char)Keys.Return)
|
{
|
if (DBUtility.ClsPub.isStrNull(txtHSourceID.Text) != "")
|
{
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
if (oSource.GetInfoByID(DBUtility.ClsPub.isLong(txtHSourceID.Text.Replace("HCX", ""))))
|
{
|
txtHSourceID.Text = oSource.omodel.HName;
|
txtHSourceID.Tag = oSource.omodel.HItemID;
|
}
|
else
|
{
|
txtHSourceID.Text = "";
|
txtHSourceID.Tag = 0;
|
}
|
}
|
else
|
{
|
txtHSourceID.Text = "";
|
txtHSourceID.Tag = 0;
|
}
|
}
|
}
|
|
private void txtHSourceID_Click(object sender, EventArgs e)
|
{
|
txtHSourceID.SelectAll();
|
}
|
|
private void txtHSourceID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHSourceID);
|
}
|
|
private void cmdHSourceID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
if (oSource.RefreshView())
|
{
|
txtHSourceID.Text = oSource.oModel.HName;
|
txtHSourceID.Tag = oSource.oModel.HItemID.ToString();
|
}
|
else
|
{
|
txtHSourceID.Text = "";
|
}
|
}
|
|
#endregion
|
|
#region //生产班组选择
|
|
private void cmdHGroupID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View();
|
if (oGroup.RefreshView())
|
{
|
txtHGroupID.Text = oGroup.oModel.HName;
|
txtHGroupID.Tag = oGroup.oModel.HItemID.ToString();
|
}
|
else
|
{
|
txtHGroupID.Text = "";
|
}
|
}
|
|
private void txtHGroupID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHGroupID);
|
}
|
|
#endregion
|
|
#region //工作中心选择
|
|
private void cmdHCenterID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_WorkCenter_View oWorkCenter = new DAL.ClsGy_WorkCenter_View();
|
if (oWorkCenter.RefreshView())
|
{
|
txtHCenterID.Text = oWorkCenter.oModel.HName;
|
txtHCenterID.Tag = oWorkCenter.oModel.HItemID.ToString();
|
}
|
else
|
{
|
txtHCenterID.Text = "";
|
}
|
}
|
|
private void txtHCenterID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHCenterID);
|
}
|
|
|
#endregion
|
}
|
}
|