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 System.Threading;
|
using System.IO.Ports;
|
|
namespace SCM
|
{
|
public partial class Sc_ICMOReportToBarCode : Form
|
{
|
public Sc_ICMOReportToBarCode()
|
{
|
InitializeComponent();
|
}
|
|
public frmBillQueryCondition_Base frmCondition;
|
public string ModCaption = "成品分切在线检验";
|
public string ModName = "Sc_ICMOReportToBarCode";
|
public string HSourceBillTypeID = ""; //单据类型
|
public string HSourceBillType = ""; //单据类型名称
|
public string HSourceBillNo = "";
|
public Int64 HSourceInterID = 0;
|
public Int64 HSourceEntryID = 0;
|
public int HTMCol = 0;
|
public int HMaterIDCol = 1;
|
Pub_Class.ClsGridListSum oSumGrid = new Pub_Class.ClsGridListSum();
|
public Int32 iTopRow = 0;//画横线
|
SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1();
|
//
|
|
#region 固定代码
|
|
//清空界面
|
public void Sub_ClearBill()
|
{
|
//清空界面控件 for 控件
|
foreach (Control ct in gbUp.Controls)
|
{
|
switch (ct.GetType().Name)
|
{
|
case "ComboBox":
|
((ComboBox)ct).SelectedIndex = 0;
|
break;
|
case "TextBox":
|
((TextBox)ct).Text = "";
|
break;
|
case "DateTimePicker":
|
((DateTimePicker)ct).Value = DateTime.Today;
|
break;
|
default:
|
break;
|
}
|
}
|
//
|
txtHMaker.Text = ClsPub.CurUserName;
|
initGrid();
|
}
|
|
private void Sc_ICMOReportToBarCode_Load(object sender, EventArgs e)
|
{
|
//设置动态URL
|
oWeb.Url = SCM.ClsPub1.WEBSURL;
|
//
|
frmCondition = new frmBillQueryCondition_Base();
|
this.Text = ModCaption;
|
oSumGrid.ogrdMain = grdSub; //初始化 new
|
oSumGrid.oGridsum = grdSum;
|
initGrid();
|
//cmbHBillType.SelectedIndex = 0;
|
//cmbHSourceBillType.SelectedIndex = 0;
|
cmbFQMB.Items.Add(this.Text);
|
cmbFQMB.SelectedIndex = 0;
|
|
if(DBUtility.ClsPub.CurUserName.ToLower()=="admin")
|
{
|
txtHDQQty.ReadOnly = false;
|
txtHKSQty.ReadOnly = false;
|
}
|
}
|
|
//初始化网格
|
private void initGrid()
|
{
|
ClsPub1.initGridList(grdMain, this.Name);
|
ClsPub1.initGridList(grdSub, this.Name + "grdSub");
|
ClsPub1.initGridFst(grdEmp, this.Name + "grdEmp");
|
grdMain.RowTemplate.Height = 30;
|
grdMain.RowTemplate.MinimumHeight = 30;
|
grdMain.RowsDefaultCellStyle.Font = new Font("宋体", 15);
|
grdMain.ReadOnly = true;
|
|
grdSub.RowTemplate.Height = 30;
|
grdSub.RowTemplate.MinimumHeight = 30;
|
grdSub.RowsDefaultCellStyle.Font = new Font("宋体", 15);
|
grdSub.ReadOnly = true;
|
|
grdEmp.RowTemplate.Height = 30;
|
grdEmp.RowTemplate.MinimumHeight = 30;
|
grdEmp.RowsDefaultCellStyle.Font = new Font("宋体", 15);
|
grdEmp.ReadOnly = false;
|
//DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name);
|
//DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub");
|
DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name);
|
DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub");
|
DBUtility.Xt_BaseBillFun.GetGrid(grdEmp, this.Name + "grdEmp");
|
}
|
|
//时间控件
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled=false;
|
Sub_ClearBill();
|
}
|
|
private void timer2_Tick(object sender, EventArgs e)
|
{
|
timer2.Enabled = false;
|
//
|
if (ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini").Contains("没有找到")==false)
|
{
|
txtPortName.Text = ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
txtBaudRate.Text = ClsIni.ReadIni("COMINFO", "txtBaudRate", DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
cmbParity.Text = ClsIni.ReadIni("COMINFO", "cmbParity", DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
txtDataBits.Text = ClsIni.ReadIni("COMINFO", "txtDataBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
cmbStopBits.Text = ClsIni.ReadIni("COMINFO", "cmbStopBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
txtHSend0.Text = ClsIni.ReadIni("COMINFO", "txtHSend0", DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
txtHSend.Text = ClsIni.ReadIni("COMINFO", "txtHSend", DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
txtHSourceID.Text = ClsIni.ReadIni("COMINFO", "txtHSourceID", DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
txtHSourceID.Tag = ClsIni.ReadIni("COMINFO", "txtHSourceIDTag", DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
this.Text = this.Text + "-" + txtHSourceID.Text;
|
}
|
|
//初始化串口
|
ComDevice = new SerialPort();
|
ComDevice.DataReceived += new SerialDataReceivedEventHandler(Com_DataReceived);//绑定事件
|
string[] PortNames = SerialPort.GetPortNames();
|
//打开串口
|
OpenCom();
|
}
|
|
//退出
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void grdMain_Paint(object sender, PaintEventArgs e)
|
{
|
GraphicsGrid();
|
}
|
|
private void GraphicsGrid()
|
{
|
//画底线
|
DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
|
//画横线
|
DBUtility.Xt_BaseBillFun.GraphicsRowGrid(grdMain, iTopRow, iTopRow + 50, Fun_GetCol("hmainid"));
|
}
|
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
|
}
|
|
//保存列宽
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub");
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdEmp, this.Name + "grdEmp");
|
}
|
|
//默认列宽
|
private void mrlk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub");
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdEmp, this.Name + "grdEmp");
|
}
|
|
#endregion
|
|
|
#region 返回源单信息
|
|
private void xd_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
|
private void Display(string SourceBillType, Int64 HSourceBillInterID, Int64 HSourceBillEntryID)
|
{
|
DataSet Ds;
|
//生产订单
|
if (SourceBillType == "生产订单")
|
{
|
//得到信息
|
Ds = oWeb.getDataSetBySQL("select * from h_v_IFCLD_ICMOList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IFCLD_ICMOList", ref DBUtility.ClsPub.sExeReturnInfo);
|
//写入信息
|
Sub_WriteInForm(Ds.Tables[0], 0);
|
}
|
//收料通知单
|
if (SourceBillType == "收料通知单")
|
{
|
//得到信息
|
Ds = oWeb.getDataSetBySQL("select * from h_v_IF_POInStockList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo);
|
//写入信息
|
Sub_WriteInForm(Ds.Tables[0], 0);
|
}
|
//生产汇报单
|
if (SourceBillType == "生产汇报单")
|
{
|
//得到信息
|
Ds = oWeb.getDataSetBySQL("select * from h_v_IF_ICMOReportBillList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo);
|
//写入信息
|
Sub_WriteInForm(Ds.Tables[0], 0);
|
}
|
}
|
|
//根据TABLE写入界面
|
private void Sub_WriteInForm(DataTable oTable, int i)
|
{
|
try
|
{
|
txtHSourceBillNo.Text = oTable.Rows[0]["单据号"].ToString();
|
txtHMaterNumber.Text = oTable.Rows[0]["物料代码"].ToString();
|
txtHOldMaterNumber.Text = oTable.Rows[0]["旧物料编码"].ToString();
|
txtHMaterNumber.Tag = oTable.Rows[0]["HMaterID"].ToString();
|
txtHMaterName.Text = oTable.Rows[0]["物料名称"].ToString();
|
txtHMaterName.Tag = oTable.Rows[0]["HMaterID"].ToString();
|
txtHMaterModel.Text = oTable.Rows[0]["规格型号"].ToString();
|
txtHUnitName.Text = oTable.Rows[0]["计量单位"].ToString();
|
txtHUnitName.Tag = oTable.Rows[0]["HUnitID"].ToString();
|
txtHBatchNo.Text = oTable.Rows[0]["批次"].ToString();
|
txtHSumQty.Text = oTable.Rows[0]["数量"].ToString();
|
txtHRelationQty.Text = oTable.Rows[0]["已生成条码数量"].ToString();
|
txtHSYQty.Text = oTable.Rows[0]["未生成条码数量"].ToString();
|
txtHKSQty.Text = lblHNowQty.Text;
|
txtHDQQty.Text = lblHNowQty.Text;
|
if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text)>0)
|
{
|
txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 2);
|
}
|
else
|
{
|
txtHSJQty.Text = "0";
|
}
|
DisplayMain();
|
//DisplaySub();
|
}
|
catch(Exception e)
|
{
|
MessageBox.Show("读取失败!" + e.Message);
|
}
|
}
|
|
|
private void DisplayMain()
|
{
|
DataSet DSet;
|
string sSql = "";
|
string sWhere = "";
|
//过滤条件
|
sSql = " exec h_p_Sc_ICMOReportToBarCode_All '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString();
|
//
|
DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_All", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
MessageBox.Show("没有返回任何结果,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
if (DSet.Tables[0].Rows.Count>0)
|
{
|
grdMain.DataSource = DSet.Tables[0].DefaultView;
|
}
|
//冻结
|
int FrCol = DBUtility.ClsPub.isInt(0);
|
string s = "是";
|
ClsPub1.DisplayGrid(grdMain, this.Name, s, FrCol);
|
//画线
|
//Total();
|
///////////////////////////////////////////
|
if (DSet.Tables[1].Rows.Count > 0)
|
{
|
grdSub.DataSource = DSet.Tables[1].DefaultView;
|
}
|
//冻结
|
ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol);
|
/////////////////////////////
|
txtHRelationQty.Text = DBUtility.ClsPub.isDoule(DSet.Tables[2].Rows[0]["关联数量"], 2);
|
if(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text)>=0)
|
{
|
txtHSYQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text), 2);
|
}
|
else
|
{
|
txtHSYQty.Text = "0";
|
}
|
//////////////////////////
|
}
|
|
private void DisplaySub()
|
{
|
DataSet DSet;
|
string sSql = "";
|
string sWhere = "";
|
//过滤条件
|
sSql = " exec h_p_Sc_ICMOReportToBarCode_Sub '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString();
|
|
//
|
DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_Sub", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
MessageBox.Show("没有返回任何结果,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdSub.DataSource = DSet.Tables[0].DefaultView;
|
|
|
//冻结
|
int FrCol = DBUtility.ClsPub.isInt(0);
|
string s = "是";
|
ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol);
|
//画线
|
//Total();
|
}
|
|
|
#endregion
|
|
|
#region //打印设置
|
|
GridppReport Report;
|
string sBarCode = "";
|
|
//预览
|
int CurRows = 0;
|
|
|
|
|
|
|
|
#endregion
|
|
|
#region 界面控件处理
|
|
private void cmdHDeptID_Click(object sender, EventArgs e)
|
{
|
SCM.ClsIF_Department_View oDept = new SCM.ClsIF_Department_View();
|
string sWhere = "";
|
if (oDept.RefreshView(sWhere))
|
{
|
this.txtHDeptID.Text = oDept.oModel.HName;
|
this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHDeptID.Text = "";
|
}
|
}
|
|
private void txtHDeptID_TextChanged(object sender, EventArgs e)
|
{
|
BLL.ClsPub_BLL.Sub_ClearText(txtHDeptID);
|
}
|
|
#endregion
|
|
|
//选择源单
|
private void cmdHSourceBillNo_Click(object sender, EventArgs e)
|
{
|
Gy_SourceBillList_Touch oGy_SourceBillList_Touch = new Gy_SourceBillList_Touch();
|
oGy_SourceBillList_Touch.HSourceBillType = HSourceBillType;//类型名称
|
oGy_SourceBillList_Touch.ShowDialog();
|
if (oGy_SourceBillList_Touch.OKTag == 1)
|
{
|
//根据选中的源单内码和子内码,返回相应信息
|
HSourceEntryID = oGy_SourceBillList_Touch.HSelEntryID;
|
HSourceInterID = oGy_SourceBillList_Touch.HSelInterID;
|
HSourceBillTypeID = oGy_SourceBillList_Touch.HSourceBillTypeID;
|
HSourceBillNo = oGy_SourceBillList_Touch.HSourceBillNo;
|
Display(HSourceBillType, oGy_SourceBillList_Touch.HSelInterID, oGy_SourceBillList_Touch.HSelEntryID);
|
}
|
else
|
{
|
HSourceEntryID = 0;
|
HSourceInterID = 0;
|
HSourceBillTypeID = "";
|
HSourceBillNo = "";
|
}
|
}
|
|
//
|
private void cmdCancel_Click(object sender, EventArgs e)
|
{
|
CloseCom();
|
this.Close();
|
}
|
|
private void label19_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
public bool SaveBill(string sType)
|
{
|
try
|
{
|
int LSHlen = 2; //流水号长度
|
int SumLen = 10; //总长度
|
string TM = ""; //条码
|
string HNumber = ""; //物料代码
|
double HSumQty = 0; //产品数量
|
double HMinQty = 0; //最小包装数
|
int HBQty = 0; //箱数
|
double HQty = 0; //数量
|
string WeiShu = ""; //尾数
|
int LSH = 0; //流水号
|
string LSH2 = ""; //流水号转换成字符
|
string sDate = ""; //日期
|
string sYear = ""; //年
|
string sPeriod = ""; //月
|
string sDay = ""; //日
|
string HBatchNo = ""; //批次
|
int k = 0;
|
int n = 0; //同一批生成条码中的第几条
|
string sTMNumber = ""; //条码自定义前缀
|
DataSet Ds;
|
//
|
string HWei = ""; //尾数
|
HBarCode = "";
|
string HBarCodeType = "";
|
Int64 HMaterID = 0;
|
Int64 HAuxPropID = 0;
|
Int64 HUnitID = 0;
|
double HQty2 = 0;
|
string HBatchNo2 = "";
|
Int64 HSupID = 0;
|
Int64 HGroupID = 0;
|
int HPrintQty = 0;
|
Int64 HBarcodeNo = 0; //托号
|
Int64 HBarcodeQtys = 0; //总托数
|
Int64 HDeptID = 0;
|
Int64 HWhID = 0;
|
Int64 HSPID = 0;
|
string HRemark = "";
|
string HMaterName = "";
|
string HMaterModel = "";
|
string HPinfan = "";
|
string HMTONo = "";
|
Int64 HCusID = 0;
|
string HCusType = "";
|
DateTime HEndDate;
|
string HWorkLineName = "";
|
DateTime HBeginDate;
|
string HSeOrderBillNo = "";
|
string HJiaYe2 = "";
|
string HPressModel = "";
|
string HCusModel = "";
|
string HMaterialModel = "";
|
string HColor = "";
|
string HLogo = "";
|
string HPackageSize = "";
|
double HMaterialJQty = 0;
|
double HMaterialMQty = 0;
|
string HCustomBatchNo = "";
|
string HGBBarCode = "";
|
string POOrderBillNo = "";
|
//
|
cmdHSaveBill.Enabled = false;
|
//判断是否存在 源单信息;
|
if (HSourceInterID <= 0 || HSourceEntryID <= 0 || DBUtility.ClsPub.isLong(txtHMaterName.Tag) <= 0 || DBUtility.ClsPub.isLong(txtHUnitName.Tag) <= 0)//判断是否有源单
|
{
|
MessageBox.Show("没有选单!");
|
cmdHSaveBill.Enabled = true;
|
return false;
|
}
|
if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text) >= 0)
|
{
|
txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 2); //实际米数= 当前米数-开始米数
|
lblHRelQty.Text = txtHSJQty.Text;
|
}
|
else
|
{
|
if (MessageBox.Show("当前米数小于开始米数,是否确定要清零开始米数", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
txtHKSQty.Text = "0";
|
txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text), 2); //实际米数= 当前米数-开始米数
|
lblHRelQty.Text = txtHSJQty.Text;
|
}
|
}
|
if (DBUtility.ClsPub.isDoule(txtHSJQty.Text) <= 0)
|
{
|
MessageBox.Show("当前数量不能小于等于0!");
|
cmdHSaveBill.Enabled = true;
|
return false;
|
}
|
//if (DBUtility.ClsPub.isDoule(txtHSYQty.Text) <= 0)
|
//{
|
// MessageBox.Show("剩余数量已经为0,不能在裁切!");
|
// cmdHSaveBill.Enabled = true;
|
// return false;
|
//}
|
if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0 || DBUtility.ClsPub.isLong(txtHEmpID2.Tag) == 0 )
|
{
|
MessageBox.Show("职员1或者职员2没有选择!");
|
cmdHSaveBill.Enabled = true;
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(txtHGroupID.Tag) == 0 )
|
{
|
MessageBox.Show("班组没有选择!");
|
cmdHSaveBill.Enabled = true;
|
return false;
|
}
|
|
|
//根据源单 生成条形码 并保存如数据库
|
HNumber = DBUtility.ClsPub.isStrNull(txtHMaterName.Tag);
|
HBatchNo = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text);
|
sDate = dtpHDate.Value.ToShortDateString();
|
sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
|
sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
|
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
|
sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
|
sDay = sDay.Substring(sDay.Length - 2, 2);
|
|
//条码前缀 = 组织代码 + 物料内码 + 年 + 月 + 日
|
//sTMNumber = HOrgNumber + HNumber + sYear + sPeriod + sDay;
|
//sTMNumber = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text);
|
//获取最大流水号,降等品加CP后缀以重新生成流水号
|
if (sType == "SaveDown")
|
{
|
sTMNumber = HNumber + ";" + DBUtility.ClsPub.isStrNull(txtHBatchNo.Text) + "CP";
|
}
|
else if (sType == "Sample")
|
{
|
sTMNumber = HNumber + ";" + DBUtility.ClsPub.isStrNull(txtHBatchNo.Text) + "B";
|
}
|
else
|
{
|
sTMNumber = HNumber + ";" + DBUtility.ClsPub.isStrNull(txtHBatchNo.Text);
|
}
|
//sTMNumber = HNumber + ";" + DBUtility.ClsPub.isStrNull(txtHBatchNo.Text);
|
|
Ds = oWeb.getDataSetBySQL("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo", ref DBUtility.ClsPub.sExeReturnInfo);//获取最大流水号
|
LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
|
|
//
|
HQty = DBUtility.ClsPub.isDoule(txtHSJQty.Text);
|
//
|
string sSQLNoMul = " exec h_p_WMS_SetMaxNo '" + sTMNumber + "' ";
|
oWeb.getRunProc(sSQLNoMul, ref DBUtility.ClsPub.sExeReturnInfo);
|
//
|
HWei = "";
|
LSH = LSH + 1;
|
LSH2 = LSH.ToString();
|
while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0
|
{
|
LSH2 = "0" + LSH2;
|
}
|
|
//条码编号 = 条码前缀 + 流水号
|
//降等品时增加CP后缀
|
string sTMNumberNew = HNumber + ";" + DBUtility.ClsPub.isStrNull(txtHBatchNo.Text);
|
if (sType == "SaveDown")
|
{
|
TM = sTMNumberNew + "CP-" + LSH2;
|
}
|
else if (sType == "Sample")
|
{
|
TM = sTMNumberNew + "B-" + LSH2;
|
}
|
else
|
{
|
TM = sTMNumberNew + "-" + LSH2;
|
}
|
//TM = sTMNumber + "-" + LSH2;
|
|
HBarCode = TM;
|
HBarCodeType = "唯一条码";
|
|
HMaterID = DBUtility.ClsPub.isLong(txtHMaterName.Tag);
|
HAuxPropID = 0;
|
HUnitID = DBUtility.ClsPub.isLong(txtHUnitName.Tag);
|
HQty2 = HQty;
|
//HBatchNo2 = HBatchNo;
|
//if (HSourceBillType != "生产订单")
|
//{
|
//HBatchNo2 = TM;
|
//HBatchNo2 = HBatchNo + "-" + LSH2;
|
//判断按钮类型给批次增加后缀
|
if (sType == "SaveDown")
|
{
|
HBatchNo2 = HBatchNo + "CP-" + LSH2;
|
}
|
else if (sType == "Sample")
|
{
|
HBatchNo2 = HBatchNo + "B-" + LSH2;
|
}
|
else
|
{
|
HBatchNo2 = HBatchNo + "-" + LSH2;
|
}
|
//}
|
//HSourceBillType = HSourceBillTypeID;
|
HBarcodeQtys = 0;
|
HBarcodeNo = 1;
|
HSupID = 0;
|
HDeptID = 0;
|
HWhID = 0;
|
HSPID = 0;
|
if (sType == "SaveDown")
|
{
|
HRemark = "二等品";
|
}
|
else if (sType == "Sample")
|
{
|
HRemark = "样本纸";
|
}
|
else
|
{
|
HRemark = "";
|
}
|
HMaterName = DBUtility.ClsPub.isStrNull(txtHMaterName.Text);
|
HMaterModel = DBUtility.ClsPub.isStrNull(txtHMaterModel.Text);
|
HPinfan = "";
|
HMTONo = "";
|
HCusID = 0;
|
HCusType = "";
|
HEndDate = dtpHDate.Value;
|
HWorkLineName = DBUtility.ClsPub.isStrNull(txtHEmpID.Text) + ";" + DBUtility.ClsPub.isStrNull(txtHEmpID2.Text) + ";" + DBUtility.ClsPub.isStrNull(txtHEmpID3.Text);
|
HBeginDate = dtpHDate.Value;
|
HSeOrderBillNo = "";
|
HGroupID = DBUtility.ClsPub.isLong(txtHGroupID.Tag);
|
HJiaYe2 = DBUtility.ClsPub.isLong(txtHEmpID.Tag).ToString() + ";" + DBUtility.ClsPub.isLong(txtHEmpID2.Tag).ToString() + ";" + DBUtility.ClsPub.isLong(txtHEmpID3.Tag).ToString();
|
HPressModel = "";
|
HCusModel = "";
|
HMaterialModel = "";
|
HColor = "";
|
HLogo = "";
|
HPackageSize = "";
|
HMaterialJQty = 0;
|
HMaterialMQty = 0;
|
HCustomBatchNo = "";
|
HGBBarCode = "";
|
POOrderBillNo = "";
|
string sSQLMul = " 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,HJiaYe " +
|
",HPressModel,HCusModel,HMaterialModel,HColor,HBarCodeDate " +
|
",HLogo,HPackageSize,HMaterialJQty,HMaterialMQty,HCustomBatchNo " +
|
",HSTOCKORGID,HOWNERID,HBeginDate,HSeOrderBillNo,HGBBarCode " +
|
",POOrderBillNo,HSourceID " +
|
",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo " +
|
") values ("
|
+ "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
|
+ ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
|
+ ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillTypeID + "','" + HWei + "'"
|
+ ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
|
+ ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + HJiaYe2 + "'"
|
+ ",'" + HPressModel + "','" + HCusModel + "','" + HMaterialModel + "','" + HColor + "','" + sDate + "'"
|
+ ",'" + HLogo + "','" + HPackageSize + "'," + HMaterialJQty.ToString() + "," + HMaterialMQty.ToString() + ",'" + HCustomBatchNo + "'"
|
+ ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HBeginDate.ToShortDateString() + "','" + HSeOrderBillNo + "','" + HGBBarCode + "'"
|
+ ",'" + POOrderBillNo + "'" + "," + DBUtility.ClsPub.isLong(txtHSourceID.Tag)
|
+ ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "')";
|
oWeb.getRunProc(sSQLMul, ref DBUtility.ClsPub.sExeReturnInfo);
|
|
|
//刷新界面
|
DisplayMain();
|
//DisplaySub();
|
//根据界面选择打印模板,打印条形码
|
Sub_SetReport(cmbFQMB.Text);
|
if (DBUtility.ClsPub.CurUserName.ToLower() == "admin")
|
{
|
Report.PrintPreview(false);
|
}
|
else
|
{
|
Report.Print(false);
|
}
|
|
Thread.Sleep(500);
|
|
if (HSourceBillType != "生产汇报单")
|
{
|
txtHKSQty.Text = "0";
|
}
|
|
cmdHSaveBill.Enabled = true;
|
return true;
|
}
|
catch (Exception e1)
|
{
|
MessageBox.Show("保存失败!" + e1.Message);
|
cmdHSaveBill.Enabled = true;
|
return false;
|
}
|
}
|
|
public string HOrgNumber = "1001";
|
public Int64 HOrgID = 1;
|
public string HBarCode = "";
|
|
//保存 并生成打印条码
|
private void cmdHSaveBill_Click(object sender, EventArgs e)
|
{
|
SaveBill("");
|
}
|
|
|
private void Sub_SetReport(string sOpenTmp)
|
{
|
//判断行数
|
|
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 Sub_SetReportList(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(ReportBeforePostRecordList);
|
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTableList);
|
//Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
|
}
|
|
//填入单据表头信息
|
private void ReportBeforePostRecord()//
|
{
|
try
|
{
|
Report.FieldByName("物料代码").AsString = ClsPub.isStrNull(txtHMaterNumber.Text);
|
Report.FieldByName("物料名称").AsString = ClsPub.isStrNull(txtHMaterName.Text);
|
Report.FieldByName("规格型号").AsString = ClsPub.isStrNull(txtHMaterModel.Text);
|
Report.FieldByName("条码编号").AsString = HBarCode;
|
Report.FieldByName("数量").AsString = ClsPub.isStrNull(txtHSJQty.Text);
|
Report.FieldByName("班组").AsString = ClsPub.isStrNull(txtHGroupID.Text);
|
Report.FieldByName("组员").AsString = ClsPub.isStrNull(txtHEmpID.Text) + ";" + ClsPub.isStrNull(txtHEmpID2.Text) + ";" + ClsPub.isStrNull(txtHEmpID3.Text);
|
Report.FieldByName("数量").AsString = ClsPub.isStrNull(txtHSJQty.Text);
|
Report.FieldByName("旧物料编码").AsString = ClsPub.isStrNull(txtHOldMaterNumber.Text);
|
//Report.FieldByName("源单单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value);
|
//Report.FieldByName("销售订单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSeOrderBillNo2Col].Value);
|
//Report.FieldByName("生产车间").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HDeptName2Col].Value);
|
//Report.FieldByName("备注").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HRemark2Col].Value);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表头:" + e.Message);
|
}
|
}
|
|
private void ReportFetchRecordByDataTable()
|
{
|
try
|
{
|
DataTable ds = new DataTable();
|
BLL.Utility.FillRecordToReport_FstRow(Report, grdMain, ds, 0);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表体:" + e.Message);
|
}
|
}
|
|
//填入单据表头信息
|
private void ReportBeforePostRecordList()//
|
{
|
try
|
{
|
//Report.FieldByName("物料代码").AsString = ClsPub.isStrNull(txtHMaterNumber.Text);
|
//Report.FieldByName("物料名称").AsString = ClsPub.isStrNull(txtHMaterName.Text);
|
//Report.FieldByName("规格型号").AsString = ClsPub.isStrNull(txtHMaterModel.Text);
|
//Report.FieldByName("条码编号").AsString = HBarCode;
|
//Report.FieldByName("数量").AsString = ClsPub.isStrNull(txtHSJQty.Text);
|
//Report.FieldByName("源单单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value);
|
//Report.FieldByName("销售订单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSeOrderBillNo2Col].Value);
|
//Report.FieldByName("生产车间").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HDeptName2Col].Value);
|
//Report.FieldByName("备注").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HRemark2Col].Value);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表头:" + e.Message);
|
}
|
}
|
|
private void ReportFetchRecordByDataTableList()
|
{
|
try
|
{
|
DataTable ds = new DataTable();
|
SCM.Utility.FillRecordToReport(Report, grdMain, ds, Fun_GetCol("选择"));
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表体:" + e.Message);
|
}
|
}
|
|
private SerialPort ComDevice = null;
|
|
public void OpenCom()
|
{
|
if (!ComDevice.IsOpen)
|
{
|
|
try
|
{
|
ComDevice.PortName = txtPortName.Text;
|
ComDevice.BaudRate = int.Parse(txtBaudRate.Text);
|
switch (cmbParity.SelectedItem.ToString())
|
{
|
case "0":
|
ComDevice.Parity = Parity.None;
|
break;
|
case "1":
|
ComDevice.Parity = Parity.Odd;
|
break;
|
case "2":
|
ComDevice.Parity = Parity.Even;
|
break;
|
case "3":
|
ComDevice.Parity = Parity.Mark;
|
break;
|
case "4":
|
ComDevice.Parity = Parity.Space;
|
break;
|
default:
|
break;
|
}
|
|
ComDevice.DataBits = int.Parse(txtDataBits.Text);
|
switch (cmbStopBits.SelectedItem.ToString())
|
{
|
case "0":
|
ComDevice.StopBits = StopBits.None;
|
break;
|
case "1":
|
ComDevice.StopBits = StopBits.One;
|
break;
|
case "2":
|
ComDevice.StopBits = StopBits.Two;
|
break;
|
case "1.5":
|
ComDevice.StopBits = StopBits.OnePointFive;
|
break;
|
default:
|
break;
|
}
|
|
ComDevice.Open();
|
lblComStatus.Text = "串口状态:开启";
|
timer3.Enabled = true;
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show("打开串口失败!" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
return;
|
}
|
}
|
else
|
{
|
//try
|
//{
|
// ComDevice.Close();
|
// textBox3.Enabled = true;
|
// textBox4.Enabled = true;
|
// textBox5.Enabled = true;
|
// comboBox1.Enabled = true;
|
// comboBox2.Enabled = true;
|
// AddContent($"串口已关闭");
|
// button1.Enabled = false;
|
// btnPush.Text = "开启串口";
|
//}
|
//catch (Exception ex)
|
//{
|
// MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
// AddContent($"串口关闭失败:{ex.Message}");
|
// return;
|
//}
|
}
|
}
|
|
private void cmdOpenCom_Click(object sender, EventArgs e)
|
{
|
OpenCom();
|
}
|
|
private void cmdCloseCom_Click(object sender, EventArgs e)
|
{
|
CloseCom();
|
}
|
|
public void CloseCom()
|
{
|
if (!ComDevice.IsOpen)
|
{
|
|
}
|
else
|
{
|
try
|
{
|
ComDevice.Close();
|
lblComStatus.Text = "串口状态:关闭";
|
timer3.Enabled = false;
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
return;
|
}
|
}
|
}
|
|
//设备清零
|
private void cmdHSetZero_Click(object sender, EventArgs e)
|
{
|
cmdHSetZero.Enabled=false;
|
byte[] sendData = strToHexByte(txtHSend0.Text);
|
SendData(sendData);
|
txtHSJQty.Text = "0";
|
txtHDQQty.Text = "0";
|
txtHKSQty.Text = "0";
|
lblHNowQty.Text = "0";
|
lblHRelQty.Text = "0";
|
cmdHSetZero.Enabled = true;
|
}
|
|
/// <summary>
|
/// 字符串转换16进制字节数组
|
/// </summary>
|
/// <param name="hexString"></param>
|
/// <returns></returns>
|
private byte[] strToHexByte(string hexString)
|
{
|
hexString = hexString.Replace(" ", "");
|
if ((hexString.Length % 2) != 0)
|
hexString += " ";
|
byte[] returnBytes = new byte[hexString.Length / 2];
|
for (int i = 0; i < returnBytes.Length; i++)
|
returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2).Replace(" ", ""), 16);
|
return returnBytes;
|
}
|
|
|
/// <summary>
|
/// 发送数据
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="data"></param>
|
public bool SendData(byte[] data)
|
{
|
if (ComDevice.IsOpen)
|
{
|
try
|
{
|
ComDevice.Write(data, 0, data.Length);//发送数据
|
return true;
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
}
|
finally
|
{
|
//cmdHSetZero.Enabled = true;
|
}
|
}
|
else
|
{
|
MessageBox.Show("串口未打开", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
}
|
return false;
|
}
|
|
private void timer3_Tick(object sender, EventArgs e)
|
{
|
if (!ComDevice.IsOpen)
|
{
|
return;
|
}
|
byte[] sendData = strToHexByte(txtHSend.Text);
|
SendData(sendData);
|
|
}
|
|
/// <summary>
|
/// 接收数据
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void Com_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
{
|
//if (!ComDevice.IsOpen)
|
//{
|
// return;
|
//}
|
Thread.Sleep(100);
|
byte[] ReDatas = new byte[ComDevice.BytesToRead];
|
ComDevice.Read(ReDatas, 0, ReDatas.Length);//读取数据
|
this.AddData(ReDatas);//输出数据
|
}
|
|
|
///// <summary>
|
///// 添加数据
|
///// </summary>
|
///// <param name="data">字节数组</param>
|
//public void AddData(byte[] data)
|
//{
|
// StringBuilder sb = new StringBuilder();
|
// for (int i = 0; i < data.Length; i++)
|
// {
|
// sb.AppendFormat("{0:x2}" + " ", data[i]);
|
// }
|
// string str = sb.ToString().ToUpper() ;
|
// string[] strArr = str.Split(' ');
|
// string newStr = string.Empty;
|
// try
|
// {
|
// if (strArr[4] != "00")
|
// {
|
// char[] bw = strArr[4].ToCharArray();
|
// if(bw[0]=='0')
|
// {
|
// newStr = bw[1].ToString();
|
// }
|
// else
|
// {
|
// newStr = strArr[4];
|
// }
|
|
// }
|
// if (string.IsNullOrEmpty(newStr))
|
// {
|
// char[] bw = strArr[5].ToCharArray();
|
// if (bw[0] == '0')
|
// {
|
// newStr = bw[1].ToString();
|
// }
|
// else
|
// {
|
// newStr = strArr[5];
|
// }
|
// }
|
// else
|
// {
|
// newStr += strArr[5];
|
// }
|
// if (strArr[6] != "00" && newStr=="00")
|
// {
|
// //newStr = $"0.{strArr[6]}";
|
// newStr = "0." + strArr[6];
|
// }
|
// if(strArr[6]!="00" && newStr != "00")
|
// {
|
// //newStr += $".{strArr[6]}";
|
// newStr = newStr + strArr[6];
|
|
// }
|
// }
|
// catch
|
// {
|
// newStr = "-1";
|
// }
|
// //将当前数 厘米 转化为 米
|
// double NewQty = DBUtility.ClsPub.isDoule(newStr) / 100.0000;
|
// if (NewQty <= 0)
|
// {
|
// newStr = "0";
|
// }
|
// else
|
// {
|
// newStr = DBUtility.ClsPub.isDoule(NewQty, 2);
|
// }
|
// //
|
// lblHNowQty.Text = newStr; //当前米数 标签
|
// txtHDQQty.Text = newStr; //当前数量 文本
|
// txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 2); //实际米数= 当前米数-开始米数
|
// lblHRelQty.Text = txtHSJQty.Text;
|
//}
|
|
|
/// <summary>
|
/// 添加数据
|
/// </summary>
|
/// <param name="data">字节数组</param>
|
public void AddData(byte[] data)
|
{
|
StringBuilder sb = new StringBuilder();
|
for (int i = 0; i < data.Length; i++)
|
{
|
sb.AppendFormat("{0:x2}" + " ", data[i]);
|
}
|
var str = sb.ToString().ToUpper().Trim();
|
string[] strArr = str.Split(' ');
|
string newStr = string.Empty;
|
try
|
{
|
if (strArr[4] != "00")
|
{
|
char[] bw = strArr[4].ToCharArray();
|
if(bw[0]=='0')
|
{
|
newStr = bw[1].ToString();
|
}
|
else
|
{
|
newStr = strArr[4];
|
}
|
|
}
|
if (string.IsNullOrEmpty(newStr))
|
{
|
char[] bw = strArr[5].ToCharArray();
|
if (bw[0] == '0')
|
{
|
newStr = bw[1].ToString();
|
}
|
else
|
{
|
newStr = strArr[5];
|
}
|
}
|
else
|
{
|
newStr += strArr[5];
|
}
|
if (strArr[6] != "00"&&newStr=="00")
|
{
|
//newStr = $"0.{strArr[6]}";
|
newStr = "0." + strArr[6];
|
}
|
if(strArr[6]!="00"&&newStr!="00")
|
{
|
//newStr += $".{strArr[6]}";
|
newStr = newStr + "." + strArr[6];
|
}
|
}
|
catch
|
{
|
newStr = "-1";
|
}
|
|
|
//将当前数 厘米 转化为 米
|
double NewQty = DBUtility.ClsPub.isDoule(newStr) ;
|
if (NewQty <= 0)
|
{
|
newStr = "0";
|
}
|
else
|
{
|
newStr = DBUtility.ClsPub.isDoule(NewQty, 2);
|
}
|
//
|
lblHNowQty.Text = newStr; //当前米数 标签
|
txtHDQQty.Text = newStr; //当前数量 文本
|
if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text) > 0)
|
{
|
txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 2); //实际米数= 当前米数-开始米数
|
lblHRelQty.Text = txtHSJQty.Text;
|
}
|
else
|
{
|
txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text), 2); //实际米数= 当前米数-开始米数
|
lblHRelQty.Text = txtHSJQty.Text;
|
}
|
}
|
|
//删除选中的行数
|
private void btnFQSH_Click(object sender, EventArgs e)
|
{
|
DelRow();
|
}
|
|
public void DelRow()
|
{
|
//WEBS
|
//if (!oWeb.getSecurity_Log(ModRightNameEdit, DBUtility.ClsPub.CurUserName, ref DBUtility.ClsPub.sExeReturnInfo))
|
//{
|
// MessageBox.Show("您没有删除权限!");
|
// return;
|
//}
|
DataSet DS;
|
DataSet DS2;
|
bool sBool = true;
|
Int64 lngBillKey = 0;
|
if (grdMain.CurrentRow == null)
|
return;
|
if (MessageBox.Show("确定要删除所选行?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
|
{
|
lngBillKey = DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HItemID")].Value);
|
if (lngBillKey == 0)
|
return;
|
try
|
{
|
oWeb.getRunProc("Delete from Gy_BarCodeBill where HItemID=" + lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo);
|
oWeb.getRunProc("insert into System_log values(GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.CurUserName + "','删除条码:" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条形码")].Value) + "' ,'WMS系统','','删除')", ref DBUtility.ClsPub.sExeReturnInfo);
|
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
}
|
MessageBox.Show("删除成功!", "提示");
|
DisplayMain();
|
}
|
|
private void btnFQBD_Click(object sender, EventArgs e)
|
{
|
//根据界面选择打印模板,打印条形码
|
Sub_SetReportList(cmbFQMB.Text);
|
Report.PrintPreview(false);
|
Thread.Sleep(500);
|
}
|
|
private void cmdHSaveInfo_Click(object sender, EventArgs e)
|
{
|
ClsIni.WriteIni("COMINFO", "txtPortName", DBUtility.ClsPub.isStrNull(txtPortName.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
ClsIni.WriteIni("COMINFO", "txtBaudRate", DBUtility.ClsPub.isStrNull(txtBaudRate.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
ClsIni.WriteIni("COMINFO", "cmbParity", DBUtility.ClsPub.isStrNull(cmbParity.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
ClsIni.WriteIni("COMINFO", "txtDataBits", DBUtility.ClsPub.isStrNull(txtDataBits.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
ClsIni.WriteIni("COMINFO", "cmbStopBits", DBUtility.ClsPub.isStrNull(cmbStopBits.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
ClsIni.WriteIni("COMINFO", "txtHSend0", DBUtility.ClsPub.isStrNull(txtHSend0.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
ClsIni.WriteIni("COMINFO", "txtHSend", DBUtility.ClsPub.isStrNull(txtHSend.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
ClsIni.WriteIni("COMINFO", "txtHSourceID", DBUtility.ClsPub.isStrNull(txtHSourceID.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
ClsIni.WriteIni("COMINFO", "txtHSourceIDTag", DBUtility.ClsPub.isStrNull(txtHSourceID.Tag), DBUtility.ClsPub.AppPath + @"/HXERP.ini");
|
}
|
|
private void btnBLHB_Click(object sender, EventArgs e)
|
{
|
Gy_BadReasonList oGy_BadReasonList = new Gy_BadReasonList();
|
oGy_BadReasonList.ShowDialog();
|
if (oGy_BadReasonList.ISOK == 1)
|
{
|
txtHReasonList.Text = "";
|
txtHReasonList.Text = oGy_BadReasonList.txtHBadReason.Text;
|
if (SaveBadReasonBill())
|
{
|
MessageBox.Show("保存不良原因成功!");
|
|
DisplayMain();
|
}
|
else
|
{
|
MessageBox.Show("保存不良原因失败!" + DBUtility.ClsPub.sExeReturnInfo);
|
}
|
}
|
oGy_BadReasonList = null;
|
}
|
|
private void cmdSaveAndNext_Click(object sender, EventArgs e)
|
{
|
if (SaveBill("Save"))
|
{
|
txtHKSQty.Text = txtHDQQty.Text;//继续裁切,将当前米数作为开始米数;
|
}
|
}
|
|
private void btnBLBD_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void btnBLSH_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void cmdHWaitList_Click(object sender, EventArgs e)
|
{
|
//跳出该产线 未处理的单据
|
Sc_WaitingForCutting_List oSc_WaitingForCutting_List = new Sc_WaitingForCutting_List();
|
if (HSourceBillType == "生产订单")
|
{
|
oSc_WaitingForCutting_List.HBillType = "3710";
|
}
|
else if (HSourceBillType == "生产汇报单")
|
{
|
oSc_WaitingForCutting_List.HBillType = "3711";
|
}
|
else if (HSourceBillType == "收料通知单")
|
{
|
oSc_WaitingForCutting_List.HBillType = "1203";
|
}
|
else
|
{
|
MessageBox.Show("错误的单据类型!");
|
return;
|
}
|
|
oSc_WaitingForCutting_List.ShowDialog();
|
|
}
|
|
private bool SaveBadReasonBill()
|
{
|
try
|
{
|
if (txtHReasonList.Text.Trim() == "")
|
{
|
MessageBox.Show("没有选择不良原因!");
|
return false;
|
}
|
//将选择不良原因分解并保存入数据库
|
WMSWeb.ClsQC_NoPassProdCheckBillMain oQC_NoPassProdCheckBillMain = new WMSWeb.ClsQC_NoPassProdCheckBillMain();
|
oQC_NoPassProdCheckBillMain.HDate = DateTime.Today;
|
oQC_NoPassProdCheckBillMain.HSourceID = DBUtility.ClsPub.isLong(txtHSourceID.Tag);
|
oQC_NoPassProdCheckBillMain.HMaterID = DBUtility.ClsPub.isLong(txtHMaterNumber.Tag);
|
oQC_NoPassProdCheckBillMain.HProcID = DBUtility.ClsPub.isLong(0);
|
oQC_NoPassProdCheckBillMain.HWorkCenterID = DBUtility.ClsPub.isLong(0);
|
oQC_NoPassProdCheckBillMain.HICMOInterID = 0;
|
oQC_NoPassProdCheckBillMain.HICMOBillNo = "";
|
oQC_NoPassProdCheckBillMain.HInStockQty = 0;
|
oQC_NoPassProdCheckBillMain.HCheckQty = 0;
|
oQC_NoPassProdCheckBillMain.HRightQty = 0;
|
oQC_NoPassProdCheckBillMain.HBadQty = DBUtility.ClsPub.isDoule(txtHDQQty.Text);
|
oQC_NoPassProdCheckBillMain.HPlanQty = 0;
|
oQC_NoPassProdCheckBillMain.HBadPNL = 0;
|
oQC_NoPassProdCheckBillMain.HPlanPNL = 0;
|
oQC_NoPassProdCheckBillMain.HFirstCheckEmp = 0;
|
oQC_NoPassProdCheckBillMain.HCheckerResult = txtHReasonList.Text;
|
oQC_NoPassProdCheckBillMain.HNote = "在线检验";
|
oQC_NoPassProdCheckBillMain.HProcExchInterID = HSourceInterID;//源单主内码
|
oQC_NoPassProdCheckBillMain.HProcExchEntryID = HSourceEntryID;//源单子内码
|
oQC_NoPassProdCheckBillMain.HProcExchBillNo = HSourceBillTypeID;//源单类型
|
oQC_NoPassProdCheckBillMain.HMainSourceInterID = 0;
|
oQC_NoPassProdCheckBillMain.HGroupName = "";
|
oQC_NoPassProdCheckBillMain.HOrderProcNo = "";
|
oQC_NoPassProdCheckBillMain.HProcExchQty = 0;
|
if (oWeb.set_SaveNoPassProdCheckBill_New(oQC_NoPassProdCheckBillMain, HSourceBillTypeID, txtHReasonList.Text.Trim(), ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
txtHReasonList.Text = "";
|
return true;
|
}
|
txtHReasonList.Text = "";
|
return false;
|
}
|
catch(Exception e1)
|
{
|
MessageBox.Show(e1.Message);
|
return false;
|
}
|
}
|
|
private void cmdHSourceID_Click(object sender, EventArgs e)
|
{
|
SCM.ClsIF_Source_View oSource = new SCM.ClsIF_Source_View();
|
string sWhere = "";
|
if (oSource.RefreshView(sWhere))
|
{
|
this.txtHSourceID.Text = oSource.oModel.HName;
|
this.txtHSourceID.Tag = oSource.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHSourceID.Text = "";
|
}
|
}
|
|
private void cmdSaveAndDown_Click(object sender, EventArgs e)
|
{
|
if (SaveBill("SaveDown"))
|
{
|
txtHKSQty.Text = txtHDQQty.Text;//继续裁切,将当前米数作为开始米数;
|
}
|
}
|
|
private void cmdHGroupID_Click(object sender, EventArgs e)
|
{
|
SCM.ClsIF_Group_View oGroup= new SCM.ClsIF_Group_View();
|
string sWhere = "";
|
if (oGroup.RefreshView(sWhere))
|
{
|
this.txtHGroupID.Text = oGroup.oModel.HName;
|
this.txtHGroupID.Tag = oGroup.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHGroupID.Text = "";
|
}
|
}
|
|
private void txtHSourceID_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHSourceID.Text.Trim() == "")
|
{
|
txtHSourceID.Tag = "";
|
}
|
}
|
|
private void txtHGroupID_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHGroupID.Text.Trim() == "")
|
{
|
txtHGroupID.Tag = "";
|
}
|
}
|
|
private void cmdHEmp_Click(object sender, EventArgs e)
|
{
|
SCM.ClsIF_Employee_View oEmp = new SCM.ClsIF_Employee_View();
|
string sWhere = "";
|
if (oEmp.RefreshView(sWhere))
|
{
|
this.txtHEmpID.Text = oEmp.oModel.HName;
|
this.txtHEmpID.Tag = oEmp.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHEmpID.Text = "";
|
}
|
}
|
|
private void cmdHEmp2_Click(object sender, EventArgs e)
|
{
|
SCM.ClsIF_Employee_View oEmp = new SCM.ClsIF_Employee_View();
|
string sWhere = "";
|
if (oEmp.RefreshView(sWhere))
|
{
|
this.txtHEmpID2.Text = oEmp.oModel.HName;
|
this.txtHEmpID2.Tag = oEmp.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHEmpID2.Text = "";
|
}
|
}
|
|
private void txtHEmpID_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHEmpID.Text.Trim() == "")
|
{
|
txtHEmpID.Tag = "";
|
}
|
}
|
|
private void txtHEmpID2_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHEmpID2.Text.Trim() == "")
|
{
|
txtHEmpID2.Tag = "";
|
}
|
}
|
|
private void cmdHEmp3_Click(object sender, EventArgs e)
|
{
|
SCM.ClsIF_Employee_View oEmp = new SCM.ClsIF_Employee_View();
|
string sWhere = "";
|
if (oEmp.RefreshView(sWhere))
|
{
|
this.txtHEmpID3.Text = oEmp.oModel.HName;
|
this.txtHEmpID3.Tag = oEmp.oModel.HItemID.ToString();
|
}
|
else
|
{
|
this.txtHEmpID3.Text = "";
|
}
|
}
|
|
private void txtHEmpID3_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHEmpID3.Text.Trim() == "")
|
{
|
txtHEmpID3.Tag = "";
|
}
|
}
|
|
private void cmdZero_Click(object sender, EventArgs e)
|
{
|
txtHKSQty.Text = "0";
|
txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 2);
|
|
}
|
|
private void cmdSaveAndDown2_Click(object sender, EventArgs e)
|
{
|
if (SaveBill("Sample"))
|
{
|
txtHKSQty.Text = txtHDQQty.Text;//继续裁切,将当前米数作为开始米数;
|
}
|
}
|
|
}
|
}
|