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.Net.Sockets;
|
using System.Net;
|
using System.Drawing.Printing;
|
using System.IO;
|
using System.Management;
|
|
namespace WarM
|
{
|
public partial class Gy_BarCodeBill_automaticallyByPLC_New : Form
|
{
|
public Gy_BarCodeBill_automaticallyByPLC_New()
|
{
|
InitializeComponent();
|
}
|
//定义
|
public const Int16 HTagCol = 0;
|
public const Int16 HSnoCol = 1;
|
public const Int16 HMainIDCol = 2;
|
public const Int16 HSubIDCol = 3;
|
public const Int16 HBillNoCol = 4;
|
public const Int16 HBillTypeCol = 5;
|
public const Int16 HMaterIDCol = 6;
|
public const Int16 HMaterNumberCol = 7;
|
public const Int16 HMaterNameCol = 8;
|
public const Int16 HPinfanCol = 9;//
|
public const Int16 HMaterModelCol = 10;//
|
public const Int16 HModelCol = 11;
|
public const Int16 HAuxPropIDCol = 12;
|
public const Int16 HAuxPropNumberCol = 13;
|
public const Int16 HAuxPropNameCol = 14;
|
public const Int16 HUnitIDCol = 15;
|
public const Int16 HUnitNumberCol = 16;
|
public const Int16 HUnitNameCol = 17;
|
public const Int16 HBarCodeTypeCol = 18;
|
public const Int16 HBatchManagerCol = 19;
|
public const Int16 HBatchNoCol = 20;
|
public const Int16 HGiveAwayFlagCol = 21;
|
public const Int16 HQtyCol = 22;
|
public const Int16 HMinQtyCol = 23;
|
public const Int16 HBQtyCol = 24;
|
public const Int16 HPackQtyCol = 25;
|
public const Int16 HProduceDateCol = 26;
|
public const Int16 HExpiryDateCol = 27;
|
public const Int16 HDeptIDCol = 28;
|
public const Int16 HDeptNumberCol = 29;
|
public const Int16 HDeptNameCol = 30;
|
public const Int16 HSourceIDCol = 31;
|
public const Int16 HSourceNumberCol = 32;
|
public const Int16 HSourceNameCol = 33;
|
public const Int16 HDateCol = 34;
|
public const Int16 HEndDateCol = 35;
|
public const Int16 HSupIDCol = 36;
|
public const Int16 HSupNumberCol = 37;
|
public const Int16 HSupNameCol = 38;
|
public const Int16 HCusIDCol = 39;
|
public const Int16 HCusNumberCol = 40;
|
public const Int16 HCusNameCol = 41;
|
public const Int16 HCusTypeCol = 42;
|
public const Int16 HSourceInterIDCol = 43;
|
public const Int16 HSourceEntryIDCol = 44;
|
public const Int16 HSourceBillNoCol = 45;
|
public const Int16 HSourceBillTypeCol = 46;
|
public const Int16 HInstructIDCol = 47;
|
public const Int16 HInstructNoCol = 48;
|
public const Int16 HSeOrderBillIDCol = 49;
|
public const Int16 HSeOrderBillNoCol = 50;
|
public const Int16 HSeOrderSEQCol = 51;
|
public const Int16 HWhIDCol = 52;
|
public const Int16 HWhNumberCol = 53;
|
public const Int16 HWhNameCol = 54;
|
public const Int16 HSPIDCol = 55;
|
public const Int16 HSPNumberCol = 56;
|
public const Int16 HSPNameCol = 57;
|
public const Int16 HinitQtyCol = 58;
|
public const Int16 HRemarkCol = 59;
|
public const Int16 HPinfanBarCodeCol = 60;
|
public const Int16 HMTONoCol = 61;
|
public const Int16 HShowDateCol = 62;
|
public const Int16 HInnerBillNoCol = 63;
|
public const Int16 HMakerCol = 64;
|
public const Int16 HISKFPERIODCol = 65;
|
public const Int16 HEXPUNITCol = 66;
|
public const Int16 HEXPPERIODCol = 67;
|
|
public Int16 HSelectCol = 0;
|
public Int16 HSno2Col = 1;
|
public Int16 HTMCol = 2;
|
public Int16 HBarCodeType2Col = 3;
|
public Int16 HMaterID2Col = 4;
|
public Int16 HMaterNumber2Col = 5;
|
public Int16 HMaterName2Col = 6;
|
public Int16 HPinfan2Col = 7;
|
public Int16 HMaterModel2Col = 8;
|
public Int16 HModel2Col = 9;
|
public Int16 HAuxPropID2Col = 10;
|
public Int16 HAuxPropNumber2Col = 11;
|
public Int16 HAuxPropName2Col = 12;
|
public Int16 HBatchNo2Col = 13;
|
public Int16 HGiveAwayFlag2Col = 14;
|
public Int16 HUnitID2Col = 15;
|
public Int16 HUnitNumber2Col = 16;
|
public Int16 HUnitName2Col = 17;
|
public Int16 HQty2Col = 18;
|
public Int16 HWeiCol = 19;
|
public Int16 HPrintCol = 20;
|
public Int16 HDeptID2Col = 21;
|
public Int16 HDeptNumber2Col = 22;
|
public Int16 HDeptName2Col = 23;
|
public Int16 HSourceID2Col = 24;
|
public Int16 HSourceNumber2Col = 25;
|
public Int16 HSourceName2Col = 26;
|
public Int16 HDate2Col = 27;
|
public Int16 HEndDate2Col = 28;
|
public Int16 HBarcodeNoCol = 29;
|
public Int16 HBarcodeQtysCol = 30;
|
public Int16 HSupID2Col = 31;
|
public Int16 HSupNumber2Col = 32;
|
public Int16 HSupName2Col = 33;
|
public Int16 HCusID2Col = 34;
|
public Int16 HCusNumber2Col = 35;
|
public Int16 HCusName2Col = 36;
|
public Int16 HCusType2Col = 37;
|
public Int16 HSourceInterID2Col = 38;
|
public Int16 HSourceEntryID2Col = 39;
|
public Int16 HSourceBillNo2Col = 40;
|
public Int16 HSourceBillType2Col = 41;
|
public Int16 HInstructID2Col = 42;
|
public Int16 HInstructNo2Col = 43;
|
public Int16 HSeOrderBillID2Col = 44;
|
public Int16 HSeOrderBillNo2Col = 45;
|
public Int16 HSeOrderSEQ2Col = 46;
|
public Int16 HWhID2Col = 47;
|
public Int16 HWhNumber2Col = 48;
|
public Int16 HWhName2Col = 49;
|
public Int16 HSPID2Col = 50;
|
public Int16 HSPNumber2Col = 51;
|
public Int16 HSPName2Col = 52;
|
public Int16 HRemark2Col = 53;
|
public Int16 HPinfanBarCode2Col = 54;
|
public Int16 HMTONo2Col = 55;
|
public Int16 HShowDate2Col = 56;
|
public Int16 HInnerBillNo2Col = 57;
|
public Int16 HMaker2Col = 58;
|
public Int16 HEntryID2Col = 59;
|
public Int16 HProduceDate2Col = 60;
|
public Int16 HExpiryDate2Col = 61;
|
public Int16 HISKFPERIOD2Col = 62;
|
public Int16 HEXPUNIT2Col = 63;
|
public Int16 HEXPPERIOD2Col = 64;
|
//
|
public string ModName = "85";
|
public string ModCaption = "条码生成";
|
public const string ModRightName = "Gy_BarCodeBill";
|
public const string ModRightNameSourceQty = ModRightName + "_SourceQty"; //超源单数量控制
|
public bool BillChange; //
|
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
public DBUtility.ClsXt_BaseBill BaseBill;
|
//public WarM.WMSWeb.WebService1 oWeb = new WarM.WMSWeb.WebService1();
|
public Int64 KeyID;
|
public bool grdStatus;
|
//public DAL.ClsGy_BarCodeBill BillNew =new DAL.ClsGy_BarCodeBill();
|
//public DAL.ClsGy_BarCodeBill BillOld = new DAL.ClsGy_BarCodeBill();
|
public DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
ClsGridViewSum oSumGrid = new ClsGridViewSum();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
public int selectRow = 0;
|
public int selectRow2 = 0;
|
public Int64 HInterID = 0; //内码
|
public Int64 HOrgID = -1;
|
public string HOrgNumber = "";
|
public string ERPMode = ""; //ERP模式(WISE、CLOUD)
|
public string CampanyName = ""; //客户定制化名称
|
public string SourceQtyCtl = ""; //超源单数量控制
|
public long PrintQty = 0; //允许条码打印次数
|
public string PrintQtyCtl = ""; //条码打印次数控制
|
public string UpdatePrintQtyCtl = ""; //条码打印次数更新
|
//-------------------------------------------------------------------------
|
|
//
|
//Socket通讯
|
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
long produceQty = 0; //接收通讯,需要生成几个条码
|
|
GridppReport Report;
|
|
|
#region 主要方法
|
#region 选择源单
|
//选择源单控件点击方法
|
private void cmdSourceBillNo_Click_1(object sender, EventArgs e)
|
{
|
cmdSourceBillNo_Click(sender, e);
|
}
|
|
//选原单
|
private void cmdSourceBillNo_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
|
if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
|
{
|
HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
|
}
|
if (HOrgID == -1)
|
{
|
MessageBox.Show("选择组织有错误!");
|
return;
|
}
|
|
if (cmbSourceBillType.Text.Trim() == "生产订单")
|
{
|
string sWhere = "";
|
//系统参数,生成条码数量可否超源单数量控制(N为不可超源单数量)
|
if (SourceQtyCtl == "N")
|
{
|
sWhere = " and HOrgID =" + HOrgID.ToString() + " and 任务数量>0 and 状态 = '开工' and 生产线='" + comboBox_SourceNameParams.Text + "' ";
|
}
|
else
|
{
|
sWhere = " and HOrgID =" + HOrgID.ToString() + " and 状态 = '开工' and 生产线='" + comboBox_SourceNameParams.Text + "' "; ;
|
}
|
|
DAL.Cls_S_IFCLD_ICMOList1 oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList1();
|
if (oIFCLD_ICMOList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIFCLD_ICMOList.oBillSelectColl);
|
}
|
}
|
else
|
{
|
|
}
|
|
//选择源单后,加载该源单记录物料在当前日期的条码列表
|
Display4();
|
}
|
|
//
|
private void FillSelectData(List<DBUtility.BillSelect> oList)
|
{
|
if (oList.Count != 1)
|
{
|
MessageBox.Show("请选择一条数据!");
|
return;
|
}
|
|
|
DataSet Ds;
|
oSumGrid.Changelock = true;
|
initGrid();
|
int i = -1;
|
foreach (DBUtility.BillSelect oSelectRow in oList)
|
{
|
i = i + 1;
|
//生产订单
|
if (oSelectRow.BillType == "3710")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("exec h_p_Gy_BarCodeBill_ICMOBillList " + oSelectRow.BillMainID.ToString() + "," + oSelectRow.BillSubID.ToString() + ",'" + SourceQtyCtl + "'", "h_p_Gy_BarCodeBill_ICMOBillList");
|
//Ds = oCn.RunProcReturn("select * from h_v_IFCLD_ICMOList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IFCLD_ICMOList");
|
//写入信息
|
Sub_WriteInForm(Ds.Tables[0], i);
|
}
|
}
|
//
|
oSumGrid.Changelock = false;
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
|
if (grdMain.Rows.Count > 0)
|
{
|
//根据源单设置表头
|
textBox_HMaterNumber.Text = grdMain.Rows[0].Cells[HMaterNumberCol].Value.ToString();
|
textBox_HMaterName.Text = grdMain.Rows[0].Cells[HMaterNameCol].Value.ToString();
|
textBox_HMaterModel.Text = grdMain.Rows[0].Cells[HMaterModelCol].Value.ToString();
|
long HMaterID = ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value.ToString());
|
Ds = oCn.RunProcReturn("select * from Gy_Material where HItemID = " + HMaterID + " and HUSEORGID =" + HOrgID, "Gy_Material");
|
if (Ds != null && Ds.Tables[0].Rows.Count > 0)
|
{
|
string HBatchManager = Ds.Tables[0].Rows[0]["HBatchManager"].ToString();
|
if (HBatchManager == "False")
|
{
|
radioButton_HIsUsingBatchNo.Checked = false;
|
}
|
else
|
{
|
radioButton_HIsUsingBatchNo.Checked = true;
|
}
|
}
|
//设置批号
|
if (radioButton_HIsUsingBatchNo.Checked)
|
{
|
grdMain.Rows[0].Cells[HBatchNoCol].Value = getBatchNo();
|
}
|
}
|
}
|
|
//根据TABLE写入界面(生产任务单)
|
private void Sub_WriteInForm(DataTable oTable, int i)
|
{
|
////加载表头
|
//this.txtHDeptID.Tag = oTable.Rows[0]["HDeptID"].ToString();
|
//this.txtHDeptID.Text = oTable.Rows[0]["部门名称"].ToString();
|
////加载表体
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
grdMain.Rows[i].Cells[HQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["未生成条码数量"]);
|
grdMain.Rows[i].Cells[HinitQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["未生成条码数量"]);
|
//
|
grdMain.Rows[i].Cells[HMainIDCol].Value = oTable.Rows[0]["hmainid"].ToString();
|
grdMain.Rows[i].Cells[HSubIDCol].Value = oTable.Rows[0]["hsubid"].ToString();
|
grdMain.Rows[i].Cells[HBillNoCol].Value = oTable.Rows[0]["单据号"].ToString();
|
grdMain.Rows[i].Cells[HSourceBillNoCol].Value = oTable.Rows[0]["单据号"].ToString();
|
grdMain.Rows[i].Cells[HBillTypeCol].Value = oTable.Rows[0]["HBillType"].ToString();
|
grdMain.Rows[i].Cells[HDateCol].Value = oTable.Rows[0]["日期"].ToString(); //博日 收料单据日期
|
grdMain.Rows[i].Cells[HShowDateCol].Value = dtpHDate.Value.ToShortDateString();
|
grdMain.Rows[i].Cells[HSupIDCol].Value = oTable.Rows[0]["hsupid"].ToString();
|
grdMain.Rows[i].Cells[HSupNumberCol].Value = oTable.Rows[0]["供应商代码"].ToString();
|
grdMain.Rows[i].Cells[HSupNameCol].Value = oTable.Rows[0]["供应商"].ToString();
|
grdMain.Rows[i].Cells[HDeptIDCol].Value = oTable.Rows[0]["HDeptID"].ToString();
|
grdMain.Rows[i].Cells[HDeptNumberCol].Value = oTable.Rows[0]["部门代码"].ToString();
|
grdMain.Rows[i].Cells[HDeptNameCol].Value = oTable.Rows[0]["部门"].ToString();
|
grdMain.Rows[i].Cells[HMaterIDCol].Value = oTable.Rows[0]["HMaterID"].ToString();
|
grdMain.Rows[i].Cells[HMaterNumberCol].Value = oTable.Rows[0]["物料代码"].ToString();
|
grdMain.Rows[i].Cells[HMaterNameCol].Value = oTable.Rows[0]["物料名称"].ToString();
|
grdMain.Rows[i].Cells[HMaterModelCol].Value = oTable.Rows[0]["规格型号"].ToString();
|
//grdMain.Rows[i].Cells[HBatchManagerCol].Value = oTable.Rows[0]["是否启用批次"].ToString();
|
grdMain.Rows[i].Cells[HBatchNoCol].Value = oTable.Rows[0]["批次"].ToString();
|
grdMain.Rows[i].Cells[HUnitIDCol].Value = oTable.Rows[0]["HUnitID"].ToString();
|
grdMain.Rows[i].Cells[HUnitNumberCol].Value = oTable.Rows[0]["计量单位代码"].ToString();
|
grdMain.Rows[i].Cells[HUnitNameCol].Value = oTable.Rows[0]["计量单位"].ToString();
|
grdMain.Rows[i].Cells[HRemarkCol].Value = oTable.Rows[0]["备注"].ToString();
|
grdMain.Rows[i].Cells[HMTONoCol].Value = oTable.Rows[0]["计划跟踪号"].ToString();
|
grdMain.Rows[i].Cells[HCusIDCol].Value = oTable.Rows[0]["HCusID"].ToString();
|
grdMain.Rows[i].Cells[HCusNumberCol].Value = oTable.Rows[0]["客户代码"].ToString();
|
grdMain.Rows[i].Cells[HCusNameCol].Value = oTable.Rows[0]["客户"].ToString();
|
grdMain.Rows[i].Cells[HCusTypeCol].Value = oTable.Rows[0]["客户型号"].ToString();
|
grdMain.Rows[i].Cells[HPinfanBarCodeCol].Value = oTable.Rows[0]["HPinfanBarCode"].ToString();
|
grdMain.Rows[i].Cells[HPinfanCol].Value = oTable.Rows[0]["HPinfan"].ToString();
|
//grdMain.Rows[i].Cells[HSourceIDCol].Value = oTable.Rows[0]["HSourceID"].ToString();
|
//grdMain.Rows[i].Cells[HSourceNumberCol].Value = oTable.Rows[0]["生产线代码"].ToString();
|
grdMain.Rows[i].Cells[HSourceNameCol].Value = oTable.Rows[0]["生产线"].ToString();
|
grdMain.Rows[i].Cells[HEndDateCol].Value = oTable.Rows[0]["计划完工日期"].ToString();//博日 生产订单 失效日期
|
|
grdMain.Rows[i].Cells[HAuxPropIDCol].Value = oTable.Rows[0]["HAuxPropID"].ToString();
|
|
if (cmbHBarCodeType.Text == "仪器外购件条码容器规则")
|
{
|
grdMain.Rows[i].Cells[HMinQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["未生成条码数量"]);
|
}
|
else if (cmbHBarCodeType.Text == "仪器外购件条码普通规则"
|
|| cmbHBarCodeType.Text == "仪器成品条码规则"
|
|| cmbHBarCodeType.Text == "试剂成品条码规则")
|
{
|
grdMain.Rows[i].Cells[HMinQtyCol].Value = "1";
|
}
|
else
|
{
|
grdMain.Rows[i].Cells[HMinQtyCol].Value = oTable.Rows[0]["最小包装数"].ToString();
|
}
|
grdMain.Rows[i].Cells[HProduceDateCol].Value = oTable.Rows[0]["HProduceDate"].ToString();
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = oTable.Rows[0]["HExpiryDate"].ToString();
|
grdMain.Rows[i].Cells[HISKFPERIODCol].Value = oTable.Rows[0]["HISKFPERIOD"].ToString();
|
grdMain.Rows[i].Cells[HEXPUNITCol].Value = oTable.Rows[0]["HEXPUNIT"].ToString();
|
grdMain.Rows[i].Cells[HEXPPERIODCol].Value = oTable.Rows[0]["HEXPPERIOD"].ToString();
|
|
|
//自动生成-设置数量、最小包装数、箱数为1
|
grdMain.Rows[i].Cells[HQtyCol].Value = 1;
|
grdMain.Rows[i].Cells[HMinQtyCol].Value = 1;
|
grdMain.Rows[i].Cells[HBQtyCol].Value = 1;
|
|
|
|
|
//--
|
//设置可编辑列
|
string sAllowCol = HQtyCol.ToString() +
|
"," + HMinQtyCol.ToString() +
|
"," + HAuxPropNumberCol.ToString() +
|
"," + HBatchNoCol.ToString() +
|
"," + HPackQtyCol.ToString() +
|
"," + HRemarkCol.ToString();
|
grdMain.Columns[HBillNoCol].ReadOnly = true;
|
//设置合计列
|
string sTotalCol = HQtyCol.ToString();
|
//
|
DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid);
|
tabControl1.SelectedIndex = 3;
|
bc.Enabled = true;
|
//
|
RowCount(i, 0);
|
}
|
#endregion
|
|
#region 生成按钮
|
private void bc_Click(object sender, EventArgs e)
|
{
|
this.Sub_SaveBill();
|
Display();
|
|
Display4();
|
}
|
//保存单据
|
private bool Sub_SaveBill()
|
{
|
//获取内码
|
HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
|
////若MAINDI重复则重新获取
|
//if (BaseBill.IsExistMainID(ref DBUtility.ClsPub.sExeReturnInfo, HInterID, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew))
|
//{
|
// HInterID = DBUtility.ClsPub.CreateBillID(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
|
//}
|
//
|
|
|
DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
|
HOrgNumber = "";
|
if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
|
{
|
HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
|
HOrgNumber = DBUtility.ClsPub.isStrNull(oClsGy_ORGANIZATIONS_View.omodel.HNumber);
|
}
|
if (HOrgID == -1)
|
{
|
MessageBox.Show("选择组织有错误!");
|
return false;
|
}
|
|
|
lblCaption.Focus();
|
if (!Sub_AllowSave())//单据完整性判断
|
{
|
return false;
|
}
|
|
SaveBarCode();
|
return true;
|
}
|
|
//单据完整性判断 未完成
|
private bool Sub_AllowSave()
|
{
|
//明细表是否为零行
|
bool b = false;
|
for (int i = 0; i < grdMain.RowCount; i++)
|
{
|
if (!IsNullRow(i))
|
{
|
b = true;
|
break;
|
}
|
}
|
if (b == false)
|
{
|
MessageBox.Show("明细行不存在!", "提示");
|
return false;
|
}
|
|
string sHRemark = "";
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
long HSno = DBUtility.ClsPub.isLong(grdMain.Rows[j].Cells[HSnoCol].Value); // 序号
|
string HBarCodeType = cmbHBarCodeType.Text; // 条码类型
|
string HSourceBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillNoCol].Value); // 源单单号
|
long HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value); // 物料内码
|
string HBatchNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value); // 批号
|
long HAuxPropID = DBUtility.ClsPub.isLong(grdMain.Rows[j].Cells[HAuxPropIDCol].Value); // 辅助属性ID
|
double HSourceQty = DBUtility.ClsPub.isDoule(grdMain.Rows[j].Cells[HinitQtyCol].Value); // 源单数量
|
double HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); // 数量
|
double HMinQty = DBUtility.ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value); // 最小包装数
|
|
if (HMaterID != 0)
|
{
|
DataSet oDsCheck = oCn.RunProcReturn("exec h_p_Gy_BarCodeBill_AddCheck " + HSno.ToString() + ",'" + HBarCodeType + "','" + HSourceBillNo + "'," + HMaterID.ToString() + ",'" + HBatchNo + "'," + HAuxPropID.ToString() + "," + HSourceQty.ToString() + "," + HQty.ToString() + "," + HMinQty.ToString() + "," + HOrgID.ToString() + ",'" + SourceQtyCtl + "'", "h_p_Gy_BarCodeBill_AddCheck");
|
//
|
if (oDsCheck == null && oDsCheck.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("条码生成完整性判断错误!");
|
return false;
|
}
|
else if (DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0][0]) == "1")
|
{
|
sHRemark = sHRemark + DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0]["HRemark"]);
|
}
|
else if (DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HExpiryDateCol].Value) == "")
|
{
|
if (DBUtility.ClsPub.isBool(oDsCheck.Tables[0].Rows[0]["HISKFPERIOD"]))
|
{
|
DateTime HProduceDate; //生产日期
|
string HEXPUNIT; //保质期单位
|
int HEXPPERIOD; //保质期
|
|
HProduceDate = dtpHDate.Value;
|
HEXPUNIT = DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0]["HEXPUNIT"]);
|
HEXPPERIOD = DBUtility.ClsPub.isInt(oDsCheck.Tables[0].Rows[0]["HEXPPERIOD"]);
|
|
grdMain.Rows[j].Cells[HISKFPERIODCol].Value = 1;
|
grdMain.Rows[j].Cells[HEXPUNITCol].Value = HEXPUNIT;
|
grdMain.Rows[j].Cells[HEXPPERIODCol].Value = HEXPPERIOD.ToString();
|
grdMain.Rows[j].Cells[HProduceDateCol].Value = HProduceDate.ToShortDateString();
|
|
if (HEXPUNIT == "Y")
|
{
|
grdMain.Rows[j].Cells[HExpiryDateCol].Value = HProduceDate.AddYears(HEXPPERIOD).ToShortDateString();
|
}
|
else if (HEXPUNIT == "M")
|
{
|
grdMain.Rows[j].Cells[HExpiryDateCol].Value = HProduceDate.AddMonths(HEXPPERIOD).ToShortDateString();
|
}
|
else
|
{
|
grdMain.Rows[j].Cells[HExpiryDateCol].Value = HProduceDate.AddDays(HEXPPERIOD).ToShortDateString();
|
}
|
}
|
else
|
{
|
grdMain.Rows[j].Cells[HISKFPERIODCol].Value = 0;
|
grdMain.Rows[j].Cells[HEXPUNITCol].Value = "";
|
grdMain.Rows[j].Cells[HEXPPERIODCol].Value = 0;
|
grdMain.Rows[j].Cells[HProduceDateCol].Value = "";
|
grdMain.Rows[j].Cells[HExpiryDateCol].Value = "";
|
}
|
}
|
}
|
}
|
if (sHRemark != "")
|
{
|
MessageBox.Show(sHRemark);
|
return false;
|
}
|
return true;
|
}
|
|
//生成条码
|
private void SaveBarCode()
|
{
|
grdSub.Rows.Clear();
|
int LSHlen = 6; //流水号长度
|
int SumLen = 10; //总长度
|
string TM = ""; //条码
|
string HNumber = ""; //物料内码
|
string HMaterNumber = ""; //物料代码
|
double HSumQty = 0; //产品数量
|
double HMinQty = 0; //最小包装数
|
Int64 HBQty = 0; //箱数
|
double HQty = 0; //数量
|
string WeiShu = ""; //尾数
|
Int64 LSH = 0; //流水号
|
string LSH2 = ""; //流水号转换成字符
|
string sDate = ""; //日期
|
string sYear = ""; //年
|
string sPeriod = ""; //月
|
string sDay = ""; //日
|
string HBatchNo = ""; //批次
|
string HYasuoji = ""; //压缩机
|
string HModelName = ""; //机型
|
string HICMOBillNo = ""; //源单号
|
string HBarCodeBatchNo = ""; //条码批次号
|
string HBarCodeDate = ""; //条码日期
|
int k = 0;
|
Int64 n = 0; //同一批生成条码中的第几条
|
string sTMNumber = ""; //条码自定义前缀
|
string sSourceBillNo = ""; //源单号
|
string sSourceEntryID = ""; //行号(源单子ID)
|
DataSet Ds;
|
//Ds = oCn.RunProcReturn("exec GetLSH '" + ClsPub.GetServerDate(0) + "'", "GetLSH");
|
//LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0)
|
{
|
HNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HMaterIDCol].Value);
|
HMaterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HMaterNumberCol].Value);
|
HBatchNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value);
|
//日期获取方式
|
sDate = dtpHDate.Value.ToShortDateString();
|
|
HYasuoji = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HPinfanCol].Value); //压缩机代码(夏宝电器)
|
HModelName = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusTypeCol].Value); //机型(夏宝电器)
|
HICMOBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HSourceBillNoCol].Value); //生产订单号(夏宝电器)
|
HBarCodeBatchNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HPinfanBarCodeCol].Value); //条码批次号(夏宝电器)
|
HBarCodeDate = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HSupNumberCol].Value); //条码日期(夏宝电器)
|
//
|
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);
|
//==================================
|
if (cmbHBarCodeType.Text == "唯一条码")
|
{
|
|
//条码前缀 = 组织代码 + 物料代码 + 年 + 月 + 日
|
sTMNumber = HOrgNumber + HNumber + sYear + sPeriod + sDay;
|
Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //获取最大流水号
|
//oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
|
LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
|
}
|
else
|
{
|
MessageBox.Show("错误的条码类型,不能生成条码!");
|
return;
|
}
|
|
Int64 HBQty2 = 0; //箱数
|
HBQty2 = ClsPub.isLong(grdMain.Rows[j].Cells[HBQtyCol].Value);
|
HBQty = HBQty + ClsPub.isLong(grdMain.Rows[j].Cells[HBQtyCol].Value);
|
HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value);
|
HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value);
|
n = 0;
|
int nn = 0;
|
for (int i = k; i < HBQty; i++)
|
{
|
if (HSumQty - HMinQty > 0)
|
{
|
WeiShu = "";
|
HSumQty = HSumQty - HMinQty;
|
}
|
else
|
{
|
if (HSumQty == HMinQty)
|
{
|
WeiShu = "";
|
}
|
else
|
{
|
WeiShu = "尾数";
|
}
|
HMinQty = HSumQty;
|
}
|
//
|
LSH = LSH + 1;
|
LSH2 = LSH.ToString();
|
while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0
|
{
|
LSH2 = "0" + LSH2;
|
}
|
if (cmbHBarCodeType.Text == "唯一条码")
|
{
|
//条码编号 = 条码前缀 + 流水号
|
TM = sTMNumber + LSH2;
|
}
|
|
//
|
if (i + 1 > grdSub.Rows.Count)
|
{
|
grdSub.RowCount = grdSub.RowCount + 1;
|
}
|
grdSub.Rows[i].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1);
|
if (TM.Trim() == "")
|
{
|
MessageBox.Show("条形码不能为空,不能生成条码!");
|
return;
|
}
|
grdSub.Rows[i].Cells[HTMCol].Value = TM;
|
grdSub.Rows[i].Cells[HEntryID2Col].Value = j + 1;
|
grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value;
|
grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value;
|
grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value;
|
grdSub.Rows[i].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value;
|
grdSub.Rows[i].Cells[HPinfan2Col].Value = grdMain.Rows[j].Cells[HPinfanCol].Value;
|
grdSub.Rows[i].Cells[HPinfanBarCode2Col].Value = grdMain.Rows[j].Cells[HPinfanBarCodeCol].Value;
|
|
grdSub.Rows[i].Cells[HAuxPropID2Col].Value = grdMain.Rows[j].Cells[HAuxPropIDCol].Value;
|
grdSub.Rows[i].Cells[HAuxPropNumber2Col].Value = grdMain.Rows[j].Cells[HAuxPropNumberCol].Value;
|
grdSub.Rows[i].Cells[HAuxPropName2Col].Value = grdMain.Rows[j].Cells[HAuxPropNameCol].Value;
|
|
grdSub.Rows[i].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value;
|
grdSub.Rows[i].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value;
|
grdSub.Rows[i].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value;
|
|
grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty;
|
grdSub.Rows[i].Cells[HBatchNo2Col].Value = grdMain.Rows[j].Cells[HBatchNoCol].Value;
|
grdSub.Rows[i].Cells[HSourceInterID2Col].Value = grdMain.Rows[j].Cells[HMainIDCol].Value;
|
grdSub.Rows[i].Cells[HSourceEntryID2Col].Value = grdMain.Rows[j].Cells[HSubIDCol].Value;
|
grdSub.Rows[i].Cells[HSourceBillNo2Col].Value = grdMain.Rows[j].Cells[HBillNoCol].Value;
|
grdSub.Rows[i].Cells[HSourceBillType2Col].Value = grdMain.Rows[j].Cells[HBillTypeCol].Value;
|
grdSub.Rows[i].Cells[HPrintCol].Value = "0";
|
grdSub.Rows[i].Cells[HWeiCol].Value = WeiShu;
|
grdSub.Rows[i].Cells[HBarcodeNoCol].Value = n + 1;
|
grdSub.Rows[i].Cells[HBarcodeQtysCol].Value = grdMain.Rows[j].Cells[HBQtyCol].Value;
|
grdSub.Rows[i].Cells[HSupID2Col].Value = grdMain.Rows[j].Cells[HSupIDCol].Value;
|
grdSub.Rows[i].Cells[HSupNumber2Col].Value = grdMain.Rows[j].Cells[HSupNumberCol].Value;
|
grdSub.Rows[i].Cells[HSupName2Col].Value = grdMain.Rows[j].Cells[HSupNameCol].Value;
|
grdSub.Rows[i].Cells[HDeptID2Col].Value = grdMain.Rows[j].Cells[HDeptIDCol].Value;
|
grdSub.Rows[i].Cells[HDeptNumber2Col].Value = grdMain.Rows[j].Cells[HDeptNumberCol].Value;
|
grdSub.Rows[i].Cells[HDeptName2Col].Value = grdMain.Rows[j].Cells[HDeptNameCol].Value;
|
grdSub.Rows[i].Cells[HRemark2Col].Value = grdMain.Rows[j].Cells[HRemarkCol].Value;
|
grdSub.Rows[i].Cells[HDate2Col].Value = grdMain.Rows[j].Cells[HDateCol].Value;
|
grdSub.Rows[i].Cells[HShowDate2Col].Value = grdMain.Rows[j].Cells[HShowDateCol].Value;
|
grdSub.Rows[i].Cells[HWhID2Col].Value = grdMain.Rows[j].Cells[HWhIDCol].Value;
|
grdSub.Rows[i].Cells[HWhNumber2Col].Value = grdMain.Rows[j].Cells[HWhNumberCol].Value;
|
grdSub.Rows[i].Cells[HWhName2Col].Value = grdMain.Rows[j].Cells[HWhNameCol].Value;
|
grdSub.Rows[i].Cells[HSPID2Col].Value = grdMain.Rows[j].Cells[HSPIDCol].Value;
|
grdSub.Rows[i].Cells[HSPNumber2Col].Value = grdMain.Rows[j].Cells[HSPNumberCol].Value;
|
grdSub.Rows[i].Cells[HSPName2Col].Value = grdMain.Rows[j].Cells[HSPNameCol].Value;
|
grdSub.Rows[i].Cells[HMTONo2Col].Value = grdMain.Rows[j].Cells[HMTONoCol].Value;
|
grdSub.Rows[i].Cells[HCusID2Col].Value = grdMain.Rows[j].Cells[HCusIDCol].Value;
|
grdSub.Rows[i].Cells[HCusNumber2Col].Value = grdMain.Rows[j].Cells[HCusNumberCol].Value;
|
grdSub.Rows[i].Cells[HCusName2Col].Value = grdMain.Rows[j].Cells[HCusNameCol].Value;
|
grdSub.Rows[i].Cells[HCusType2Col].Value = grdMain.Rows[j].Cells[HCusTypeCol].Value;
|
grdSub.Rows[i].Cells[HSourceID2Col].Value = grdMain.Rows[j].Cells[HSourceIDCol].Value;
|
grdSub.Rows[i].Cells[HSourceNumber2Col].Value = grdMain.Rows[j].Cells[HSourceNumberCol].Value;
|
grdSub.Rows[i].Cells[HSourceName2Col].Value = grdMain.Rows[j].Cells[HSourceNameCol].Value;
|
grdSub.Rows[i].Cells[HEndDate2Col].Value = grdMain.Rows[j].Cells[HEndDateCol].Value;
|
grdSub.Rows[i].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value;
|
grdSub.Rows[i].Cells[HSeOrderSEQ2Col].Value = grdMain.Rows[j].Cells[HSeOrderSEQCol].Value;
|
grdSub.Rows[i].Cells[HInnerBillNo2Col].Value = grdMain.Rows[j].Cells[HInnerBillNoCol].Value;
|
grdSub.Rows[i].Cells[HMaker2Col].Value = grdMain.Rows[j].Cells[HMakerCol].Value;
|
grdSub.Rows[i].Cells[HGiveAwayFlag2Col].Value = grdMain.Rows[j].Cells[HGiveAwayFlagCol].Value;
|
grdSub.Rows[i].Cells[HProduceDate2Col].Value = grdMain.Rows[j].Cells[HProduceDateCol].Value;
|
grdSub.Rows[i].Cells[HExpiryDate2Col].Value = grdMain.Rows[j].Cells[HExpiryDateCol].Value;
|
grdSub.Rows[i].Cells[HISKFPERIOD2Col].Value = grdMain.Rows[j].Cells[HISKFPERIODCol].Value;
|
grdSub.Rows[i].Cells[HEXPUNIT2Col].Value = grdMain.Rows[j].Cells[HEXPUNITCol].Value;
|
grdSub.Rows[i].Cells[HEXPPERIOD2Col].Value = grdMain.Rows[j].Cells[HEXPPERIODCol].Value;
|
//网格打勾
|
//是否赠品
|
DataGridViewCheckBoxCell oCell = new DataGridViewCheckBoxCell();
|
oCell.ThreeState = false;
|
oCell.Value = grdSub.Rows[i].Cells[HGiveAwayFlag2Col].Value;
|
oCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdSub.Rows[i].Cells[HGiveAwayFlag2Col] = oCell;
|
//是否启用保质期
|
DataGridViewCheckBoxCell oCell2 = new DataGridViewCheckBoxCell();
|
oCell2.ThreeState = false;
|
oCell2.Value = grdSub.Rows[i].Cells[HISKFPERIOD2Col].Value;
|
oCell2.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdSub.Rows[i].Cells[HISKFPERIOD2Col] = oCell2;
|
k = k + 1;
|
n = n + 1;
|
//oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
|
nn = nn + 1;
|
}
|
//后台批量执行语句
|
oCn.RunProc("exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "'," + nn.ToString() + " ");
|
}
|
}
|
string HWei = ""; //尾数
|
string 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 HSourceInterID = 0;
|
Int64 HSourceEntryID = 0;
|
string HSourceBillNo = "";
|
string HSourceBillType = "";
|
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 = "";
|
string HSeOrderBillNo = "";
|
Int64 HSeOrderSEQ = 0;
|
string HInnerBillNo = "";
|
bool HGiveAwayFlag = false;
|
Int64 HEntryID = 0;
|
string HProduceDate;
|
string HExpiryDate;
|
bool HISKFPERIOD = false;
|
string HEXPUNIT = "";
|
double HEXPPERIOD = 0;
|
try
|
{
|
oCn.BeginTran();
|
for (int i = 0; i < grdSub.Rows.Count; i++)
|
{
|
if (ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value) != 0)
|
{
|
HWei = ClsPub.isStrNull(grdSub.Rows[i].Cells[HWeiCol].Value);
|
HBarCode = ClsPub.isStrNull(grdSub.Rows[i].Cells[HTMCol].Value);
|
//
|
HBarCodeType = ClsPub.isStrNull(cmbHBarCodeType.Text);
|
HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value);
|
HEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[HEntryID2Col].Value);
|
HAuxPropID = ClsPub.isLong(grdSub.Rows[i].Cells[HAuxPropID2Col].Value);
|
HUnitID = ClsPub.isLong(grdSub.Rows[i].Cells[HUnitID2Col].Value);
|
HQty2 = ClsPub.isDoule(grdSub.Rows[i].Cells[HQty2Col].Value);
|
HBatchNo2 = ClsPub.isStrNull(grdSub.Rows[i].Cells[HBatchNo2Col].Value);
|
HSourceInterID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceInterID2Col].Value);
|
HSourceEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceEntryID2Col].Value);
|
HSourceBillNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillNo2Col].Value);
|
HSourceBillType = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillType2Col].Value);
|
HBarcodeQtys = ClsPub.isLong(grdSub.Rows[i].Cells[HBarcodeQtysCol].Value);
|
HBarcodeNo = ClsPub.isLong(grdSub.Rows[i].Cells[HBarcodeNoCol].Value);
|
HSupID = ClsPub.isLong(grdSub.Rows[i].Cells[HSupID2Col].Value);
|
HDeptID = ClsPub.isLong(grdSub.Rows[i].Cells[HDeptID2Col].Value);
|
HWhID = ClsPub.isLong(grdSub.Rows[i].Cells[HWhID2Col].Value);
|
HSPID = ClsPub.isLong(grdSub.Rows[i].Cells[HSPID2Col].Value);
|
HRemark = ClsPub.isStrNull(grdSub.Rows[i].Cells[HRemark2Col].Value);
|
HMaterName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterName2Col].Value);
|
HMaterModel = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterModel2Col].Value);
|
HPinfan = ClsPub.isStrNull(grdSub.Rows[i].Cells[HPinfan2Col].Value);
|
HMTONo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMTONo2Col].Value);
|
HCusID = ClsPub.isLong(grdSub.Rows[i].Cells[HCusID2Col].Value);
|
HCusType = ClsPub.isStrNull(grdSub.Rows[i].Cells[HCusType2Col].Value);
|
HEndDate = ClsPub.isDate(grdSub.Rows[i].Cells[HEndDate2Col].Value);
|
HWorkLineName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceName2Col].Value);
|
HSeOrderBillNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSeOrderBillNo2Col].Value);
|
HSeOrderSEQ = ClsPub.isLong(grdSub.Rows[i].Cells[HSeOrderSEQ2Col].Value);
|
HInnerBillNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HInnerBillNo2Col].Value);
|
HGiveAwayFlag = ClsPub.isBool(grdSub.Rows[i].Cells[HGiveAwayFlag2Col].Value);
|
if (ClsPub.isDate(grdSub.Rows[i].Cells[HProduceDate2Col].Value) < Convert.ToDateTime("1950-01-01"))
|
{
|
HProduceDate = "";
|
}
|
else
|
{
|
HProduceDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HProduceDate2Col].Value);
|
}
|
if (ClsPub.isDate(grdSub.Rows[i].Cells[HExpiryDate2Col].Value) < Convert.ToDateTime("1950-01-01"))
|
{
|
HExpiryDate = "";
|
}
|
else
|
{
|
HExpiryDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HExpiryDate2Col].Value);
|
}
|
HISKFPERIOD = ClsPub.isBool(grdSub.Rows[i].Cells[HISKFPERIOD2Col].Value);
|
HEXPUNIT = ClsPub.isStrNull(grdSub.Rows[i].Cells[HEXPUNIT2Col].Value);
|
HEXPPERIOD = ClsPub.isDoule(grdSub.Rows[i].Cells[HEXPPERIOD2Col].Value);
|
|
if (radioButton_HIsUsingBatchNo.Checked)
|
{
|
HBatchNo2 = getBatchNo();
|
}
|
|
HBarCode = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterModel2Col].Value) + getHBarCode_MaxNo();
|
|
long HSourceID = 0;
|
string sql = "select * from Gy_Source where HName = '" + comboBox_SourceNameParams.Text + "' ";
|
DataSet ds = oCn.RunProcReturn(sql, "Gy_Source");
|
if (ds != null && ds.Tables[0].Rows.Count > 0)
|
{
|
HSourceID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HItemID"].ToString());
|
}
|
|
oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
|
",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
|
",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
|
",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
|
",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
|
",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
|
",HProduceDate,HExpiryDate " +
|
",HISKFPERIOD,HEXPUNIT,HEXPPERIOD " +
|
",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HSourceID " +
|
") 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 + "','" + HSourceBillType + "','" + HWei + "'"
|
+ ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
|
+ ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + sDate + "'"
|
+ ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterID.ToString() + "," + HEntryID.ToString()
|
+ ", " + DBUtility.ClsPub.BoolToString(HGiveAwayFlag) + "," + HSeOrderSEQ.ToString() + "," + HSourceEntryID.ToString()
|
+ ", " + (HProduceDate == "" ? "NULL" : "'" + HProduceDate + "'") + "," + (HExpiryDate == "" ? "NULL" : "'" + HExpiryDate + "'")
|
+ ", " + DBUtility.ClsPub.BoolToString(HISKFPERIOD) + ",'" + HEXPUNIT + "'," + HEXPPERIOD.ToString()
|
+ ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "'," + HSourceID +
|
")");
|
}
|
}
|
//增加 条码超过未生成功能控制
|
|
//
|
oCn.Commit();
|
tabControl1.SelectedIndex = 3;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
MessageBox.Show("条码生成失败!" + e.Message);
|
grdSub.RowCount = 0;
|
}
|
}
|
|
//生成当天物料的批号
|
private string getBatchNo()
|
{
|
string HBatchNo = "";
|
|
if (radioButton_HIsUsingBatchNo.Checked)
|
{
|
//日期获取方式
|
string sDate = dtpHDate.Value.ToShortDateString(); //
|
string sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
|
string sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
|
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
|
string sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
|
sDay = sDay.Substring(sDay.Length - 2, 2);
|
|
string HDate = "20" + sYear + "-" + sPeriod + "-" + sDay;
|
|
//获取流水号:四位,该物料当天生成的条码数
|
string LIU = "";
|
int LEN = 4;
|
DataSet ds;
|
string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),条码日期, 23) = '" + HDate + "' order by 批号 desc";
|
ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList");
|
if (ds != null)
|
{
|
long count = 0;
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
count = ClsPub.isLong(ds.Tables[0].Rows[0]["批号"].ToString().Replace(sYear + sPeriod + sDay, ""));
|
}
|
LIU += count + 1;
|
while (LIU.Length < LEN) //如果流水号小于6位数前面补0
|
{
|
LIU = "0" + LIU;
|
}
|
}
|
else
|
{
|
return "";
|
}
|
|
//拼接批号
|
HBatchNo = sYear + sPeriod + sDay + LIU;
|
}
|
|
|
return HBatchNo;
|
}
|
|
//生成当天产品条码的流水号
|
private string getHBarCode_MaxNo()
|
{
|
string HBarCode_MaxNo = "";
|
|
//日期获取方式
|
string sDate = dtpHDate.Value.ToShortDateString(); //
|
string sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
|
string sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
|
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
|
string sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
|
sDay = sDay.Substring(sDay.Length - 2, 2);
|
|
string HDate = "20" + sYear + "-" + sPeriod + "-" + sDay;
|
|
//获取流水号:四位,该物料当天生成的条码数
|
string LIU = "";
|
int LEN = 4;
|
|
//获取产品条码备份表中当日本产品条码编号最大的记录
|
long HMaxNo_Bak = 0; //记录产品条码备份表中当日本产品条码编号最大的记录的条码编号的流水号
|
DataSet ds1;
|
string sql1 = "select * from Gy_BarCodeBill_SWELL_SubBarCodeBill Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),HBarCodeDate, 23) = '" + HDate + "' and HInterID <>0 order by HBarCode desc";
|
ds1 = oCn.RunProcReturn(sql1, "Gy_BarCodeBill_SWELL_SubBarCodeBill");
|
if (ds1 != null && ds1.Tables[0].Rows.Count>0)
|
{
|
string HBarCodeMaxNo = ds1.Tables[0].Rows[0]["HBarCode"].ToString();
|
HBarCodeMaxNo = HBarCodeMaxNo.Substring(HBarCodeMaxNo.Length - LEN, LEN);
|
HMaxNo_Bak = ClsPub.isLong(HBarCodeMaxNo);
|
}
|
|
////获取条码档案中当日本产品条码编号最大的记录
|
long HMaxNo = 0; //记录条码档案中当日本产品条码编号最大的记录的条码编号的流水号
|
DataSet ds;
|
string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),条码日期, 23) = '" + HDate + "' and HInterID <> 0 order by 条码编号 desc";
|
ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList");
|
if (ds != null && ds.Tables[0].Rows.Count > 0)
|
{
|
string HBarCodeMaxNo = ds.Tables[0].Rows[0]["条码编号"].ToString();
|
HBarCodeMaxNo = HBarCodeMaxNo.Substring(HBarCodeMaxNo.Length - LEN, LEN);
|
HMaxNo = ClsPub.isLong(HBarCodeMaxNo);
|
}
|
|
|
//获取当日本产品 在条码档案和产品条码备份表中 最大的流水号
|
long count = 0;
|
count = HMaxNo >= HMaxNo_Bak ? HMaxNo : HMaxNo_Bak;
|
|
//为流水号前面补零
|
LIU += count + 1;
|
while (LIU.Length < LEN) //如果流水号小于6位数前面补0
|
{
|
LIU = "0" + LIU;
|
}
|
|
//拼接批号
|
HBarCode_MaxNo = sYear + sPeriod + sDay + LIU;
|
|
return HBarCode_MaxNo;
|
}
|
#endregion
|
|
#endregion
|
|
#region 监听通讯
|
//开始监听按钮 点击事件
|
private void button_startListen_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
if (grdMain.Rows.Count == 0 || grdMain.Rows[0].Cells[HMaterIDCol].Value == null || grdMain.Rows[0].Cells[HMaterIDCol].Value.ToString() == "" || grdMain.Rows[0].Cells[HMaterIDCol].Value.ToString() == "0")
|
{
|
MessageBox.Show("请选择源单!");
|
return;
|
}
|
|
if (textBox_IPParams.Text == "")
|
{
|
MessageBox.Show("请设置IP地址!");
|
return;
|
}
|
if (textBox_PortParams.Text == "")
|
{
|
MessageBox.Show("请设置端口号!");
|
return;
|
}
|
|
if (comboBox_PrinterParams.Text == "")
|
{
|
MessageBox.Show("请选择打印机!");
|
return;
|
}
|
|
if (textBox_PrintModelParams.Text == "")
|
{
|
MessageBox.Show("请设置打印模板!");
|
return;
|
}
|
|
if (!judgePrinterIsConnected())
|
{
|
MessageBox.Show("打印机处于离线状态,请检查!");
|
return;
|
}
|
|
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
IPAddress iPAddress = IPAddress.Parse(textBox_IPParams.Text);
|
IPEndPoint point = new IPEndPoint(iPAddress, Convert.ToInt32(textBox_PortParams.Text));
|
socket.Connect(point);
|
|
Thread thread = new Thread(ReceiveMess);
|
thread.Start();
|
MessageBox.Show("连接成功!");
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show(ex.Message);
|
}
|
}
|
|
//socket通讯:客户端接收信息
|
private void ReceiveMess()
|
{
|
try
|
{
|
while (true)
|
{
|
byte[] buffer = new byte[1024 * 1024 * 5];
|
int length = socket.Receive(buffer);
|
if (length == 0)
|
{
|
break;
|
}
|
else
|
{
|
string RMess = Encoding.UTF8.GetString(buffer, 0, length);
|
produceQty = ClsPub.isLong(RMess);
|
if (produceQty == 0)
|
{
|
produceQty = 1;
|
}
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show("接口异常,已关闭连接:" + ex.Message);
|
socket.Close();
|
}
|
}
|
|
//判断打印机是否可用
|
private bool judgePrinterIsConnected()
|
{
|
//获取电脑连接的打印机列表
|
ManagementObjectSearcher searcher = new
|
ManagementObjectSearcher("SELECT * FROM Win32_Printer");
|
|
//匹配设置的打印机,并判断是否可用
|
string printerName = "";
|
foreach (ManagementObject printer in searcher.Get())
|
{
|
printerName = printer["Name"].ToString().ToLower();
|
if (printerName.Equals(comboBox_PrinterParams.Text.Replace("(默认)", "").ToLower()))
|
{
|
string HPrinterName = printer.Properties["Name"].Value.ToString(); //获取打印机名称
|
string HPrinterPort = printer.Properties["PortName"].Value.ToString(); //获取打印机端口号
|
string HPrinterDefault = printer.Properties["Default"].Value.ToString(); //获取打印机是否是默认打印机
|
string HPrinterWorkStatus = printer.Properties["PrinterStatus"].Value.ToString(); //获取打印机工作状态(1:其他,2:未知,3:空闲,4:打印,5:预热,6:停止打印,7:脱机)
|
string HIsOffOnline = printer.Properties["WorkOffline"].Value.ToString(); //获取打印机是否离线
|
|
|
string isConnected = printer["WorkOffline"].ToString().ToLower();
|
|
if (isConnected.Equals("true"))
|
{
|
return false;
|
}
|
else
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
|
//根据通讯信息生成条码并打印
|
private void timer2_Tick(object sender, EventArgs e)
|
{
|
for (int i = 0; i < produceQty; i++)
|
{
|
//生成条码
|
this.Sub_SaveBill();
|
|
//获取需要打印的数据
|
Display();
|
|
//设置打印模板,打印
|
grdList.Rows[0].Cells[0].Value = "*";
|
Report = new GridppReport();
|
Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf"); //here .
|
Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
|
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
|
Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
|
if (comboBox_PrinterParams.Text != "")
|
{
|
Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(默认)", "");
|
}
|
Report.Print(false);
|
|
if (i == produceQty - 1)
|
{
|
//重新加载该物料当天生成的条码
|
Display4();
|
}
|
}
|
|
produceQty = 0;
|
}
|
|
//获取需要打印的数据并存放在子表grdList
|
private void Display()
|
{
|
//设置档案列表选项卡表格数据
|
DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " order by HItemID", "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
MessageBox.Show("没有返回任何结果,条码不存在!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdList.DataSource = DSet.Tables[0].DefaultView;
|
//冻结
|
int FrCol = 0;
|
string s = "是";
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdList, this.Name + "grdList", s, FrCol);
|
//画线
|
//GraphLine();
|
}
|
|
//获取工单当天物料生成的条码记录
|
private void Display4()
|
{
|
if (grdMain.Rows.Count > 0)
|
{
|
//日期获取方式
|
string sDate = dtpHDate.Value.ToShortDateString(); //
|
string sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
|
string sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
|
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
|
string sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
|
sDay = sDay.Substring(sDay.Length - 2, 2);
|
|
sDate = "20" + sYear + "-" + sPeriod + "-" + sDay;
|
|
//设置工单条码选项卡表格数据
|
//string sql = "select * from h_v_IF_BarCodeBillList Where 源单单号 = '" + grdMain.Rows[0].Cells[HBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),条码日期, 23) = '" + sDate + "' order by 条码编号";
|
string sql = "select * from h_v_IF_BarCodeBillList Where 源单单号 = '" + grdMain.Rows[0].Cells[HBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and CONVERT(varchar(100),条码日期, 23) = '" + sDate + "' order by 条码编号";
|
DataSet DSet1 = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet1 == null)
|
{
|
return;
|
}
|
//
|
grdBillBarCodeList.DataSource = DSet1.Tables[0].DefaultView;
|
//冻结
|
int FrCol = 0;
|
string s = "是";
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdBillBarCodeList, this.Name + "grdBillBarCodeList", s, FrCol);
|
//画线
|
//GraphLine();
|
//
|
}
|
}
|
|
#endregion
|
|
#region 停止监听
|
//停止监听按钮 点击事件
|
private void button_stopListen_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
if (socket.Connected)
|
{
|
socket.Close();
|
}
|
else
|
{
|
MessageBox.Show("当前尚未连接");
|
}
|
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show(ex.Message);
|
}
|
}
|
#endregion
|
|
#region 保存配置信息按钮
|
//配置信息保存按钮 点击事件
|
private void button_saveParams_Click(object sender, EventArgs e)
|
{
|
saveParams();
|
}
|
|
//写入配置参数
|
private void saveParams()
|
{
|
//判断文件是否存在
|
if (!File.Exists(Application.StartupPath + "//Gy_BarCodeBill_automaticallyByPLC.txt"))
|
{
|
FileStream fs1 = new FileStream(Application.StartupPath + "//Gy_BarCodeBill_automaticallyByPLC.txt", FileMode.Create, FileAccess.Write);//创建写入文件
|
StreamWriter sw = new StreamWriter(fs1);
|
sw.WriteLine(textBox_IPParams.Text);//开始写入值
|
sw.WriteLine(textBox_PortParams.Text);
|
|
sw.WriteLine(comboBox_SourceNameParams.Text);
|
|
sw.WriteLine(comboBox_PrinterParams.Text.Replace("(默认)", ""));
|
sw.WriteLine(textBox_PrintModelParams.Text);
|
sw.Close();
|
fs1.Close();
|
}
|
else
|
{
|
FileStream fs1 = new FileStream(Application.StartupPath + "//Gy_BarCodeBill_automaticallyByPLC.txt", FileMode.Create, FileAccess.Write);//创建写入文件
|
StreamWriter sw = new StreamWriter(fs1);
|
sw.WriteLine(textBox_IPParams.Text);//开始写入值
|
sw.WriteLine(textBox_PortParams.Text);
|
|
sw.WriteLine(comboBox_SourceNameParams.Text);
|
|
sw.WriteLine(comboBox_PrinterParams.Text);
|
sw.WriteLine(textBox_PrintModelParams.Text);
|
sw.Close();
|
fs1.Close();
|
}
|
|
MessageBox.Show("保存成功!");
|
}
|
|
#endregion
|
|
#region 配置信息重置
|
//配置信息重置按钮点击 事件
|
private void button_resetParams_Click(object sender, EventArgs e)
|
{
|
|
}
|
#endregion
|
|
#region 固定代码
|
//清空界面
|
public void Sub_ClearBill()
|
{
|
////表体清空
|
//grdMain.Rows.Clear();
|
//grdSub.Rows.Clear();
|
|
//设置条码类型 下拉列表
|
cmbHBarCodeType.Items.Clear();
|
cmbHBarCodeType.Items.Add("唯一条码");
|
|
//设置源单类型 下拉列表
|
cmbSourceBillType.Items.Clear();
|
cmbSourceBillType.Items.Add("生产订单");
|
|
//初始化控件
|
DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
|
|
//设置组织 下拉列表 并设置值
|
DataSet Ds1 = oCn.RunProcReturn("select * from Xt_ORGANIZATIONS with(nolock) where HItemID=" + ClsPub.HOrgID, "Xt_ORGANIZATIONS", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (Ds1.Tables[0].Rows.Count != 0)
|
{
|
cmbHOrgID.Text = DBUtility.ClsPub.isStrNull(Ds1.Tables[0].Rows[0]["HName"]);
|
}
|
|
//设置打印机 下拉列表
|
PrintDocument fPrintDocument = new PrintDocument();
|
string defaultPrinter = fPrintDocument.PrinterSettings.PrinterName;
|
comboBox_PrinterParams.Items.Clear();
|
for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
|
{
|
string tmp = PrinterSettings.InstalledPrinters[i];
|
if (tmp == defaultPrinter)
|
{
|
//tmp = tmp + "(默认)";
|
}
|
comboBox_PrinterParams.Items.Add(tmp);
|
}
|
|
|
//设置产线 下拉列表
|
DataSet DsSource = oCn.RunProcReturn("select * from Gy_Source", "Gy_Source");
|
comboBox_SourceNameParams.Items.Add("");
|
if (DsSource != null)
|
{
|
comboBox_SourceNameParams.Items.Clear();
|
comboBox_SourceNameParams.Items.Add("");
|
for (int i = 0; i < DsSource.Tables[0].Rows.Count; i++)
|
{
|
comboBox_SourceNameParams.Items.Add(DsSource.Tables[0].Rows[i]["HName"]);
|
}
|
}
|
|
|
//读取配置文件设置配置
|
readParams();
|
//设置工单信息
|
textBox_SourceName.Text = comboBox_SourceNameParams.Text;
|
//设置制单信息
|
txtHMaker.Text = ClsPub.CurUserName;
|
txtHMakeDate.Text = "";
|
txtHChecker.Text = "";
|
txtHCheckDate.Text = "";
|
txtHCloseMan.Text = "";
|
txtHCloseDate.Text = "";
|
txtHDeleteMan.Text = "";
|
txtHDeleteDate.Text = "";
|
txtHUpDater.Text = "";
|
txtHUpDateDate.Text = "";
|
|
//设置子表
|
initGrid();
|
grdList.DataSource = null;
|
grdBillBarCodeList.DataSource = null;
|
tabControl1.SelectedIndex = 3;
|
}
|
|
//读取配置文件
|
private void readParams()
|
{
|
if (File.Exists(Application.StartupPath + "//Gy_BarCodeBill_automaticallyByPLC.txt"))
|
{
|
//读取文件值并显示到窗体
|
FileStream fs = new FileStream(Application.StartupPath + "//Gy_BarCodeBill_automaticallyByPLC.txt", FileMode.Open, FileAccess.ReadWrite);
|
StreamReader sr = new StreamReader(fs);
|
string line = sr.ReadLine();
|
int curLine = 0;
|
while (line != null)
|
{
|
if (++curLine == 1)
|
{
|
textBox_IPParams.Text = line;
|
}
|
else if (curLine == 2)
|
{
|
textBox_PortParams.Text = line;
|
}
|
else if (curLine == 3)
|
{
|
for (int i = 0; i < comboBox_SourceNameParams.Items.Count; i++)
|
{
|
if (comboBox_SourceNameParams.Items[i].ToString() == line)
|
{
|
comboBox_SourceNameParams.Text = line;
|
}
|
}
|
|
if (comboBox_SourceNameParams.Text == "")
|
{
|
comboBox_SourceNameParams.Items.Add(line);
|
comboBox_SourceNameParams.Text = line;
|
}
|
}
|
else if (curLine == 4)
|
{
|
for (int i = 0; i < comboBox_PrinterParams.Items.Count; i++)
|
{
|
if (comboBox_PrinterParams.Items[i].ToString() == line)
|
{
|
comboBox_PrinterParams.Text = line;
|
}
|
}
|
}
|
else if (curLine == 5)
|
{
|
textBox_PrintModelParams.Text = line;
|
}
|
else
|
{
|
|
}
|
line = sr.ReadLine();
|
}
|
sr.Close();
|
fs.Close();
|
}
|
}
|
|
//初始化GRID
|
private void initGrid()
|
{
|
//
|
grdMain.RowCount = 0;
|
grdSub.RowCount = 0;
|
grdMain.ColumnCount = 68; //总列数
|
DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name);
|
grdMain.Columns[HSnoCol].HeaderText = "序号";
|
grdMain.Columns[HMainIDCol].HeaderText = "源单主ID";
|
grdMain.Columns[HSubIDCol].HeaderText = "源单子ID";
|
grdMain.Columns[HBillNoCol].HeaderText = "源单单号";
|
grdMain.Columns[HBillTypeCol].HeaderText = "单据类型";
|
grdMain.Columns[HMaterIDCol].HeaderText = "物料ID";
|
grdMain.Columns[HMaterNumberCol].HeaderText = "物料代码";
|
grdMain.Columns[HMaterNameCol].HeaderText = "物料名称";
|
grdMain.Columns[HMaterModelCol].HeaderText = "规格型号";
|
grdMain.Columns[HModelCol].HeaderText = "自定义规格";
|
grdMain.Columns[HPinfanCol].HeaderText = "品番";
|
grdMain.Columns[HPinfanBarCodeCol].HeaderText = "HPinfanBarCode";
|
grdMain.Columns[HAuxPropIDCol].HeaderText = "辅助属性ID";
|
grdMain.Columns[HAuxPropNumberCol].HeaderText = "辅助属性代码";
|
grdMain.Columns[HAuxPropNameCol].HeaderText = "辅助属性名称";
|
grdMain.Columns[HUnitIDCol].HeaderText = "计量单位ID";
|
grdMain.Columns[HUnitNumberCol].HeaderText = "计量单位代码";
|
grdMain.Columns[HUnitNameCol].HeaderText = "计量单位名称";
|
grdMain.Columns[HBarCodeTypeCol].HeaderText = "条码类型";
|
grdMain.Columns[HBatchManagerCol].HeaderText = "是否启用批次";
|
grdMain.Columns[HBatchNoCol].HeaderText = "批号";
|
grdMain.Columns[HGiveAwayFlagCol].HeaderText = "是否赠品";
|
grdMain.Columns[HQtyCol].HeaderText = "数量";
|
grdMain.Columns[HMinQtyCol].HeaderText = "最小包装数";
|
grdMain.Columns[HPackQtyCol].HeaderText = "外箱数";
|
grdMain.Columns[HBQtyCol].HeaderText = "箱数";
|
grdMain.Columns[HSupIDCol].HeaderText = "供应商ID";
|
grdMain.Columns[HSupNumberCol].HeaderText = "供应商代码";
|
grdMain.Columns[HSupNameCol].HeaderText = "供应商";
|
grdMain.Columns[HDeptIDCol].HeaderText = "车间ID";
|
grdMain.Columns[HDeptNumberCol].HeaderText = "车间代码";
|
grdMain.Columns[HDeptNameCol].HeaderText = "车间";
|
grdMain.Columns[HWhIDCol].HeaderText = "仓库ID";
|
grdMain.Columns[HWhNumberCol].HeaderText = "仓库代码";
|
grdMain.Columns[HWhNameCol].HeaderText = "仓库";
|
grdMain.Columns[HSPIDCol].HeaderText = "仓位ID";
|
grdMain.Columns[HSPNumberCol].HeaderText = "仓位代码";
|
grdMain.Columns[HSPNameCol].HeaderText = "仓位";
|
grdMain.Columns[HInstructNoCol].HeaderText = "指令单号";
|
grdMain.Columns[HSeOrderBillNoCol].HeaderText = "销售订单号";
|
grdMain.Columns[HSeOrderSEQCol].HeaderText = "销售订单行号";
|
grdMain.Columns[HDateCol].HeaderText = "进料日期";
|
grdMain.Columns[HRemarkCol].HeaderText = "备注";
|
grdMain.Columns[HMTONoCol].HeaderText = "计划跟踪号";
|
grdMain.Columns[HCusIDCol].HeaderText = "客户ID";
|
grdMain.Columns[HCusNumberCol].HeaderText = "客户代码";
|
grdMain.Columns[HCusNameCol].HeaderText = "客户";
|
grdMain.Columns[HCusTypeCol].HeaderText = "客户型号";
|
grdMain.Columns[HEndDateCol].HeaderText = "计划完工日期";
|
grdMain.Columns[HSourceIDCol].HeaderText = "生产线ID";
|
grdMain.Columns[HSourceNumberCol].HeaderText = "生产线代码";
|
grdMain.Columns[HSourceNameCol].HeaderText = "生产线";
|
grdMain.Columns[HShowDateCol].HeaderText = "日期";
|
grdMain.Columns[HInnerBillNoCol].HeaderText = "内部采购订单号";
|
grdMain.Columns[HMakerCol].HeaderText = "制单人";
|
grdMain.Columns[HProduceDateCol].HeaderText = "生产日期";
|
grdMain.Columns[HExpiryDateCol].HeaderText = "有效期至";
|
grdMain.Columns[HISKFPERIODCol].HeaderText = "是否启用保质期";
|
grdMain.Columns[HEXPUNITCol].HeaderText = "保质期单位";
|
grdMain.Columns[HEXPPERIODCol].HeaderText = "保质期";
|
////
|
//格式化
|
grdMain.Columns[HTagCol].Visible = false; //隐藏列
|
grdMain.Columns[HMainIDCol].Visible = false;
|
grdMain.Columns[HSubIDCol].Visible = false;
|
grdMain.Columns[HBillTypeCol].Visible = false;
|
grdMain.Columns[HMaterIDCol].Visible = false;
|
grdMain.Columns[HModelCol].Visible = false;
|
//grdMain.Columns[HBatchNoCol].Visible = false;
|
grdMain.Columns[HAuxPropIDCol].Visible = false;
|
//grdMain.Columns[HAuxPropNumberCol].Visible = false;
|
//grdMain.Columns[HAuxPropNameCol].Visible = false;
|
grdMain.Columns[HUnitIDCol].Visible = false;
|
grdMain.Columns[HinitQtyCol].Visible = false;
|
grdMain.Columns[HSupIDCol].Visible = false;
|
grdMain.Columns[HSupNumberCol].Visible = false;
|
grdMain.Columns[HSupNameCol].Visible = false;
|
grdMain.Columns[HDeptIDCol].Visible = false;
|
grdMain.Columns[HDeptNumberCol].Visible = false;
|
grdMain.Columns[HDeptNameCol].Visible = false;
|
grdMain.Columns[HWhIDCol].Visible = false;
|
grdMain.Columns[HWhNumberCol].Visible = false;
|
grdMain.Columns[HWhNameCol].Visible = false;
|
grdMain.Columns[HSPIDCol].Visible = false;
|
grdMain.Columns[HSPNumberCol].Visible = false;
|
grdMain.Columns[HSPNameCol].Visible = false;
|
grdMain.Columns[HSourceInterIDCol].Visible = false;
|
grdMain.Columns[HSourceEntryIDCol].Visible = false;
|
grdMain.Columns[HSourceBillNoCol].Visible = false;
|
grdMain.Columns[HSourceBillTypeCol].Visible = false;
|
grdMain.Columns[HInstructIDCol].Visible = false;
|
grdMain.Columns[HInstructNoCol].Visible = false;
|
grdMain.Columns[HSeOrderBillIDCol].Visible = false;
|
//grdMain.Columns[HSeOrderBillNoCol].Visible = false;
|
grdMain.Columns[HBarCodeTypeCol].Visible = false;
|
grdMain.Columns[HBatchManagerCol].Visible = false;
|
//grdMain.Columns[HDateCol].Visible = false;
|
grdMain.Columns[HPinfanCol].Visible = false;
|
grdMain.Columns[HPinfanBarCodeCol].Visible = false;
|
grdMain.Columns[HCusIDCol].Visible = false;
|
//grdMain.Columns[HCusNumberCol].Visible = false;
|
//grdMain.Columns[HCusNameCol].Visible = false;
|
grdMain.Columns[HCusTypeCol].Visible = false;
|
grdMain.Columns[HEndDateCol].Visible = false;
|
grdMain.Columns[HSourceIDCol].Visible = false;
|
grdMain.Columns[HSourceNumberCol].Visible = false;
|
grdMain.Columns[HSourceNameCol].Visible = false;
|
//grdMain.Columns[HProduceDateCol].Visible = false;
|
//grdMain.Columns[HExpiryDateCol].Visible = false;
|
grdMain.Columns[HISKFPERIODCol].Visible = false;
|
grdMain.Columns[HEXPUNITCol].Visible = false;
|
grdMain.Columns[HEXPPERIODCol].Visible = false;
|
|
//设置可编辑列
|
string sAllowCol = HQtyCol.ToString() +
|
"," + HMinQtyCol.ToString() +
|
"," + HMaterNumberCol.ToString() +
|
"," + HAuxPropNumberCol.ToString() +
|
"," + HUnitNumberCol.ToString() +
|
"," + HSeOrderBillNoCol.ToString() +
|
"," + HBatchNoCol.ToString() +
|
"," + HCusNumberCol.ToString() +
|
"," + HPackQtyCol.ToString() +
|
"," + HRemarkCol.ToString();
|
//设置合计列
|
string sTotalCol = HQtyCol.ToString();
|
|
//设置特殊列
|
for (int i = 0; i < grdMain.Rows.Count; i++)
|
{
|
//网格打勾
|
DataGridViewCheckBoxCell oCell = new DataGridViewCheckBoxCell();
|
oCell.ThreeState = false;
|
oCell.Value = 0;
|
oCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdMain.Rows[i].Cells[HGiveAwayFlagCol] = oCell;
|
}
|
//
|
|
DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid);
|
//----------------------------
|
|
grdSub.ColumnCount = 65; //总列数
|
DBUtility.Xt_BaseBillFun.initGridFst(grdSub, this.Name);
|
grdSub.Columns[HSelectCol].HeaderText = "选择";
|
grdSub.Columns[HTMCol].HeaderText = "条码编号";
|
grdSub.Columns[HBarCodeType2Col].HeaderText = "条码类型";
|
grdSub.Columns[HSno2Col].HeaderText = "序号";
|
grdSub.Columns[HMaterID2Col].HeaderText = "物料ID";
|
grdSub.Columns[HMaterNumber2Col].HeaderText = "物料代码";
|
grdSub.Columns[HMaterName2Col].HeaderText = "物料名称";
|
grdSub.Columns[HMaterModel2Col].HeaderText = "规格型号";
|
grdSub.Columns[HModel2Col].HeaderText = "自定义规格";
|
grdSub.Columns[HAuxPropID2Col].HeaderText = "辅助属性ID";
|
grdSub.Columns[HAuxPropNumber2Col].HeaderText = "辅助属性代码";
|
grdSub.Columns[HAuxPropName2Col].HeaderText = "辅助属性";
|
grdSub.Columns[HPinfan2Col].HeaderText = "品番";
|
grdSub.Columns[HPinfanBarCode2Col].HeaderText = "HPinfanBarCode";
|
grdSub.Columns[HBatchNo2Col].HeaderText = "批号";
|
grdSub.Columns[HGiveAwayFlag2Col].HeaderText = "是否赠品";
|
grdSub.Columns[HUnitID2Col].HeaderText = "计量单位ID";
|
grdSub.Columns[HUnitNumber2Col].HeaderText = "计量单位代码";
|
grdSub.Columns[HUnitName2Col].HeaderText = "计量单位";
|
grdSub.Columns[HQty2Col].HeaderText = "数量";
|
grdSub.Columns[HWeiCol].HeaderText = "尾数";
|
grdSub.Columns[HPrintCol].HeaderText = "打印次数";
|
grdSub.Columns[HSourceInterID2Col].HeaderText = "源单主ID";
|
grdSub.Columns[HSourceEntryID2Col].HeaderText = "源单子ID";
|
grdSub.Columns[HSourceBillNo2Col].HeaderText = "源单单号";
|
grdSub.Columns[HSourceBillType2Col].HeaderText = "源单类型";
|
grdSub.Columns[HSeOrderBillNo2Col].HeaderText = "销售订单号";
|
grdSub.Columns[HSeOrderSEQ2Col].HeaderText = "销售订单行号";
|
grdSub.Columns[HBarcodeNoCol].HeaderText = "托号";
|
grdSub.Columns[HBarcodeQtysCol].HeaderText = "总托数";
|
grdSub.Columns[HSupID2Col].HeaderText = "供应商ID";
|
grdSub.Columns[HSupNumber2Col].HeaderText = "供应商代码";
|
grdSub.Columns[HSupName2Col].HeaderText = "供应商";
|
grdSub.Columns[HDeptID2Col].HeaderText = "车间ID";
|
grdSub.Columns[HDeptNumber2Col].HeaderText = "车间代码";
|
grdSub.Columns[HDeptName2Col].HeaderText = "车间";
|
grdSub.Columns[HWhID2Col].HeaderText = "仓库ID";
|
grdSub.Columns[HWhNumber2Col].HeaderText = "仓库代码";
|
grdSub.Columns[HWhName2Col].HeaderText = "仓库";
|
grdSub.Columns[HSPID2Col].HeaderText = "仓位ID";
|
grdSub.Columns[HSPNumber2Col].HeaderText = "仓位代码";
|
grdSub.Columns[HSPName2Col].HeaderText = "仓位";
|
grdSub.Columns[HInstructNo2Col].HeaderText = "指令单号";
|
grdSub.Columns[HDate2Col].HeaderText = "进料日期";
|
grdSub.Columns[HRemark2Col].HeaderText = "备注";
|
grdSub.Columns[HMTONo2Col].HeaderText = "计划跟踪号";
|
grdSub.Columns[HCusID2Col].HeaderText = "客户ID";
|
grdSub.Columns[HCusNumber2Col].HeaderText = "客户代码";
|
grdSub.Columns[HCusName2Col].HeaderText = "客户";
|
grdSub.Columns[HCusType2Col].HeaderText = "客户型号";
|
grdSub.Columns[HEndDate2Col].HeaderText = "计划完工日期";
|
grdSub.Columns[HSourceID2Col].HeaderText = "生产线ID";
|
grdSub.Columns[HSourceNumber2Col].HeaderText = "生产线代码";
|
grdSub.Columns[HSourceName2Col].HeaderText = "生产线";
|
grdSub.Columns[HShowDate2Col].HeaderText = "日期";
|
grdSub.Columns[HInnerBillNo2Col].HeaderText = "内部采购订单号";
|
grdSub.Columns[HMaker2Col].HeaderText = "制单人";
|
grdSub.Columns[HEntryID2Col].HeaderText = "行号";
|
grdSub.Columns[HProduceDate2Col].HeaderText = "生产日期";
|
grdSub.Columns[HExpiryDate2Col].HeaderText = "有效期至";
|
grdSub.Columns[HISKFPERIOD2Col].HeaderText = "是否启用保质期";
|
grdSub.Columns[HEXPUNIT2Col].HeaderText = "保质期单位";
|
grdSub.Columns[HEXPPERIOD2Col].HeaderText = "保质期";
|
//格式化
|
grdSub.Columns[HMaterID2Col].Visible = false;
|
grdSub.Columns[HModel2Col].Visible = false;
|
grdSub.Columns[HAuxPropID2Col].Visible = false;
|
//grdSub.Columns[HAuxPropNumber2Col].Visible = false;
|
//grdSub.Columns[HAuxPropName2Col].Visible = false;
|
grdSub.Columns[HUnitID2Col].Visible = false;
|
grdSub.Columns[HPrintCol].Visible = false;
|
grdSub.Columns[HSourceInterID2Col].Visible = false;
|
grdSub.Columns[HSourceEntryID2Col].Visible = false;
|
grdSub.Columns[HSourceBillType2Col].Visible = false;
|
grdSub.Columns[HDeptID2Col].Visible = false;
|
grdSub.Columns[HDeptNumber2Col].Visible = false;
|
grdSub.Columns[HDeptName2Col].Visible = false;
|
//grdSub.Columns[HDate2Col].Visible = false;
|
grdSub.Columns[HBarCodeType2Col].Visible = false;
|
//grdSub.Columns[HBatchNo2Col].Visible = false;
|
grdSub.Columns[HWeiCol].Visible = false;
|
grdSub.Columns[HBarcodeNoCol].Visible = false;
|
grdSub.Columns[HBarcodeQtysCol].Visible = false;
|
grdSub.Columns[HSupID2Col].Visible = false;
|
grdSub.Columns[HSupNumber2Col].Visible = false;
|
grdSub.Columns[HSupName2Col].Visible = false;
|
grdSub.Columns[HWhID2Col].Visible = false;
|
grdSub.Columns[HWhNumber2Col].Visible = false;
|
grdSub.Columns[HWhName2Col].Visible = false;
|
grdSub.Columns[HSPID2Col].Visible = false;
|
grdSub.Columns[HSPNumber2Col].Visible = false;
|
grdSub.Columns[HSPName2Col].Visible = false;
|
grdSub.Columns[HInstructID2Col].Visible = false;
|
grdSub.Columns[HInstructNo2Col].Visible = false;
|
grdSub.Columns[HSeOrderBillID2Col].Visible = false;
|
//grdSub.Columns[HSeOrderBillNo2Col].Visible = false;
|
grdSub.Columns[HPinfan2Col].Visible = false;
|
grdSub.Columns[HPinfanBarCode2Col].Visible = false;
|
grdSub.Columns[HCusID2Col].Visible = false;
|
//grdSub.Columns[HCusNumber2Col].Visible = false;
|
//grdSub.Columns[HCusName2Col].Visible = false;
|
grdSub.Columns[HCusType2Col].Visible = false;
|
grdSub.Columns[HEndDate2Col].Visible = false;
|
grdSub.Columns[HSourceID2Col].Visible = false;
|
grdSub.Columns[HSourceNumber2Col].Visible = false;
|
grdSub.Columns[HSourceName2Col].Visible = false;
|
|
//设置特殊列
|
for (int i = 0; i < grdSub.Rows.Count; i++)
|
{
|
//网格打勾
|
//是否赠品
|
DataGridViewCheckBoxCell oCell = new DataGridViewCheckBoxCell();
|
oCell.ThreeState = false;
|
oCell.Value = 0;
|
oCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdSub.Rows[i].Cells[HGiveAwayFlag2Col] = oCell;
|
//是否启用保质期
|
DataGridViewCheckBoxCell oCell2 = new DataGridViewCheckBoxCell();
|
oCell2.ThreeState = false;
|
oCell2.Value = 0;
|
oCell2.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdSub.Rows[i].Cells[HISKFPERIOD2Col] = oCell2;
|
}
|
|
DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name);
|
DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub");
|
grdSub.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //选行模式
|
|
////
|
DBUtility.Xt_BaseBillFun.initGridList(grdList, this.Name + "grdList");
|
DBUtility.Xt_BaseBillFun.initGridList(grdBillBarCodeList, this.Name + "grdBillBarCodeList");
|
////
|
}
|
#endregion
|
|
|
#region 打印相关
|
//打印结束后回填条码打印次数
|
private void ReportPrintEnd()
|
{
|
if (UpdatePrintQtyCtl == "Y")
|
{
|
oBar.Set_UpdatePrintQty_SD(HInterID);
|
}
|
}
|
|
//填入单据表头信息
|
private void ReportBeforePostRecord()//
|
{
|
try
|
{
|
//Report.FieldByName("物料代码").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HMaterNumber2Col].Value);
|
//Report.FieldByName("物料名称").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HMaterName2Col].Value);
|
//Report.FieldByName("规格型号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HMaterModel2Col].Value);
|
////Report.FieldByName("自定义规格").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HModel2Col].Value);
|
//Report.FieldByName("条码编号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HTMCol].Value);
|
//Report.FieldByName("数量").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HQty2Col].Value);
|
//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_Sel(Report, grdList, ds, Fun_GetCol("选择"));
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表体:" + e.Message);
|
}
|
}
|
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
|
}
|
#endregion
|
|
|
|
#region 固定代码
|
|
|
|
//保存列宽
|
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(grdList, this.Name + "grdList");
|
}
|
|
//默认列宽
|
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(grdList, this.Name + "grdList");
|
}
|
|
//增行按钮
|
private void AddRow_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.AddRow(oSumGrid);
|
}
|
|
//删行按纽
|
private void DelRow_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.DelRow(oSumGrid);
|
}
|
|
|
|
//重置按纽
|
private void cz_Click(object sender, EventArgs e)
|
{
|
if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew || BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
|
{
|
if (MessageBox.Show("确定要清空当前界面信息,重置界面?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
this.Sub_AddBill();
|
}
|
}
|
grdMain.Columns[HBillNoCol].ReadOnly = false;
|
tabControl1.SelectedIndex = 3;
|
}
|
|
//新增单据
|
private void Sub_AddBill()
|
{
|
this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
|
this.Sub_OperStatus();//设置TOOLBAR
|
this.Sub_ClearBill();//清空界面
|
}
|
|
//退出按钮
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
//离开单元格
|
private void grdMain_LeaveCell(object sender, EventArgs e)
|
{
|
oSumGrid.LeaveCell();
|
}
|
|
//网格单元格变化事件
|
private void grdMain_RowColChange(object sender, EventArgs e)
|
{
|
if (!grdStatus)
|
{
|
return;
|
}
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
//
|
//if (oSumGrid.Changelock)
|
// return;
|
//if(oSumGrid.EditStatus)
|
//{
|
if (!CheckGridRow(oSumGrid.OldCell.Row))
|
return;
|
//}
|
}
|
|
private void Gy_BarCodeBill_Paint(object sender, PaintEventArgs e)//画线
|
{
|
Graphics g = this.panel2.CreateGraphics();
|
Pen p = new Pen(Color.Gray);
|
p.Width = 1;
|
g.DrawLine(p, new Point(txtHMaker.Left, txtHMaker.Top + txtHMaker.Height), new Point(txtHMaker.Left + txtHMaker.Width, txtHMaker.Top + txtHMaker.Height));
|
g.DrawLine(p, new Point(txtHMakeDate.Left, txtHMakeDate.Top + txtHMakeDate.Height), new Point(txtHMakeDate.Left + txtHMakeDate.Width, txtHMakeDate.Top + txtHMakeDate.Height));
|
//
|
g.DrawLine(p, new Point(txtHChecker.Left, txtHChecker.Top + txtHChecker.Height), new Point(txtHChecker.Left + txtHChecker.Width, txtHChecker.Top + txtHChecker.Height));
|
g.DrawLine(p, new Point(txtHCheckDate.Left, txtHCheckDate.Top + txtHCheckDate.Height), new Point(txtHCheckDate.Left + txtHCheckDate.Width, txtHCheckDate.Top + txtHCheckDate.Height));
|
//
|
g.DrawLine(p, new Point(txtHCloseMan.Left, txtHCloseMan.Top + txtHCloseMan.Height), new Point(txtHCloseMan.Left + txtHCloseMan.Width, txtHCloseMan.Top + txtHCloseMan.Height));
|
g.DrawLine(p, new Point(txtHCloseDate.Left, txtHCloseDate.Top + txtHCloseDate.Height), new Point(txtHCloseDate.Left + txtHCloseDate.Width, txtHCloseDate.Top + txtHCloseDate.Height));
|
//
|
g.DrawLine(p, new Point(this.txtHDeleteMan.Left, txtHDeleteMan.Top + txtHDeleteMan.Height), new Point(txtHDeleteMan.Left + txtHDeleteMan.Width, txtHDeleteMan.Top + txtHDeleteMan.Height));
|
g.DrawLine(p, new Point(txtHDeleteDate.Left, txtHDeleteDate.Top + txtHDeleteDate.Height), new Point(txtHDeleteDate.Left + txtHDeleteDate.Width, txtHDeleteDate.Top + txtHDeleteDate.Height));
|
//
|
g.DrawLine(p, new Point(this.txtHUpDater.Left, txtHUpDater.Top + txtHUpDater.Height), new Point(txtHUpDater.Left + txtHUpDater.Width, txtHUpDater.Top + txtHUpDater.Height));
|
g.DrawLine(p, new Point(txtHUpDateDate.Left, txtHUpDateDate.Top + txtHUpDateDate.Height), new Point(txtHUpDateDate.Left + txtHUpDateDate.Width, txtHUpDateDate.Top + txtHUpDateDate.Height));
|
//控件位置设置
|
|
}
|
|
//控件位置
|
private void Sub_ControlLocation()
|
{
|
//gbUp.Width = P1.Width - 20;
|
//gbUp.Left = 10;
|
//gbUp.Height = P1.Height - 35;
|
//gbUp.Top = 30;
|
}
|
|
//窗体加载
|
private void Gy_BarCodeBill_Load(object sender, EventArgs e)
|
{
|
//打印初始化
|
oSumGrid.NoCol = HSnoCol;
|
oSumGrid.ogrdMain = grdMain;
|
oSumGrid.oGridsum = grdSum;
|
this.Text = ModCaption;
|
this.lblCaption.Text = ModCaption;
|
//加载组织信息
|
Sub_AddOrdList();
|
//加载工厂代码信息
|
Sub_AddWorksNumberList();
|
}
|
|
//加载组织信息
|
private void Sub_AddOrdList()
|
{
|
DataSet ds;
|
DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
|
ds = oClsGy_ORGANIZATIONS_View.GetList();
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("获取组织失败");
|
return;
|
}
|
cmbHOrgID.Items.Clear();
|
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
{
|
cmbHOrgID.Items.Add(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HName"]));
|
}
|
}
|
|
//加载工厂代码信息
|
private void Sub_AddWorksNumberList()
|
{
|
//获取系统参数
|
ClsXt_SystemParameter oSystemParameter = new ClsXt_SystemParameter();
|
if (oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo) == false)
|
{
|
MessageBox.Show("获取系统参数失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
|
return;
|
}
|
else
|
{
|
ERPMode = oSystemParameter.omodel.WMS_WMSStockCtl_ERPMode;
|
CampanyName = oSystemParameter.omodel.WMS_CampanyName;
|
SourceQtyCtl = oSystemParameter.omodel.BarCode_SourceQtyCtl;
|
PrintQty = oSystemParameter.omodel.BarCode_PrintQty;
|
PrintQtyCtl = oSystemParameter.omodel.BarCode_PrintQtyCtl;
|
UpdatePrintQtyCtl = oSystemParameter.omodel.BarCode_UpdatePrintQtyCtl;
|
}
|
//系统参数,有源单生成条码,生成条码数量可否超源单数量控制(N为不可超源单数量)
|
if (SourceQtyCtl == "N")
|
{
|
//系统参数为不可超源单数量时,再次判断用户权限是否可超源单数量
|
//判断权限
|
if (ClsPub.Security_Log(ModRightNameSourceQty, 3, false, ClsPub.CurUserName))
|
{
|
SourceQtyCtl = "Y";
|
}
|
}
|
|
cmbHWorksNumber.Items.Clear();
|
if (CampanyName == "飞龙") //系统参数 客户定制化名称
|
{
|
cmbHWorksNumber.Items.Add("ZL");
|
cmbHWorksNumber.Items.Add("ST");
|
cmbHWorksNumber.Items.Add("SQ");
|
cmbHWorksNumber.Items.Add("MQ");
|
}
|
else
|
{
|
cmbHWorksNumber.Items.Add("");
|
}
|
}
|
|
//窗体尺寸变化时
|
private void Gy_BarCodeBill_Resize(object sender, EventArgs e)
|
{
|
//Sub_ControlLocation();
|
}
|
|
//根据编辑状态 设置 控件是否允许录入
|
private void Sub_LrtextStatus(bool TextEnabled)
|
{
|
if (TextEnabled == true)
|
{
|
//控件全部有效
|
gbUp.Enabled = true;
|
grdMain.BackColor = ClsPub.EditColor;
|
}
|
else
|
{ //控件全部无效
|
gbUp.Enabled = false;
|
grdMain.BackColor = ClsPub.ViewColor;
|
}
|
}
|
|
//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();
|
}
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
}
|
|
//窗体卸载
|
private void Gy_BarCodeBill_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
}
|
|
//TOOLBAR状态 按钮是否灰度
|
public void Sub_OperStatus()
|
{
|
switch (BillStatus)
|
{
|
case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View:
|
//浏览状态
|
yl.Enabled = true;
|
AddRow.Enabled = false;
|
DelRow.Enabled = false;
|
bc.Enabled = false;
|
cz.Enabled = false;
|
tc.Enabled = true;
|
//未审核
|
if (txtHChecker.Text.Trim() == "")
|
{
|
//未审核
|
pic1.Visible = false;
|
pic1.Image = null;
|
//
|
}
|
else if (txtHCloseMan.Text.Trim() == "" && txtHChecker.Text.Trim() != "")//审核未关闭
|
{
|
//
|
pic1.Visible = true;
|
pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Checked.jpg");
|
//
|
}
|
else//已关闭
|
{
|
//
|
pic1.Visible = true;
|
pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Closed.jpg");
|
//
|
}
|
if (txtHDeleteMan.Text.Trim() == "")
|
{
|
}
|
else //已作废
|
{
|
AddRow.Enabled = false;
|
DelRow.Enabled = false;
|
bc.Enabled = false;
|
cz.Enabled = false;
|
//
|
pic1.Visible = true;
|
pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Deleted.jpg");
|
//
|
}
|
Sub_LrtextStatus(false);
|
grdStatus = false;
|
break;
|
case DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew:
|
//新增状态
|
yl.Enabled = true;
|
AddRow.Enabled = true;
|
DelRow.Enabled = true;
|
bc.Enabled = true;
|
cz.Enabled = true;
|
tc.Enabled = true;
|
Sub_LrtextStatus(true);
|
grdStatus = true;
|
//未审核
|
pic1.Visible = false;
|
pic1.Image = null;
|
//
|
break;
|
case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify:
|
//修改状态
|
yl.Enabled = true;
|
AddRow.Enabled = true;
|
DelRow.Enabled = true;
|
bc.Enabled = true;
|
cz.Enabled = true;
|
tc.Enabled = true;
|
Sub_LrtextStatus(true);
|
grdStatus = true;
|
//未审核
|
pic1.Visible = false;
|
pic1.Image = null;
|
//
|
break;
|
}
|
|
}
|
|
#endregion
|
|
#region 读写类
|
|
|
|
#endregion
|
|
|
#region 窗体处理方法
|
|
|
//公式重算
|
private void RowCount(int sRow, int sTag)
|
{
|
if (sTag == 0)
|
{
|
//箱数列=数量/最小包装数
|
double sMoney = 0;
|
if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMinQtyCol].Value) == 0)
|
{
|
sMoney = 0;
|
}
|
else
|
{
|
sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMinQtyCol].Value);
|
}
|
sMoney = Math.Ceiling(sMoney);
|
grdMain.Rows[sRow].Cells[HBQtyCol].Value = sMoney;
|
}
|
else
|
{
|
|
}
|
//if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) > ClsPub.isDoule(grdMain.Rows[sRow].Cells[HinitQtyCol].Value)
|
// && ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HBillNoCol].Value) != "")
|
//{
|
// MessageBox.Show("所输入的产品总数量大于剩余可生成数量" + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HinitQtyCol].Value) + ",请重新输入!");
|
// grdMain.Rows[sRow].Cells[HQtyCol].Value = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HinitQtyCol].Value);
|
// return;
|
//}
|
}
|
|
//核对选择的内容
|
public bool CheckGridCell(Cell oCell)
|
{
|
int Row;
|
int Col;
|
Row = oCell.Row;
|
Col = oCell.Col;
|
//if (ClsPub.isStrNull(grdMain.get_TextMatrix(Row, HTagCol)) != "*")
|
//{
|
// return true;
|
//}
|
//grdMain.Redraw = VSFlex7.RedrawSettings.flexRDNone;
|
//判断选中列
|
if (Col == HMaterNumberCol) //物料代码列
|
{
|
//ClsGy_MaterialHlp oMate = new ClsGy_MaterialHlp();
|
//if (oMate.GetInfoByID(ClsPub.isLong(grdMain.Rows[Row].Cells[HMaterIDCol].Value)))
|
//{
|
// grdMain.Rows[Row].Cells[HMaterIDCol].Value = oMate.HItemID.ToString();
|
// grdMain.Rows[Row].Cells[HMaterNumberCol].Value = oMate.HNumber;
|
// grdMain.Rows[Row].Cells[HMaterNameCol].Value = oMate.HName;
|
// //grdMain.Rows[Row].Cells[HMaterModelCol].Value = oMate.HModel;
|
//}
|
//else
|
//{
|
// grdMain.Rows[Row].Cells[HMaterIDCol].Value = "";
|
// grdMain.Rows[Row].Cells[HMaterNumberCol].Value = "";
|
// grdMain.Rows[Row].Cells[HMaterNameCol].Value = "";
|
// //grdMain.Rows[Row].Cells[HMaterModelCol].Value = "";
|
return false;
|
//}
|
}
|
else if (Col == HUnitIDCol) //单位ID列
|
{
|
//ClsGy_UnitHlp oUn = new ClsGy_UnitHlp();
|
//if (oUn.GetInfoByID(ClsPub.isLong(grdMain.Rows[Row].Cells[HUnitIDCol])))
|
//{
|
// grdMain.Rows[Row].Cells[HUnitIDCol].Value = oUn.HItemID.ToString();
|
// grdMain.Rows[Row].Cells[HUnitNameCol].Value = oUn.HName;
|
//}
|
//else
|
//{
|
// grdMain.Rows[Row].Cells[HUnitIDCol].Value = "";
|
// grdMain.Rows[Row].Cells[HUnitNameCol].Value = "";
|
return false;
|
//}
|
}
|
else //其他列
|
{
|
}
|
//
|
//
|
grdMain.Rows[Row].Cells[HTagCol].Value = "*";
|
oSumGrid.EditStatus = false;
|
return true;
|
}
|
//是否是空行
|
private bool IsNullRow(int Row)
|
{
|
return DBUtility.Xt_BaseBillFun.IsNullRow(Row, HMaterIDCol, grdMain);
|
}
|
//'判断网格行的录入是否正确
|
private bool CheckGridRow(int Row)
|
{
|
Cell oCell = new Cell();
|
int c = 0;
|
//if (ClsPub.isStrNull(grdMain.get_TextMatrix(Row, HTagCol)) != "*")
|
//{
|
// return true;
|
//}
|
//
|
for (c = 0; c < grdMain.ColumnCount; c++)
|
{
|
oCell.Row = Row;
|
oCell.Col = c;
|
//if (!CheckGridCell(oCell))
|
// return false;
|
|
}
|
return true;
|
}
|
|
DataGridViewTextBoxEditingControl EditingControl;
|
|
|
#endregion
|
|
private void txtHSourceBillNo_KeyPress(object sender, KeyPressEventArgs e)
|
{
|
if (e.KeyChar == (char)Keys.Return)//回车带出源单信息
|
{
|
long sHOrgID = -1;
|
DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
|
if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
|
{
|
sHOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
|
}
|
|
if (txtHSourceBillNo.Text.Length < 4)
|
{
|
MessageBox.Show("请输入4位以上数据!");
|
return;
|
}
|
//根据源单类型 和源单号 获取信息
|
if (cmbSourceBillType.Text.Trim() == "生产订单")
|
{
|
DAL.Cls_S_IFCLD_ICMOList oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList();
|
//系统参数,生成条码数量可否超源单数量控制(N为不可超源单数量)
|
if (SourceQtyCtl == "N")
|
{
|
if (oIFCLD_ICMOList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + sHOrgID.ToString() + " and 任务数量>0")) //选择原单
|
{
|
FillSelectData(oIFCLD_ICMOList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
else
|
{
|
if (oIFCLD_ICMOList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + sHOrgID.ToString())) //选择原单
|
{
|
FillSelectData(oIFCLD_ICMOList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "生产汇报单")
|
{
|
DAL.Cls_S_IF_ICMOReportBillList oIF_ICMOReportBillList = new DAL.Cls_S_IF_ICMOReportBillList();
|
if (oIF_ICMOReportBillList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' ")) //选择原单
|
{
|
FillSelectData(oIF_ICMOReportBillList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "收料通知单")
|
{
|
DAL.Cls_S_IF_POInStockBillList oIF_POInStockBillList = new DAL.Cls_S_IF_POInStockBillList();
|
if (oIF_POInStockBillList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' ")) //选择原单
|
{
|
FillSelectData(oIF_POInStockBillList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "采购订单")
|
{
|
DAL.Cls_S_IF_POOrderBillList oIF_POOrderBillList = new DAL.Cls_S_IF_POOrderBillList();
|
if (oIF_POOrderBillList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' ")) //选择原单
|
{
|
FillSelectData(oIF_POOrderBillList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "委外订单")
|
{
|
DAL.Cls_S_IF_EntrustOrderBillList oIF_EntrustOrderBillList = new DAL.Cls_S_IF_EntrustOrderBillList();
|
if (oIF_EntrustOrderBillList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' ")) //选择原单
|
{
|
FillSelectData(oIF_EntrustOrderBillList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("所选源单类型,不支持此功能!");
|
return;
|
}
|
|
}
|
}
|
}
|
}
|