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;
|
|
namespace WorkM
|
{
|
public partial class MES_StationEntrustInBill : Form
|
{
|
public MES_StationEntrustInBill()
|
{
|
InitializeComponent();
|
}
|
public string ModName = "3792";
|
public string ModCaption = "委外工序发出";
|
public const string ModRightName = "MES_StationEntrustInBill";
|
public const string ModRightNameEdit = ModRightName + "_Edit";
|
public const string ModRightNameDelete = ModRightName + "_Delete";
|
public const string ModRightNameMoney = ModRightName + "_Money";
|
public bool BillChange; //
|
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
public Int64 KeyID;
|
public bool grdStatus;
|
public DAL.ClsSc_StationEntrustInBill BillNew = new DAL.ClsSc_StationEntrustInBill();
|
public DAL.ClsSc_StationEntrustInBill BillOld = new DAL.ClsSc_StationEntrustInBill();
|
|
public Int64 lngBillKey;
|
public Int64 lngBillSubKey;
|
public Int64 lngBillKey_WW;
|
public Int64 lngBillSubKey_WW = -1;
|
//-------------------------------------------------------------------------
|
#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;
|
txtHWWWorkOrderBillNo.Enabled = true;
|
txtHProcNo.Enabled = true;
|
txtHBarCode.Enabled = true;
|
tabControl1.SelectedIndex = 0;
|
txtHBarCode.Focus();
|
lngBillKey = 0;
|
}
|
|
//初始化GRID
|
private void initGrid()
|
{
|
DBUtility.Xt_BaseBillFun.initGridMESList(grdCardList, this.Name + "grdCardList");
|
grdCardList.DataSource = null;
|
}
|
//进站按钮
|
private void cmdOK_Click(object sender, EventArgs e)
|
{
|
this.Sub_SaveBill();
|
cmdCancel.Focus();
|
}
|
private void cmdOK_KeyDown(object sender, KeyEventArgs 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_StationEntrustInBill_Load(object sender, EventArgs e)
|
{
|
//打印初始化
|
this.Text = ModCaption;
|
this.lblCaption.Text = ModCaption;
|
//判断金额权限
|
if (!ClsPub.Security_Log(ModRightNameMoney, 1, false, DBUtility.ClsPub.CurUserName))
|
{
|
txtHPrice.Visible = false;
|
txtHMoney.Visible = false;
|
label18.Visible = false;
|
label19.Visible = false;
|
txtHRemark.Visible = false;
|
label20.Visible = false;
|
}
|
}
|
//窗体尺寸变化时
|
private void Sc_StationEntrustInBill_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_StationEntrustInBill_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
|
//DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
}
|
//新增单据
|
private void Sub_AddBill()
|
{
|
this.BillNew = new DAL.ClsSc_StationEntrustInBill();
|
this.BillOld = new DAL.ClsSc_StationEntrustInBill();
|
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;
|
DataSet DsJG;
|
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("流转卡卡无效!");
|
return;
|
}
|
|
if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "out" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "自制")
|
{
|
MessageBox.Show("该流转卡卡下道工序为自制出站!");
|
return;
|
}
|
else if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "out" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "委外")
|
{
|
MessageBox.Show("该流转卡卡下道工序为委外接收!");
|
return;
|
}
|
else if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "in" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "自制")
|
{
|
MessageBox.Show("该流转卡卡下道工序为自制进站!");
|
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]["板数"]);
|
txtHSupID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]);
|
txtHSupID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["供应商"]);
|
txtHTaxRate.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["税率"]);
|
|
//DsJG = oCn.RunProcReturn("exec h_p_MES_GetSupPrice " + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"])
|
// + " ," + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"])
|
// + " ," + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcID"]), "h_p_MES_GetSupPrice");
|
//if (DsJG == null)
|
//{
|
// MessageBox.Show("获取单价失败!","提示");
|
// return;
|
//}
|
//if (DsJG.Tables[0].Rows.Count == 0)
|
//{
|
txtHPrice.Text = "0";
|
txtHMoney.Text = "0";
|
txtHRemark.Text = "";
|
//}
|
//else
|
//{
|
// txtHPrice.Text = ClsPub.isStrNull(ClsPub.isDoule(DsJG.Tables[0].Rows[0][0],6));
|
// txtHMoney.Text = ClsPub.isStrNull(ClsPub.isDoule(ClsPub.isDoule(Ds.Tables[0].Rows[0]["板数"]) * ClsPub.isDoule(ClsPub.isDoule(DsJG.Tables[0].Rows[0][0],6)),4));
|
// txtHRemark.Text = DsJG.Tables[0].Rows[0][1].ToString();
|
//}
|
|
}
|
//TOOLBAR状态 按钮是否灰度
|
public void Sub_OperStatus()
|
{
|
switch (BillStatus)
|
{
|
case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View:
|
//浏览状态
|
grdStatus = false;
|
cmdOK.Enabled = false;
|
cmdCancel.Enabled = true;
|
cmdXG.Enabled = true;
|
Sub_LrtextStatus(false);
|
break;
|
case DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew:
|
//新增状态
|
grdStatus = true;
|
cmdOK.Enabled = true;
|
cmdCancel.Enabled = true;
|
cmdXG.Enabled = false;
|
Sub_LrtextStatus(true);
|
break;
|
case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify:
|
//修改状态
|
grdStatus = true;
|
cmdOK.Enabled = true;
|
cmdCancel.Enabled = true;
|
cmdXG.Enabled = false;
|
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.ClsIF_Supplier_View oSup = new DAL.ClsIF_Supplier_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 (oSup.GetInfoByID(BillOld.omodel.HSupID))
|
{
|
this.txtHSupID.Text = oSup.omodel.HName;
|
this.txtHSupID.Tag = oSup.omodel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHSupID.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.HName;
|
this.txtHSourceID.Tag = oSource.omodel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHSourceID.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.HName;
|
this.txtHGroupID.Tag = oGroup.omodel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHGroupID.Text = "";
|
}
|
//
|
this.txtHBillNo.Text = BillOld.omodel.HBillNo;
|
this.txtHInnerBillNo.Text = BillOld.omodel.HInnerBillNo;
|
this.txtHICMOBillNo.Text = BillOld.omodel.HICMOBillNo;
|
this.txtHICMOBillNo.Tag = BillOld.omodel.HICMOInterID;
|
lngBillKey = BillOld.omodel.HProcExchInterID;
|
lngBillSubKey = BillOld.omodel.HProcExchEntryID;
|
lngBillKey_WW = BillOld.omodel.HWWWorkOrderInterID;
|
lngBillSubKey_WW = BillOld.omodel.HWWWorkOrderEntryID;
|
this.txtHWWWorkOrderBillNo.Text = BillOld.omodel.HWWWorkOrderBillNo;
|
|
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.txtHQty.Text = BillOld.omodel.HQty.ToString();
|
this.txtHPieceQty.Text = BillOld.omodel.HPieceQty.ToString();
|
this.txtHSourceName.Text = BillOld.omodel.HSourceName.ToString();
|
this.txtHPrice.Text = BillOld.omodel.HPrice.ToString();
|
this.txtHMoney.Text = BillOld.omodel.HMoney.ToString();
|
this.txtHRemark.Text = BillOld.omodel.HRemark.ToString();
|
this.txtHTaxRate.Text = BillOld.omodel.HTaxRate.ToString();
|
this.txtHProcNo.Text = BillOld.omodel.HProcNo.ToString();
|
this.txtHOrderProcNO.Text = BillOld.omodel.HOrderProcNO;
|
|
Sub_OperStatus();
|
|
|
txtHProcExchBillNo.Enabled = false;
|
txtHProcNo.Enabled = false;
|
}
|
|
//单据完整性判断 未完成
|
private bool Sub_AllowSave()
|
{
|
//判断该用户名是否有该工站权限
|
//if (BillNew.CheckCenterIDByUser(DBUtility.ClsPub.isLong(66865)) == 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_WW) <= 0)
|
//{
|
// MessageBox.Show("委外工单号没有选择!", "提示");
|
// return false;
|
//}
|
//if (DBUtility.ClsPub.isLong(lngBillSubKey_WW) < 0)
|
//{
|
// MessageBox.Show("委外工单号没有选择2!", "提示");
|
// return false;
|
//}
|
|
|
if (DBUtility.ClsPub.isLong(lngBillKey) <= 0)
|
{
|
MessageBox.Show("流转卡没有选择!", "提示");
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(lngBillSubKey) <= 0)
|
{
|
MessageBox.Show("流水号2没有选择!", "提示");
|
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(txtHGroupID.Tag) == 0)
|
//{
|
// MessageBox.Show("生产班组没有选择!", "提示");
|
// return false;
|
//}
|
|
if (DBUtility.ClsPub.isLong(txtHSupID.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;
|
}
|
return true;
|
}
|
//保存单据
|
private bool Sub_SaveBill()
|
{
|
Model.ClsSc_StationEntrustInBillSub oBillSub = new Model.ClsSc_StationEntrustInBillSub();
|
//判断权限
|
if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
|
{
|
return false;
|
}
|
//
|
Int32 i;
|
bool bResult;
|
BillNew = new DAL.ClsSc_StationEntrustInBill();
|
//失去焦点
|
lblCaption.Focus();
|
if (!Sub_AllowSave())//单据完整性判断
|
return false;
|
//赋值ID
|
if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
|
BillNew.omodel.HInterID = BillOld.omodel.HInterID;
|
//主类赋值
|
BillNew.omodel.HYear = 2011;
|
BillNew.omodel.HPeriod = 1;
|
BillNew.omodel.HBillNo = this.txtHBillNo.Text.Trim();
|
BillNew.omodel.HInnerBillNo = this.txtHInnerBillNo.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.HSupID = DBUtility.ClsPub.isLong(this.txtHSupID.Tag);
|
BillNew.omodel.HPieceQty = DBUtility.ClsPub.isDoule(this.txtHPieceQty.Text);
|
BillNew.omodel.HSourceName = DBUtility.ClsPub.isStrNull(this.txtHSourceName.Text);
|
BillNew.omodel.HPrice =ClsPub.isDoule( ClsPub.isDoule(this.txtHPrice.Text,6));
|
BillNew.omodel.HMoney = ClsPub.isDoule(ClsPub.isDoule(this.txtHMoney.Text,4));
|
BillNew.omodel.HRemark = DBUtility.ClsPub.isStrNull(this.txtHRemark.Text);
|
BillNew.omodel.HTaxRate = DBUtility.ClsPub.isDoule(this.txtHTaxRate.Text);
|
BillNew.omodel.HProcNo = DBUtility.ClsPub.isLong(this.txtHProcNo.Text);
|
BillNew.omodel.HOrderProcNO = DBUtility.ClsPub.isStrNull(this.txtHOrderProcNO.Text);
|
|
BillNew.omodel.HWWWorkOrderInterID = lngBillKey_WW;
|
BillNew.omodel.HWWWorkOrderEntryID = lngBillSubKey_WW;
|
BillNew.omodel.HWWWorkOrderBillNo = DBUtility.ClsPub.isStrNull(this.txtHWWWorkOrderBillNo.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(), "提示");
|
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.HName;
|
txtHSourceID.Tag = oSource.oModel.HItemID.ToString();
|
}
|
else
|
{
|
txtHSourceID.Text = "";
|
}
|
}
|
|
private void txtHSourceID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHSourceID);
|
}
|
|
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);
|
}
|
|
private void txtHGroupID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHGroupID);
|
}
|
|
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.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View();
|
|
//
|
this.txtHICMOBillNo.Tag = oTable.Rows[0]["hicmointerid"].ToString();
|
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.txtHQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["生产数量"], 0);
|
this.txtHQty.Text = "0";
|
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"]);
|
lngBillKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HMainID"]);
|
txtHProcExchBillNo.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["单据号"]);
|
txtHICMOQty.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["任务单数量"]);
|
this.txtHOrderProcNO.Text = oTable.Rows[0]["订单跟踪号"].ToString();
|
|
//加载表体
|
|
}
|
|
|
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;
|
// LotShow();
|
// }
|
// 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;
|
}
|
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.HName;
|
txtHSourceID.Tag = oSource.omodel.HItemID;
|
}
|
else
|
{
|
txtHSourceID.Text = "";
|
txtHSourceID.Tag = 0;
|
}
|
}
|
else
|
{
|
txtHSourceID.Text = "";
|
txtHSourceID.Tag = 0;
|
}
|
}
|
}
|
|
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.HName;
|
txtHGroupID.Tag = oGroup.omodel.HItemID;
|
}
|
else
|
{
|
txtHGroupID.Text = "";
|
txtHGroupID.Tag = 0;
|
}
|
}
|
else
|
{
|
txtHGroupID.Text = "";
|
txtHGroupID.Tag = 0;
|
}
|
}
|
}
|
|
private void cmdAddNew_Click(object sender, EventArgs e)
|
{
|
lngBillKey = 0;
|
lngBillSubKey = 0;
|
Sub_AddBill();
|
}
|
|
private void cmbHSupID_Click(object sender, EventArgs e)
|
{
|
BLL.ClsBaseSelect.SetTextBySupplier(txtHSupID);
|
//GetPrice();
|
}
|
|
private void txtHSupID_KeyDown(object sender, KeyEventArgs e)
|
{
|
//if (e.KeyCode == Keys.Enter)
|
//{
|
// //获取控件位置
|
// int x = 0; int y = 0;
|
// BLL.ClsPub_BLL.SetXY(this, panel2, gbUp, txtHSupID, ref x, ref y);
|
// //选择基础
|
// DAL.ClsIF_Supplier_View oSup = new DAL.ClsIF_Supplier_View();
|
// if (oSup.RefreshViewDownMenu(" and (HNumber like '%" + txtHSupID.Text + "%' or HName like '%" + txtHSupID.Text + "%') ", x, y))
|
// {
|
// txtHSupID.Text = oSup.oModel.HName;
|
// txtHSupID.Tag = oSup.oModel.HItemID.ToString();
|
// //txtHSupID.ForeColor = System.Drawing.Color.Blue;
|
// txtHSupID.SelectAll();
|
// }
|
// else
|
// {
|
// txtHSupID.Text = "";
|
// //txtHSupID.ForeColor = System.Drawing.Color.Black;
|
// }
|
// GetPrice();
|
// txtHPrice.Select();
|
//}
|
}
|
private void GetPrice()
|
{
|
DataSet DsJG;
|
DataSet DsTaxRate;
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
SQLHelper.ClsCNK3 oCnK3 = new SQLHelper.ClsCNK3();
|
long HSupID = ClsPub.isLong(txtHSupID.Tag);
|
long HMaterID = ClsPub.isLong(txtHMaterID.Tag);
|
long HProcID = ClsPub.isLong(txtHProcID.Tag);
|
//
|
DsTaxRate = oCnK3.RunProcReturn("select FValueAddRate from t_Supplier where FItemID=" + HSupID, "h_p_MES_GetSupPrice");
|
if (DsTaxRate == null || DsTaxRate.Tables[0].Rows.Count == 0)
|
{
|
txtHTaxRate.Text = "0";
|
}
|
else
|
{
|
txtHTaxRate.Text = DsTaxRate.Tables[0].Rows[0]["FValueAddRate"].ToString();
|
}
|
//
|
DsJG = oCn.RunProcReturn("exec h_p_MES_GetSupPrice " + HSupID+ " ," + HMaterID+ " ," + HProcID, "h_p_MES_GetSupPrice");
|
if (DsJG == null)
|
{
|
MessageBox.Show("获取单价失败!", "提示");
|
return;
|
}
|
if (DsJG.Tables[0].Rows.Count == 0)
|
{
|
txtHPrice.Text = "0";
|
txtHMoney.Text = "0";
|
txtHRemark.Text = "";
|
}
|
else
|
{
|
txtHPrice.Text = ClsPub.isStrNull(DBUtility.ClsPub.isDoule(DsJG.Tables[0].Rows[0][0], 6));
|
txtHMoney.Text = ClsPub.isStrNull(ClsPub.isDoule(ClsPub.isDoule(txtHQty.Text) * ClsPub.isDoule(ClsPub.isDoule(DsJG.Tables[0].Rows[0][0], 6)), 4));
|
txtHRemark.Text = DsJG.Tables[0].Rows[0][1].ToString();
|
}
|
}
|
|
private void txtHSupID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHSupID);
|
}
|
//编辑单据
|
private void Sub_EditBill()
|
{
|
//判断权限
|
if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
|
{
|
return;
|
}
|
////判断该用户名是否有该工站权限
|
//if (BillNew.CheckCenterIDByUser(DBUtility.ClsPub.isLong(66865)) == false)
|
//{
|
// MessageBox.Show("没有该工站权限!", "提示");
|
// return;
|
//}
|
////检查是否开票
|
//string d = "";
|
//if (BillOld.CheckIsKP(BillOld.omodel.HInterID, ref d) == false)
|
//{
|
// MessageBox.Show(d, "提示");
|
// return;
|
//}
|
string s = "";
|
if (BillOld.ShowBill(BillOld.omodel.HInterID, ref s) == false)
|
{
|
MessageBox.Show("此单据有错误!", "提示");
|
return;
|
}
|
//判断是否可编辑
|
|
//判断是否可编辑
|
if (BillOld.omodel.HChecker != "")
|
{
|
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;
|
//}
|
|
Sub_EditBill();
|
}
|
|
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;
|
}
|
|
//得到信息
|
Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "' and 工序号='" + sProcNo + "' and 下道流转工序<>'转' and 委外标记=1 and 流转标记=1 ", "h_v_Sc_ProcessExchangeBillList");
|
//写入信息
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
txtHProcNo.Text = "";
|
MessageBox.Show("流水号错误,请重新输入!");
|
return;
|
}
|
if (DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["委外标记"].ToString()) != true)
|
{
|
MessageBox.Show("该工序不是委外工序,请重新输入!");
|
return;
|
}
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
Sub_WriteInForm_SM2(Ds.Tables[0], i);
|
}
|
//获取加工费 从委外价格表
|
int sHSupID = ClsPub.isInt(txtHSupID.Tag.ToString());
|
int sHMaterID = ClsPub.isInt(txtHMaterID.Tag.ToString());
|
Ds = oCn.RunProcReturn("select top 1 * from Gy_ProcCommPrice where HMaterID= '" + sHMaterID + "' and HSupID='" + sHSupID + "'", "Gy_ProcCommPrice");
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
this.txtHPrice.Text = "";
|
this.txtHTaxRate.Text = "";
|
|
}
|
else
|
{
|
this.txtHPrice.Text = Ds.Tables[0].Rows[0]["HPrice"].ToString();
|
this.txtHTaxRate.Text = Ds.Tables[0].Rows[0]["HTaxRate"].ToString();
|
}
|
txtHQty.Focus();
|
//txtHProcID.Enabled = false;
|
//cmdHProcID.Enabled = false;
|
//txtHSupID.Enabled = false;
|
//cmbHSupID.Enabled = false;
|
}
|
}
|
|
//根据TABLE写入界面
|
private void Sub_WriteInForm_SM2(DataTable oTable, int i)
|
{
|
DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View();
|
|
lngBillSubKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HSubID"]);
|
lngBillKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HMainID"]);
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet ds;
|
lngBillSubKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HSubID"]);
|
lngBillKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HMainID"]);
|
//判断是否存在对应 委外工单
|
ds = oCn.RunProcReturn("exec h_p_MES_StationEntrustOutBill_Ctrl " + lngBillKey.ToString() + "," + lngBillSubKey.ToString() + "", "h_p_MES_StationEntrustOutBill_Ctrl");
|
if (ds == null || ds.Tables[0].Rows.Count ==0 )
|
{
|
MessageBox.Show("判断委外工单失败!");
|
txtHProcNo.Text="";
|
txtHProcNo.Focus();
|
return;
|
|
}
|
else
|
{
|
if(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0][0])=="2")
|
{
|
MessageBox.Show(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]));
|
txtHProcNo.Text="";
|
txtHProcNo.Focus();
|
return;
|
}
|
}
|
|
|
this.txtHProcID.Tag = oTable.Rows[0]["HProcID"].ToString();
|
this.txtHProcID.Text = oTable.Rows[0]["工序"].ToString();
|
this.txtHSupID.Tag = oTable.Rows[0]["HSupID"].ToString();
|
this.txtHSupID.Text = oTable.Rows[0]["供应商"].ToString();
|
|
//根据流转卡内码 获取工单内码(唯一工单或者唯一未接受完毕工单)
|
//如果 没有扫描 及 流水号 则 报错
|
if (lngBillKey == 0 || lngBillSubKey == 0)
|
{
|
return;
|
}
|
//根据工号获取委外工单 及内码,子内码
|
//SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
ds = oCn.RunProcReturn("exec h_p_WW_GetWWWorkBillInfoByHProcExch " + lngBillKey.ToString() + "," + lngBillSubKey.ToString(), "h_p_WW_GetWWWorkBillInfoByHProcExch");
|
if (ds == null)
|
{
|
//MessageBox.Show("没有找到对应的委外工单!");
|
return;
|
}
|
if (ds.Tables[0].Rows.Count > 0 && DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"])==0)
|
{
|
txtHWWWorkOrderBillNo.Text = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]);
|
lngBillKey_WW = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HInterID"]);
|
lngBillSubKey_WW = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HEntryID"]);
|
txtHWWWorkOrderBillNo.Enabled = false;
|
}
|
|
}
|
|
private void txtHQty_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
cmdOK.Select();
|
}
|
}
|
|
private void txtHPrice_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
txtHMoney.Text = Pub_Class.ClsPub.isStrNull(Pub_Class.ClsPub.isDoule(txtHQty.Text) * Pub_Class.ClsPub.isDoule(txtHPrice.Text) * (1.00 + ((Pub_Class.ClsPub.isDoule(txtHTaxRate.Text) / 100.00))));
|
|
cmdOK.Select();
|
}
|
}
|
|
private void txtHMoney_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
txtHRemark.Select();
|
}
|
}
|
|
private void txtHPrice_Leave(object sender, EventArgs e)
|
{
|
// txtHMoney.Text = ClsPub.isStrNull(ClsPub.isDoule(ClsPub.isDoule(txtHQty.Text) * ClsPub.isDoule(ClsPub.isDoule(txtHPrice.Text, 6)),4));
|
txtHMoney.Text = Pub_Class.ClsPub.isStrNull(Pub_Class.ClsPub.isDoule(txtHQty.Text) * Pub_Class.ClsPub.isDoule(txtHPrice.Text) * (1.00 + ((Pub_Class.ClsPub.isDoule(txtHTaxRate.Text) / 100.00))));
|
|
}
|
|
private void txtHMoney_Leave(object sender, EventArgs e)
|
{
|
//if (ClsPub.isDoule(txtHQty.Text) == 0)
|
//{
|
// txtHPrice.Text = "0";
|
//}
|
//else
|
//{
|
// txtHPrice.Text = ClsPub.isStrNull(ClsPub.isDoule(ClsPub.isDoule(txtHMoney.Text) / ClsPub.isDoule(txtHQty.Text), 6));
|
//}
|
}
|
//金额=数量*单价*(1+税率的百分比)
|
private void txtHTaxRate_TextChanged(object sender, EventArgs e)
|
{
|
txtHMoney.Text = Pub_Class.ClsPub.isStrNull(Pub_Class.ClsPub.isDoule(txtHQty.Text) * Pub_Class.ClsPub.isDoule(txtHPrice.Text) * (1.00 + ((Pub_Class.ClsPub.isDoule(txtHTaxRate.Text) / 100.00))));
|
}
|
|
private void txtHPrice_TextChanged(object sender, EventArgs e)
|
{
|
txtHMoney.Text = Pub_Class.ClsPub.isStrNull(Pub_Class.ClsPub.isDoule(txtHQty.Text) * Pub_Class.ClsPub.isDoule(txtHPrice.Text) * (1.00 + ((Pub_Class.ClsPub.isDoule(txtHTaxRate.Text) / 100.00))));
|
}
|
|
private void txtHQty_TextChanged(object sender, EventArgs e)
|
{
|
txtHMoney.Text = Pub_Class.ClsPub.isStrNull(Pub_Class.ClsPub.isDoule(txtHQty.Text) * Pub_Class.ClsPub.isDoule(txtHPrice.Text) * (1.00 + ((Pub_Class.ClsPub.isDoule(txtHTaxRate.Text) / 100.00))));
|
}
|
|
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_StationEntrustInBill_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_StationEntrustInBill oBill = new DAL.ClsSc_StationEntrustInBill();
|
//查看是否已审核,关闭,作废
|
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 txtHWWWorkOrderBillNo_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Return)
|
{
|
//如果 没有扫描 及 流水号 则 报错
|
if (lngBillKey == 0 || lngBillSubKey == 0)
|
{
|
MessageBox.Show("没有录入流转卡号或者流水号");
|
return;
|
}
|
//根据工号获取委外工单 及内码,子内码
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet ds;
|
ds = oCn.RunProcReturn("exec h_p_WW_GetWWWorkBillInfoByNo '" + txtHWWWorkOrderBillNo.Text + "'," + lngBillKey.ToString() + "," + lngBillSubKey.ToString(), "h_p_WW_GetWWWorkBillInfoByNo");
|
if (ds == null)
|
{
|
MessageBox.Show("没有找到对应的委外工单!");
|
return;
|
}
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
txtHWWWorkOrderBillNo.Text = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]);
|
lngBillKey_WW = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HInterID"]);
|
lngBillSubKey_WW = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HEntryID"]);
|
txtHWWWorkOrderBillNo.Enabled = false;
|
}
|
|
}
|
}
|
|
GridppReport Report;
|
|
private void button3_Click(object sender, EventArgs e)
|
{
|
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.PrintPreview(true);
|
}
|
}
|
|
//找到对应打印模块
|
private void Sub_SetReport(string sOpenTmp)
|
{
|
//
|
Report = new GridppReport();
|
Report.LoadFromFile(ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here .
|
Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
|
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
|
}
|
|
//赋值表头
|
private void ReportBeforePostRecord()//
|
{
|
//Report.FieldByName("编号").AsString = txtHBillNo.Text;
|
//Report.FieldByName("日期").AsString = dtpHDate.Value.ToString();
|
//Report.FieldByName("部门").AsString = txtHDeptID.Text;
|
//Report.FieldByName("业务员").AsString = txtHEmpID.Text;
|
//Report.FieldByName("表头备注").AsString = txtHRemark.Text;
|
|
//Report.FieldByName("制单人").AsString = txtHMaker.Text;
|
//Report.FieldByName("客户").AsString = txtHCusID.Text;
|
//Report.FieldByName("交货日期").AsString = dtpHSSDate.Value.ToString();
|
//Report.FieldByName("结算方式").AsString = txtHSSID.Text;
|
//Report.FieldByName("交货地点").AsString = txtHAddress.Text;
|
//Report.FieldByName("审核日期").AsString = txtHCheckDate.Text;
|
//Report.FieldByName("审核人员").AsString = txtHChecker.Text;
|
}
|
//赋值表体
|
private void ReportFetchRecordByDataTable()
|
{
|
//DataTable dt = new DataTable();
|
//BLL.Utility.FillRecordToReport(Report, grdMain, dt, HMaterIDCol);
|
}
|
|
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;
|
}
|
|
|
//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();
|
//}
|
}
|
|
//新增
|
private void cmdXZ_Click(object sender, EventArgs e)
|
{
|
this.Sub_AddBill();
|
}
|
}
|
}
|