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 Pub_Class;
|
using SQLHelper;
|
|
namespace WorkM
|
{
|
public partial class MES_StationInBill : Form
|
{
|
public MES_StationInBill()
|
{
|
InitializeComponent();
|
}
|
public string ModName = "3790";
|
public string ModCaption = "进站接收单";
|
public const string ModRightName = "MES_StationInBill";
|
public const string ModRightNameEdit = ModRightName + "_Edit";
|
public const string ModRightNameDelete = ModRightName + "_Delete";
|
public bool BillChange; //
|
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
public Int64 KeyID;
|
public bool grdStatus;
|
public DAL.ClsSc_StationInBill BillNew = new DAL.ClsSc_StationInBill();
|
public DAL.ClsSc_StationInBill BillOld = new DAL.ClsSc_StationInBill();
|
|
public Int64 lngBillKey;
|
public Int64 lngBillSubKey;
|
|
public Int64 lngICMOEntryID;
|
//-------------------------------------------------------------------------
|
#region 固定代码
|
|
|
//清空界面
|
public void Sub_ClearBill()
|
{
|
DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
|
DBUtility.Xt_BaseBillFun.Sub_ClearBill1(tabPage1);
|
DBUtility.Xt_BaseBillFun.Sub_ClearBill1(tabPage2);
|
initGrid();
|
txtHBarCode.Text = "";
|
txtHProcExchBillNo.Enabled = true;
|
txtHProcNo.Enabled = true;
|
txtHBarCode.Enabled = true;
|
tabControl1.SelectedIndex = 0;
|
txtHBarCode.Focus();
|
//得到接收人信息(进站接收人默认为登录人,根据登录人用户名,找到职员同名的记录,默认写入 接收人 文本框;如果没找到则为空;)
|
DataSet Ds;
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
Ds = oCn.RunProcReturn("select top 1 HItemID,HName from Gy_Employee where HName= '" + ClsPub.CurUserName + "'", "Gy_Employee");
|
//写入信息
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
txtHEmpID.Text = "";
|
txtHEmpID.Tag = 0;
|
}
|
else
|
{
|
txtHEmpID.Text =DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HName"]);
|
txtHEmpID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"]);
|
}
|
}
|
|
//初始化GRID
|
private void initGrid()
|
{
|
DBUtility.Xt_BaseBillFun.initGridMESList(grdCardList, this.Name + "grdCardList");
|
DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name);
|
grdSub.SelectionMode = DataGridViewSelectionMode.CellSelect;
|
grdCardList.DataSource = null;
|
}
|
|
private void Display()
|
{
|
ClsCN SubCn = new ClsCN();
|
DataSet DSet;
|
string sSql = "";
|
string sWhere = "";
|
|
sWhere = sWhere + "" + DBUtility.ClsPub.isStrNull(txtHProcID.Tag);
|
sWhere = sWhere + "," + DBUtility.ClsPub.isStrNull(txtHSourceID.Tag);
|
sWhere = sWhere + "," + DBUtility.ClsPub.isStrNull(DBUtility.ClsPub.CurUserName);
|
|
|
sSql = " exec h_p_MES_NowStationInBillList " + sWhere ;
|
|
//
|
DSet = SubCn.RunProcReturn(sSql, "h_p_MES_NowStationInBillList", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
//MessageBox.Show("没有返回任何结果,请在过滤框中点击【恢复】按钮,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//释放冻结
|
//
|
grdCardList.DataSource = DSet.Tables[0].DefaultView;
|
//设置合计列
|
//string sTotalCol = "";
|
//sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet);
|
//string[] sT;
|
//sT = sTotalCol.Split(Convert.ToChar(","));
|
//oSumGrid.BuildTotalCols(sT);
|
//
|
//冻结
|
int FrCol = 0;
|
string s = "是";
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdCardList, this.Name + "grdCardList", s, FrCol);
|
//画线
|
//GraphLine();
|
|
//Total();
|
//判断金额权限
|
|
|
//
|
}
|
|
//
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdSub);
|
}
|
|
//进站按钮
|
private void cmdOK_Click(object sender, EventArgs e)
|
{
|
this.Sub_SaveBill();
|
}
|
//取消按钮
|
private void cmdCancel_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
//控件位置
|
private void Sub_ControlLocation()
|
{
|
//gbUp.Width = P1.Width - 20;
|
//gbUp.Left = 10;
|
//gbUp.Height = P1.Height - 35;
|
//gbUp.Top = 30;
|
}
|
//窗体加载
|
private void Sc_StationInBill_Load(object sender, EventArgs e)
|
{
|
//打印初始化
|
this.Text = ModCaption;
|
this.lblCaption.Text = ModCaption;
|
}
|
//窗体尺寸变化时
|
private void Sc_StationInBill_Resize(object sender, EventArgs e)
|
{
|
//Sub_ControlLocation();
|
}
|
//timer
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
Sub_ControlLocation();
|
if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_View)
|
{
|
this.Sub_ShowBill();
|
}
|
else
|
{
|
this.Sub_AddBill();
|
}
|
}
|
//窗体卸载
|
private void Sc_StationInBill_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
|
//DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdCardList, this.Name + "grdCardList");
|
}
|
//新增单据
|
private void Sub_AddBill()
|
{
|
this.BillNew = new DAL.ClsSc_StationInBill();
|
this.BillOld = new DAL.ClsSc_StationInBill();
|
this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
|
this.Sub_OperStatus();//设置TOOLBAR
|
this.Sub_ClearBill();//清空界面
|
this.txtHStationInTime.Text = DBUtility.ClsPub.GetServerDate(-1);
|
|
this.txtHBillNo.Text = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);//得到新单号
|
|
if (lngBillKey != 0 )
|
{
|
//LotShow();
|
}
|
|
}
|
private void LotShow() //自动载入 流转卡进站界面功能
|
{
|
DataSet Ds;
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
//Ds = oCn.RunProcReturn("Select * from h_v_MES_NowWorkBillList Where hmainid=" + lngBillKey + "and hsubid=" + lngBillSubKey, "h_v_MES_NowWorkBillList", ref DBUtility.ClsPub.sErrInfo);
|
//Ds = oCn.RunProcReturn("exec h_p_MES_NowWorkBillList " + lngBillKey + "," + lngBillSubKey, "h_p_MES_NowWorkBillList", ref DBUtility.ClsPub.sErrInfo);
|
Ds = oCn.RunProcReturn("exec h_p_Sc_GetProcByLotNo " + lngBillKey , "h_p_Sc_GetProcByLotNo");
|
if (Ds == null)
|
{
|
MessageBox.Show("错误原因:" + DBUtility.ClsPub.sErrInfo);
|
return;
|
}
|
if (Ds.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("LOT卡无效!");
|
return;
|
}
|
|
if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "out" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "自制")
|
{
|
MessageBox.Show("该LOT卡下道工序为自制出站!");
|
return;
|
}
|
else if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "out" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "委外")
|
{
|
MessageBox.Show("该LOT卡下道工序为委外接收!");
|
return;
|
}
|
else if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "in" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "委外")
|
{
|
MessageBox.Show("该LOT卡下道工序为委外发出!");
|
return;
|
}
|
lngBillSubKey = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSubID"]);
|
txtHICMOBillNo.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]);
|
txtHICMOBillNo.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["任务单号"]);
|
txtHProcExchBillNo.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["单据号"]);
|
txtHProcID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcID"]);
|
txtHProcID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["工序"]);
|
txtHMaterID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
|
txtHMaterID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["产品代码"]);
|
txtHMaterName.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["产品"]);
|
txtHMaterModel.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["规格型号"]);
|
//txtHSourceID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]);
|
//txtHSourceID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["生产资源"]);
|
//txtHGroupID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]);
|
//txtHGroupID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["班组"]);
|
//txtHEmpID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HWorkerID"]);
|
//txtHEmpID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["操作工"]);
|
txtHICMOQty.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["任务单数量"]);
|
txtHPlanQty.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["计划数量"]);
|
txtHQty.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["计划数量"]);
|
txtHPieceQty.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["板数"]);
|
txtHCenterID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCenterID"]);
|
txtHCenterID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["工作中心"]);
|
}
|
//TOOLBAR状态 按钮是否灰度
|
public void Sub_OperStatus()
|
{
|
switch (BillStatus)
|
{
|
case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View:
|
//浏览状态
|
grdStatus = false;
|
cmdOK.Enabled = false;
|
cmdXG.Enabled = true;
|
cmdCancel.Enabled = true;
|
Sub_LrtextStatus(false);
|
break;
|
case DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew:
|
//新增状态
|
grdStatus = true;
|
cmdOK.Enabled = true;
|
cmdXG.Enabled = false;
|
cmdCancel.Enabled = true;
|
Sub_LrtextStatus(true);
|
break;
|
case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify:
|
//修改状态
|
grdStatus = true;
|
cmdOK.Enabled = true;
|
cmdXG.Enabled = false;
|
cmdCancel.Enabled = true;
|
Sub_LrtextStatus(true);
|
break;
|
}
|
}
|
//根据编辑状态 设置 控件是否允许录入
|
private void Sub_LrtextStatus(bool TextEnabled)
|
{
|
if (TextEnabled == true)
|
{
|
//控件全部有效
|
gbUp.Enabled = true;
|
|
}
|
else
|
{ //控件全部无效
|
gbUp.Enabled = false;
|
}
|
}
|
#endregion
|
|
|
#region 读写类
|
//显示单据
|
public void Sub_ShowBill()
|
{
|
DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();//物料
|
DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View();//职员
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();//生产资源
|
DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View();//工序
|
DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View();//班组
|
DAL.ClsGy_WorkCenter_View oCenter = new DAL.ClsGy_WorkCenter_View();//工作中心
|
//判断是否存在单据
|
if (BillOld.ShowBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == false)
|
{
|
MessageBox.Show(ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
//清空
|
Sub_ClearBill();
|
//grid禁止刷新
|
//加载表头
|
if (oMater.GetInfoByID(BillOld.omodel.HMaterID))
|
{
|
this.txtHMaterID.Text = oMater.omodel.HNumber;
|
this.txtHMaterID.Tag = oMater.omodel.HItemID.ToString();
|
this.txtHMaterName.Text = oMater.omodel.HName;
|
this.txtHMaterModel.Text = oMater.omodel.HModel;
|
}
|
else
|
{
|
this.txtHMaterID.Text = "";
|
this.txtHMaterName.Text = "";
|
this.txtHMaterModel.Text = "";
|
}
|
//
|
if (oCenter.GetInfoByID(BillOld.omodel.HCenterID))
|
{
|
this.txtHCenterID.Text = oCenter.omodel.HName;
|
this.txtHCenterID.Tag = oCenter.omodel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHCenterID.Text = "";
|
}
|
//
|
if (oEmp.GetInfoByID(BillOld.omodel.HEmpID))
|
{
|
this.txtHEmpID.Text = oEmp.omodel.HName;
|
this.txtHEmpID.Tag = oEmp.omodel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHEmpID.Text = "";
|
}
|
//
|
if (oSource.GetInfoByID(BillOld.omodel.HSourceID))
|
{
|
this.txtHSourceID.Text = oSource.omodel.HNumber;
|
this.txtHSourceID.Tag = oSource.omodel.HItemID.ToString();
|
this.txtHSourceName.Text = oSource.omodel.HName;
|
}
|
else
|
{
|
this.txtHSourceID.Text = "";
|
this.txtHSourceName.Text = "";
|
}
|
//
|
if (oProc.GetInfoByID(BillOld.omodel.HProcID))
|
{
|
this.txtHProcID.Text = oProc.omodel.HName;
|
this.txtHProcID.Tag = oProc.omodel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHProcID.Text = "";
|
}
|
//
|
if (oGroup.GetInfoByID(BillOld.omodel.HGroupID))
|
{
|
this.txtHGroupID.Text = oGroup.omodel.HNumber;
|
this.txtHGroupID.Tag = oGroup.omodel.HItemID.ToString();
|
this.txtHGroupName.Text = oGroup.omodel.HName;
|
|
}
|
else
|
{
|
this.txtHGroupID.Text = "";
|
this.txtHGroupName.Text = "";
|
}
|
//
|
this.txtHProcNo.Text = BillOld.omodel.HProcNo.ToString();
|
this.txtHBillNo.Text = BillOld.omodel.HBillNo;
|
this.txtHICMOBillNo.Text = BillOld.omodel.HICMOBillNo;
|
this.txtHICMOBillNo.Tag = BillOld.omodel.HICMOInterID;
|
lngBillKey = BillOld.omodel.HProcExchInterID;
|
lngBillSubKey = BillOld.omodel.HProcExchEntryID;
|
this.txtHProcExchBillNo.Text = BillOld.omodel.HProcExchBillNo;
|
this.txtHStationInTime.Text = BillOld.omodel.HStationInTime.ToString();
|
this.txtHICMOQty.Text = BillOld.omodel.HICMOQty.ToString();
|
this.txtHPlanQty.Text = BillOld.omodel.HPlanQty.ToString();
|
this.txtHPieceQty.Text = BillOld.omodel.HPieceQty.ToString();
|
this.txtHOrderProcNO.Text = BillOld.omodel.HOrderProcNO;
|
|
Display();
|
this.txtHQty.Text = BillOld.omodel.HQty.ToString();
|
|
Sub_OperStatus();
|
//
|
txtHProcExchBillNo.Enabled = false;
|
txtHProcNo.Enabled = false;
|
}
|
|
//单据完整性判断 未完成
|
private bool Sub_AllowSave()
|
{
|
//判断该用户名是否有该工站权限
|
//if (BillNew.CheckCenterIDByUser(DBUtility.ClsPub.isLong(txtHCenterID.Tag)) == false)
|
//{
|
// MessageBox.Show("没有该工站权限!", "提示");
|
// return false;
|
//}
|
//if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
|
//{
|
// //判断是否已经进站
|
// DataSet Ds;
|
// SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
// Ds = oCn.RunProcReturn("select 1 from Sc_StationInBillMain where HProcExchInterID=" + lngBillKey + " and HProcExchEntryID=" + lngBillSubKey, "Sc_StationInBillMain");
|
// if (Ds == null || Ds.Tables[0].Rows.Count > 0)
|
// {
|
// MessageBox.Show("该工序已进站,请重新扫描!", "提示");
|
// return false;
|
// }
|
//}
|
//必输项目是否为空
|
if (DBUtility.ClsPub.isLong(lngBillKey) <= 0)
|
{
|
MessageBox.Show("错误的流转卡内码!", "提示");
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(lngBillSubKey) <= 0)
|
{
|
MessageBox.Show("错误的流转卡子内码!", "提示");
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(txtHProcNo.Text) <= 0)
|
{
|
MessageBox.Show("流水号没有选择!", "提示");
|
return false;
|
}
|
if (DBUtility.ClsPub.isStrNull(txtHProcExchBillNo.Text) == "")
|
{
|
MessageBox.Show("流转卡号没有选择!", "提示");
|
return false;
|
}
|
|
|
|
if (DBUtility.ClsPub.isLong(txtHMaterID.Tag) == 0)
|
{
|
MessageBox.Show("产品没有选择!", "提示");
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(txtHCenterID.Tag) == 0)
|
{
|
MessageBox.Show("工作中心没有选择!", "提示");
|
return false;
|
}
|
|
if (DBUtility.ClsPub.isLong(txtHProcID.Tag) == 0)
|
{
|
MessageBox.Show("当前工序没有选择!", "提示");
|
return false;
|
}
|
//if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0)
|
//{
|
// MessageBox.Show("操作员没有选择!", "提示");
|
// return false;
|
//}
|
//if (DBUtility.ClsPub.isLong(txtHSourceID.Tag) == 0)
|
//{
|
// MessageBox.Show("生产资源没有选择!", "提示");
|
// return false;
|
//}
|
|
//if (DBUtility.ClsPub.isDoule(txtHPieceQty.Text.Trim()) == 0.0)
|
//{
|
// MessageBox.Show("接收件数不能为0!", "提示");
|
// return false;
|
//}
|
if (DBUtility.ClsPub.isDoule(txtHQty.Text.Trim()) == 0.0)
|
{
|
MessageBox.Show("接收个数不能为0!", "提示");
|
return false;
|
}
|
//if (DBUtility.ClsPub.isDoule(txtHQty.Text.Trim()) > DBUtility.ClsPub.isDoule(txtHPlanQty.Text.Trim()))
|
//{
|
// MessageBox.Show("接收个数不能大于流转卡个数!", "提示");
|
// return false;
|
//}
|
|
//单据号是否重复
|
if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, txtHBillNo.Text.Trim(), BillStatus, BillOld.omodel.HInterID))
|
{
|
MessageBox.Show("单据号重复!", "提示");
|
return false;
|
}
|
|
//如果是首道工序 循环网格判断是否有充足库存(只判断自制件),如果网格为空则允许保存
|
DataSet ds;
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
ds = oCN.RunProcReturn("select HInterID from Sc_ProcessExchangeBillSub Where hinterid=" + lngBillKey.ToString() + " and hprocno<" + txtHProcNo.Text + " order by hprocno", "Sc_ProcessExchangeBillSub");
|
if (ds == null)
|
{
|
MessageBox.Show("判断首道工序失败,不允许保存!");
|
return false;
|
}
|
else if (ds.Tables[0].Rows.Count == 0)
|
{
|
for (int i = 0; i < grdSub.Rows.Count; i++)
|
{
|
//根据接收数量计算 需求数量
|
//if (DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[Fun_GetCol("H属性")].Value) == 2)
|
//{
|
// //判断是否不足
|
// if (DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetCol("需求数")].Value) - DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetCol("库存数量")].Value) > 0)
|
// {
|
// MessageBox.Show("第" + Convert.ToString(i+1) + "行,物料库存不足,不允许保存!");
|
// return false;
|
// }
|
//}
|
}
|
}
|
//
|
return true;
|
}
|
//保存单据
|
private bool Sub_SaveBill()
|
{
|
Model.ClsSc_StationInBillSub oBillSub = new Model.ClsSc_StationInBillSub();
|
//判断权限
|
if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
|
{
|
return false;
|
}
|
//
|
Int32 i;
|
bool bResult;
|
BillNew = new DAL.ClsSc_StationInBill();
|
//失去焦点
|
lblCaption.Focus();
|
if (!Sub_AllowSave())//单据完整性判断
|
return false;
|
//赋值ID
|
if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
|
BillNew.omodel.HInterID = BillOld.omodel.HInterID;
|
//主类赋值
|
//判断会计期是否合理
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(DBUtility.ClsPub.isDate(this.txtHStationInTime.Text), ref sYear, ref sPeriod, ref s) == false)
|
{
|
MessageBox.Show(s, "提示");
|
return false;
|
}
|
//
|
BillNew.omodel.HYear = sYear;
|
BillNew.omodel.HPeriod = sPeriod;
|
BillNew.omodel.HBillNo = this.txtHBillNo.Text.Trim();
|
BillNew.omodel.HICMOBillNo = this.txtHICMOBillNo.Text.Trim();
|
BillNew.omodel.HICMOInterID = DBUtility.ClsPub.isLong(this.txtHICMOBillNo.Tag);
|
BillNew.omodel.HProcExchInterID = lngBillKey;
|
BillNew.omodel.HProcExchEntryID = lngBillSubKey;
|
BillNew.omodel.HProcExchBillNo = this.txtHProcExchBillNo.Text.Trim();
|
BillNew.omodel.HProcID = DBUtility.ClsPub.isLong(this.txtHProcID.Tag);
|
BillNew.omodel.HMaterID = DBUtility.ClsPub.isLong(this.txtHMaterID.Tag);
|
BillNew.omodel.HStationInTime = DBUtility.ClsPub.isDate(this.txtHStationInTime.Text);
|
BillNew.omodel.HEmpID = DBUtility.ClsPub.isLong(this.txtHEmpID.Tag);
|
BillNew.omodel.HSourceID = DBUtility.ClsPub.isLong(this.txtHSourceID.Tag);
|
BillNew.omodel.HGroupID = DBUtility.ClsPub.isLong(this.txtHGroupID.Tag);
|
BillNew.omodel.HICMOQty = DBUtility.ClsPub.isDoule(this.txtHICMOQty.Text);
|
BillNew.omodel.HPlanQty = DBUtility.ClsPub.isDoule(this.txtHPlanQty.Text);
|
BillNew.omodel.HQty = DBUtility.ClsPub.isDoule(this.txtHQty.Text);
|
BillNew.omodel.HPieceQty = DBUtility.ClsPub.isDoule(this.txtHPieceQty.Text);
|
BillNew.omodel.HSourceName = DBUtility.ClsPub.isStrNull(this.txtHSourceName.Text);
|
BillNew.omodel.HCenterID = DBUtility.ClsPub.isLong(this.txtHCenterID.Tag);
|
|
BillNew.omodel.HProcNo = DBUtility.ClsPub.isLong(this.txtHProcNo.Text);
|
BillNew.omodel.HOrderProcNO = DBUtility.ClsPub.isStrNull(this.txtHOrderProcNO.Text);
|
|
//保存完毕后处理
|
if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
|
{
|
bResult = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
|
}
|
else
|
{
|
bResult = BillNew.ModifyBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
|
}
|
//提示
|
if (bResult == true)
|
{
|
BillChange = true;
|
MessageBox.Show("单据存盘完毕!单据号:" + this.txtHBillNo.Text.Trim() + ClsPub.sExeReturnInfo , "提示");
|
if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
|
{
|
BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
|
BillOld.omodel.HInterID = BillNew.omodel.HInterID;
|
this.Sub_ShowBill();
|
}
|
else if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
|
{
|
BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
|
}
|
this.Sub_OperStatus();
|
return true;
|
}
|
else
|
{
|
MessageBox.Show("保存失败!原因:" + ClsPub.sExeReturnInfo, "提示");
|
return false;
|
}
|
}
|
#endregion
|
|
|
private void cmdHMaterID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
|
if (oMater.RefreshView())
|
{
|
txtHMaterID.Tag = oMater.oModel.HItemID.ToString();
|
if (oMater.GetInfoByID(oMater.oModel.HItemID))
|
{
|
txtHMaterID.Text = oMater.omodel.HNumber;
|
txtHMaterName.Text = oMater.omodel.HName;
|
txtHMaterModel.Text = oMater.omodel.HModel;
|
}
|
else
|
{
|
txtHMaterID.Text = "";
|
txtHMaterName.Text = "";
|
txtHMaterModel.Text = "";
|
}
|
}
|
else
|
{
|
txtHMaterID.Text = "";
|
txtHMaterName.Text = "";
|
txtHMaterModel.Text = "";
|
}
|
}
|
|
private void txtHMaterID_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHMaterID.Text.Trim() == "")
|
{
|
this.txtHMaterID.Tag = "0";
|
this.txtHMaterName.Text = "";
|
this.txtHMaterModel.Text = "";
|
}
|
}
|
|
private void cmdHEmpID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByEmp(txtHEmpID);
|
}
|
|
private void txtHEmpID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHEmpID);
|
}
|
|
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.HNumber;
|
txtHSourceID.Tag = oSource.oModel.HItemID.ToString();
|
txtHSourceName.Text = oSource.oModel.HName;
|
}
|
else
|
{
|
txtHSourceID.Text = "";
|
txtHSourceName.Text = "";
|
}
|
}
|
|
private void txtHSourceID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHSourceID);
|
txtHSourceName.Text = "";
|
}
|
|
private void cmdHProcID_Click(object sender, EventArgs e)
|
{
|
|
DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View();
|
if (oProc.RefreshView())
|
{
|
//lngBillSubKey = oProc.oModel.HEntryID;
|
txtHProcID.Text = oProc.oModel.HName;
|
txtHProcID.Tag = oProc.oModel.HItemID.ToString();
|
//Sub_AddBill();
|
}
|
else
|
{
|
//lngBillSubKey = 0;
|
txtHProcID.Tag = 0;
|
txtHProcID.Text = "";
|
}
|
|
|
|
//BLL.ClsBaseSelect.SetTextByProc(txtHProcID);
|
//if (lngBillKey == 0)
|
//{
|
// MessageBox.Show("请先扫描流转卡!", "提示");
|
// return;
|
//}
|
//else
|
//{
|
// DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View();
|
// if (oProc.RefreshViewByLot(lngBillKey))
|
// {
|
// lngBillSubKey = oProc.oModel.HEntryID;
|
// txtHProcID.Text = oProc.oModel.HName;
|
// txtHProcID.Tag = oProc.oModel.HItemID.ToString();
|
// Sub_AddBill();
|
// }
|
// else
|
// {
|
// lngBillSubKey = 0;
|
// txtHProcID.Tag = 0;
|
// txtHProcID.Text = "";
|
// }
|
//}
|
}
|
|
private void txtHProcID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHProcID);
|
}
|
|
private void cmdHGroupID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextByGroup(txtHGroupID,txtHGroupName);
|
}
|
|
private void txtHGroupID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHGroupID);
|
txtHGroupName.Text = "";
|
}
|
|
private void txtHProcExchBillNo_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Return)
|
{
|
if (txtHProcExchBillNo.Text.Trim() == "")
|
{
|
MessageBox.Show("工序流转卡卡号,不能为空!");
|
return;
|
}
|
|
DataSet Ds;
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
string sBillNo = txtHProcExchBillNo.Text.Trim();
|
|
//得到信息
|
Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "'", "h_v_Sc_ProcessExchangeBillList");
|
//写入信息
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
txtHProcExchBillNo.Text = "";
|
MessageBox.Show("未查询到流转卡信息!");
|
return;
|
}
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
Sub_WriteInForm_SM(Ds.Tables[0], i);
|
}
|
//Sub_ShowBill();
|
txtHProcNo.Focus();
|
txtHProcExchBillNo.Enabled = false;
|
}
|
|
|
//if (e.KeyCode == Keys.Enter)
|
//{
|
// DAL.ClsSc_ProcessExchangeBill oPeb = new DAL.ClsSc_ProcessExchangeBill();
|
// if (oPeb.GetIDByNo(DBUtility.ClsPub.isStrNull(txtHProcExchBillNo.Text), ref ClsPub.sExeReturnInfo) == false)
|
// {
|
// MessageBox.Show(ClsPub.sExeReturnInfo, "提示");
|
// lngBillKey = 0;
|
// lngBillSubKey = 0;
|
// txtHProcID.Tag = 0;
|
// txtHProcID.Text = "";
|
// txtHProcExchBillNo.Text = "";
|
// return;
|
// }
|
// lngBillKey = oPeb.omodel.HInterID;
|
// lngBillSubKey = 0;
|
// txtHProcID.Tag = 0;
|
// txtHProcID.Text = "";
|
// LotShow();
|
//}
|
}
|
|
|
//根据TABLE写入界面
|
private void Sub_WriteInForm_SM(DataTable oTable, int i)
|
{
|
DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
|
|
//
|
this.txtHICMOBillNo.Tag = oTable.Rows[0]["hicmointerid"].ToString();
|
lngICMOEntryID = Pub_Class.ClsPub.isLong(oTable.Rows[0]["HICMOEntryID"]);
|
this.txtHICMOBillNo.Text = oTable.Rows[0]["任务单号"].ToString();
|
this.txtHMaterID.Tag = oTable.Rows[0]["HMaterID"].ToString();
|
this.txtHMaterName.Text = oTable.Rows[0]["产品"].ToString();
|
this.txtHMaterID.Text = oTable.Rows[0]["产品代码"].ToString();
|
this.txtHMaterModel.Text = oTable.Rows[0]["规格型号"].ToString();
|
//this.txtHBatchNo.Text = oTable.Rows[0]["批号"].ToString();
|
//this.txtHUnitID.Tag = oTable.Rows[0]["HUnitID"].ToString();
|
//this.txtHUnitID.Text = oTable.Rows[0]["单位"].ToString();
|
this.txtHPieceQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["流转卡数量"], 0); //未显示
|
this.txtHPlanQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["流转卡数量"], 0); //流转卡
|
//lngBillSubKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HSubID"]);
|
txtHProcExchBillNo.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["单据号"]);
|
txtHICMOQty.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["任务单数量"]); //任务单数量
|
lngBillKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["hmainid"]);
|
this.txtHOrderProcNO.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["订单跟踪号"]);
|
//加载表体
|
Display();
|
|
//this.txtHQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["流转卡数量"], 0); //进站数量
|
this.txtHQty.Text = "0"; //进站数量
|
}
|
private void Sub_WriteInForm_SM2(DataTable oTable, int i)
|
{
|
DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View();
|
DAL.ClsGy_WorkCenter_View oCenter = new DAL.ClsGy_WorkCenter_View();
|
lngBillSubKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["hsubid"]);
|
this.txtHProcID.Text = oTable.Rows[0]["工序"].ToString();
|
this.txtHProcID.Tag = oTable.Rows[0]["HProcID"].ToString();
|
this.txtHCenterID.Text = oTable.Rows[0]["工作中心"].ToString();
|
this.txtHCenterID.Tag = oTable.Rows[0]["HCenterID"].ToString();
|
|
txtHProcNo.Enabled = false;
|
|
}
|
private void txtHProcID_KeyDown(object sender, KeyEventArgs e)
|
{
|
//if (e.KeyCode == Keys.Enter)
|
//{
|
// if (lngBillKey == 0)
|
// {
|
// MessageBox.Show("请先扫描流转卡!", "提示");
|
// return;
|
// }
|
// if (DBUtility.ClsPub.isStrNull(txtHProcID.Text) != "")
|
// {
|
// DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View();
|
// if (oProc.GetInfoByNumber_Lot(DBUtility.ClsPub.isStrNull(txtHProcID.Text)))
|
// {
|
// lngBillSubKey = oProc.omodel.HEntryID;
|
// txtHProcID.Text = oProc.omodel.HName;
|
// txtHProcID.Tag = oProc.omodel.HItemID;
|
// Show();
|
// }
|
// else
|
// {
|
// lngBillSubKey = 0;
|
// txtHProcID.Text = "";
|
// txtHProcID.Tag = 0;
|
// }
|
// }
|
// else
|
// {
|
// lngBillSubKey = 0;
|
// txtHProcID.Text = "";
|
// txtHProcID.Tag = 0;
|
// }
|
//}
|
}
|
|
private void txtHEmpID_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
if (DBUtility.ClsPub.isStrNull(txtHEmpID.Text) != "")
|
{
|
DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View();
|
if (oEmp.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHEmpID.Text)))
|
{
|
txtHEmpID.Text = oEmp.omodel.HName;
|
txtHEmpID.Tag = oEmp.omodel.HItemID;
|
|
cmdOK.Focus();
|
}
|
else
|
{
|
txtHEmpID.Text = "";
|
txtHEmpID.Tag = 0;
|
}
|
}
|
else
|
{
|
txtHEmpID.Text = "";
|
txtHEmpID.Tag = 0;
|
}
|
}
|
}
|
|
private void txtHSourceID_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
if (DBUtility.ClsPub.isStrNull(txtHSourceID.Text) != "")
|
{
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
if (oSource.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHSourceID.Text)))
|
{
|
txtHSourceID.Text = oSource.omodel.HNumber;
|
txtHSourceID.Tag = oSource.omodel.HItemID;
|
txtHSourceName.Text = oSource.omodel.HName;
|
}
|
else
|
{
|
txtHSourceID.Text = "";
|
txtHSourceID.Tag = 0;
|
txtHSourceName.Text = "";
|
}
|
}
|
else
|
{
|
txtHSourceID.Text = "";
|
txtHSourceID.Tag = 0;
|
txtHSourceName.Text = "";
|
}
|
}
|
}
|
|
private void txtHGroupID_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
if (DBUtility.ClsPub.isStrNull(txtHGroupID.Text) != "")
|
{
|
DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View();
|
if (oGroup.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHGroupID.Text)))
|
{
|
txtHGroupID.Text = oGroup.omodel.HNumber;
|
txtHGroupID.Tag = oGroup.omodel.HItemID;
|
txtHGroupName.Text = oGroup.omodel.HName;
|
}
|
else
|
{
|
txtHGroupID.Text = "";
|
txtHGroupID.Tag = 0;
|
txtHGroupName.Text = "";
|
}
|
}
|
else
|
{
|
txtHGroupID.Text = "";
|
txtHGroupID.Tag = 0;
|
txtHGroupName.Text = "";
|
}
|
}
|
}
|
|
private void cmdAddNew_Click(object sender, EventArgs e)
|
{
|
//lngBillKey = 0;
|
//lngBillSubKey = 0;
|
//Sub_AddBill();
|
string s = BillNew.TestWebs();
|
MessageBox.Show(s);
|
}
|
|
private void cmdHCenterID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_WorkCenter_View oCenter = new DAL.ClsGy_WorkCenter_View();
|
if (oCenter.RefreshView())
|
{
|
txtHCenterID.Text = oCenter.oModel.HName;
|
txtHCenterID.Tag = oCenter.oModel.HItemID;
|
}
|
else
|
{
|
txtHCenterID.Text = "";
|
}
|
}
|
|
private void txtHProcNo_KeyDown(object sender, KeyEventArgs e)
|
{
|
DataSet Ds;
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
string sProcNo = txtHProcNo.Text.Trim();
|
string sBillNo = txtHProcExchBillNo.Text.Trim();
|
if (e.KeyCode == Keys.Return)
|
{
|
if (txtHProcExchBillNo.Enabled == true)
|
{
|
MessageBox.Show("流转卡没有扫描,或者没有按回车键,请扫描流转卡或者在流转卡文本框中按回车键!");
|
return;
|
}
|
|
//得到信息(委外标记为0时,流转标记为1时)
|
Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "' and 下道流转工序<>'转' and 委外标记=0 and 流转标记=1 and 工序号='" + sProcNo + "'", "h_v_Sc_ProcessExchangeBillList");
|
//Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "' and 工序号='" + sProcNo + "' and 委外标记=0 and 流转标记=1 ", "h_v_Sc_ProcessExchangeBillList");
|
//写入信息
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
txtHProcNo.Text = "";
|
MessageBox.Show("工序号错误或者当前工序号不允许进站,请重新输入!");
|
return;
|
}
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
Sub_WriteInForm_SM2(Ds.Tables[0], i);
|
}
|
txtHQty.Focus();
|
}
|
}
|
|
private void txtHProcNo_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHProcNo.Text.Trim() == "")
|
{
|
txtHProcID.Tag = "0";
|
txtHProcID.Text = "";
|
}
|
}
|
|
private void txtHQty_TextChanged(object sender, EventArgs e)
|
{
|
//Sub_Recount();
|
}
|
|
public void Sub_Recount()
|
{
|
//double dNeedQty;
|
//double dFenzi;
|
//double dFenMu;
|
//double dKCQty;
|
//double dInQty;
|
//if (DBUtility.ClsPub.isDoule(txtHQty.Text) >= 0)
|
//{
|
// for (int i = 0; i < grdSub.Rows.Count; i++)
|
// {
|
// //根据接收数量计算 需求数量
|
// if (DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetCol("分母")].Value) > 0)
|
// {
|
// dFenMu = DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetCol("分母")].Value);
|
// dFenzi = DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetCol("分子")].Value);
|
// dInQty = DBUtility.ClsPub.isDoule(txtHQty.Text);
|
// //
|
// //grdSub.Rows[i].Cells[Fun_GetCol("需求数")].Value = dInQty * dFenzi / dFenMu;
|
// dNeedQty = dInQty * dFenzi / dFenMu;
|
// grdSub.Rows[i].Cells[Fun_GetCol("需求数")].Value = dNeedQty;
|
// dKCQty = DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetCol("库存数量")].Value);
|
// //判断是否不足
|
// if (dNeedQty - dKCQty > 0)
|
// {
|
// grdSub.Rows[i].DefaultCellStyle.BackColor = Color.Violet;
|
// }
|
// else
|
// {
|
// grdSub.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
// }
|
// }
|
// else
|
// {
|
// grdSub.Rows[i].DefaultCellStyle.BackColor = Color.Violet;
|
// }
|
// }
|
//}
|
}
|
|
private void txtHQty_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
txtHEmpNumber.Focus();
|
}
|
}
|
|
//编辑单据
|
private void Sub_EditBill()
|
{
|
//判断权限
|
if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
|
{
|
return;
|
}
|
////判断该用户名是否有该工站权限
|
//if (BillNew.CheckCenterIDByUser(DBUtility.ClsPub.isLong(txtHCenterID.Tag)) == false)
|
//{
|
// MessageBox.Show("没有该工站权限!", "提示");
|
// return;
|
//}
|
|
string s = "";
|
if (BillOld.ShowBill(BillOld.omodel.HInterID, ref s) == false)
|
{
|
MessageBox.Show("此单据有错误!", "提示");
|
return;
|
}
|
//判断是否可编辑
|
|
|
//
|
this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
|
this.Sub_OperStatus();//刷新TOOLBAR
|
//
|
txtHBillNo.Enabled = false; //单据号不允许修改
|
}
|
private void cmdXG_Click(object sender, EventArgs e)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet ds;
|
//判断是否存在 相同单据号 的领料单 判断生产订单是否已结案,要求计划手工反结案
|
ds = oCn.RunProcReturn("exec h_p_MES_StationInBill_DelCtrl '" + BillOld.omodel.HBillNo + "'", "h_p_MES_StationInBill_DelCtrl");
|
if (ds == null)
|
{
|
MessageBox.Show("判断关联失败!");
|
return;
|
}
|
if (ds.Tables[0].Rows.Count > 0 && Pub_Class.ClsPub.isInt(ds.Tables[0].Rows[0][0]) == 2)
|
{
|
MessageBox.Show(Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]));
|
return;
|
}
|
//重算网格
|
Display();
|
//Sub_Recount();
|
Sub_EditBill();
|
}
|
|
private void cmdHDelBill_Click(object sender, EventArgs e)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
if (MessageBox.Show("确定要删除当前单据对应的领料单?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
{
|
//oCn.RunProc(" update Sc_StationInBillMain set HDelBillFlag=5 Where HInterID= " + BillOld.omodel.HInterID.ToString());
|
if (BillOld.DelBillMaterialOut(BillOld.omodel.HInterID, BillOld.omodel.HBillNo))
|
{
|
MessageBox.Show("删除领料单成功!");
|
}
|
else
|
{
|
MessageBox.Show("删除领料单失败11!" + Pub_Class.ClsPub.sExeReturnInfo);
|
}
|
return;
|
}
|
}
|
catch (Exception e1)
|
{
|
MessageBox.Show("删除领料单失败!");
|
|
}
|
}
|
|
private void MES_StationInBill_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.F12)
|
{
|
Sc_ProcExchBilltransRelationQty ofrm = new Sc_ProcExchBilltransRelationQty();
|
ofrm.keyitem = lngBillKey;
|
ofrm.ShowDialog();
|
}
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
{
|
//审核权限
|
//if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, DBUtility.ClsPub.CurUserName))
|
//{
|
// return;
|
//}
|
//
|
Int64 lInterID = 0;
|
lInterID = BillOld.omodel.HInterID;
|
if (lInterID == 0)
|
{
|
MessageBox.Show("单据未保存,不能审核");
|
return;
|
}
|
DAL.ClsSc_StationInBill oBill = new DAL.ClsSc_StationInBill();
|
//查看是否已审核,关闭,作废
|
if (oBill.ShowBill(lInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oBill.omodel.HChecker.Trim() != "")
|
{
|
MessageBox.Show("单据已审核!不能再次审核", "提示");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
//判断是否已经存在 领料单
|
|
//审核
|
if (oBill.CheckBill(lInterID, ref DBUtility.ClsPub.sExeReturnInfo) == true)
|
{
|
MessageBox.Show("审核成功!", "提示");
|
return;
|
}
|
else
|
{
|
//删除同名领料单
|
|
//
|
MessageBox.Show("审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
}
|
|
private void button2_Click(object sender, EventArgs e)
|
{
|
//审核权限
|
//if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, DBUtility.ClsPub.CurUserName))
|
//{
|
// return;
|
//}
|
//
|
Int64 lInterID = 0;
|
lInterID = BillOld.omodel.HInterID;
|
if (lInterID == 0)
|
{
|
MessageBox.Show("单据未保存,不能反审核");
|
return;
|
}
|
DAL.ClsSc_StationInBill oBill = new DAL.ClsSc_StationInBill();
|
//查看是否已审核,关闭,作废
|
if (oBill.ShowBill(lInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oBill.omodel.HChecker.Trim() == "")
|
{
|
MessageBox.Show("单据未审核!不需要反审核!", "提示");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
//反审核
|
if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
|
{
|
MessageBox.Show("反审核成功!", "提示");
|
return;
|
}
|
else
|
{
|
MessageBox.Show("反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
}
|
|
private void txtHBarCode_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Return)
|
{
|
if (txtHBarCode.Text.Trim() == "")
|
{
|
MessageBox.Show("工序流转卡卡号,不能为空!");
|
return;
|
}
|
|
DataSet Ds;
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
//拆分条形码
|
string sBillBarCode = txtHBarCode.Text.Trim();
|
string[] NewBarCode;
|
if (sBillBarCode.CompareTo("#") > 0)
|
{
|
NewBarCode = sBillBarCode.Split(Convert.ToChar("#"));
|
sBillBarCode = NewBarCode[0];
|
}
|
string sBillNo = sBillBarCode;
|
//========================================
|
|
//得到信息
|
Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "'", "h_v_Sc_ProcessExchangeBillList");
|
//写入信息
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
txtHProcExchBillNo.Text = "";
|
txtHBarCode.Text = "";
|
MessageBox.Show("未查询到流转卡信息!");
|
return;
|
}
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
Sub_WriteInForm_SM(Ds.Tables[0], i);
|
}
|
//Sub_ShowBill();
|
txtHProcNo.Focus();
|
txtHProcExchBillNo.Enabled = false;
|
txtHBarCode.Enabled = false;
|
}
|
|
}
|
|
private void txtHEmpNumber_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
if (DBUtility.ClsPub.isStrNull(txtHEmpNumber.Text) != "")
|
{
|
DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View();
|
if (oEmp.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHEmpNumber.Text)))
|
{
|
txtHEmpID.Text = oEmp.omodel.HName;
|
txtHEmpID.Tag = oEmp.omodel.HItemID;
|
txtHEmpNumber.Text = "";
|
cmdOK.Focus();
|
}
|
else
|
{
|
MessageBox.Show("错误的工号!");
|
|
txtHEmpID.Text = "";
|
txtHEmpID.Tag = 0;
|
}
|
}
|
else
|
{
|
txtHEmpID.Text = "";
|
txtHEmpID.Tag = 0;
|
}
|
}
|
}
|
|
private void cmdHSourceID2_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
if (oSource.RefreshView())
|
{
|
txtHSourceID2.Text = oSource.oModel.HNumber;
|
txtHSourceID2.Tag = oSource.oModel.HItemID.ToString();
|
txtHSourceName2.Text = oSource.oModel.HName;
|
}
|
else
|
{
|
txtHSourceID2.Text = "";
|
txtHSourceName2.Text = "";
|
}
|
}
|
|
private void cmdHSourceID3_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
if (oSource.RefreshView())
|
{
|
txtHSourceID3.Text = oSource.oModel.HNumber;
|
txtHSourceID3.Tag = oSource.oModel.HItemID.ToString();
|
txtHSourceName3.Text = oSource.oModel.HName;
|
}
|
else
|
{
|
txtHSourceID3.Text = "";
|
txtHSourceName3.Text = "";
|
}
|
}
|
|
private void cmdHSourceID4_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
if (oSource.RefreshView())
|
{
|
txtHSourceID4.Text = oSource.oModel.HNumber;
|
txtHSourceID4.Tag = oSource.oModel.HItemID.ToString();
|
txtHSourceName4.Text = oSource.oModel.HName;
|
}
|
else
|
{
|
txtHSourceID4.Text = "";
|
txtHSourceName4.Text = "";
|
}
|
}
|
|
private void cmdHSourceID5_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
if (oSource.RefreshView())
|
{
|
txtHSourceID5.Text = oSource.oModel.HNumber;
|
txtHSourceID5.Tag = oSource.oModel.HItemID.ToString();
|
txtHSourceName5.Text = oSource.oModel.HName;
|
}
|
else
|
{
|
txtHSourceID5.Text = "";
|
txtHSourceName5.Text = "";
|
}
|
}
|
/// <summary>
|
/// 限制文本框只能输入正整数
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
public void VailInt(object sender, KeyPressEventArgs e)
|
{
|
if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
|
{
|
e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
|
}
|
else if (Char.IsPunctuation(e.KeyChar))
|
{
|
e.Handled = true;
|
}
|
}
|
|
private void txtHQty_KeyPress(object sender, KeyPressEventArgs e)
|
{
|
VailInt(sender, e);
|
}
|
|
//新增
|
private void cmdXZ_Click(object sender, EventArgs e)
|
{
|
this.Sub_AddBill();
|
}
|
}
|
}
|