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;
|
|
namespace WarM
|
{
|
public partial class Gy_CusBarCodeBill_KaiBei_LangChao : Form
|
{
|
public Gy_CusBarCodeBill_KaiBei_LangChao()
|
{
|
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 HMaterModelCol = 9;
|
public const Int16 HCusModelNameCol = 10;
|
public const Int16 HUnitIDCol = 11;
|
public const Int16 HUnitNumberCol = 12;
|
public const Int16 HUnitNameCol = 13;
|
public const Int16 HAuxPropIDCol = 14;
|
public const Int16 HAuxPropNumberCol = 15;
|
public const Int16 HAuxPropNameCol = 16;
|
public const Int16 HBatchManagerCol = 17;
|
public const Int16 HBatchNoCol = 18;
|
public const Int16 HGiveAwayFlagCol = 19;
|
public const Int16 HCode1Col = 20;
|
public const Int16 HCode2Col = 21;
|
public const Int16 HCode3Col = 22;
|
public const Int16 HInnerBillNoCol = 23;
|
public const Int16 HQtyCol = 24;
|
public const Int16 HMinQtyCol = 25;
|
public const Int16 HBQtyCol = 26;
|
public const Int16 HWMinQtyCol = 27;
|
public const Int16 HWBQtyCol = 28;
|
public const Int16 HProduceDateCol = 29;
|
public const Int16 HExpiryDateCol = 30;
|
public const Int16 HCusIDCol = 31;
|
public const Int16 HCusNumberCol = 32;
|
public const Int16 HCusNameCol = 33;
|
public const Int16 HSourceInterIDCol = 34;
|
public const Int16 HSourceEntryIDCol = 35;
|
public const Int16 HSourceBillNoCol = 36;
|
public const Int16 HSourceBillTypeCol = 37;
|
public const Int16 HRemarkCol = 38;
|
public const Int16 HInitQtyCol = 39;
|
public const Int16 HMTONoCol = 40;
|
public const Int16 HISKFPERIODCol = 41;
|
public const Int16 HEXPUNITCol = 42;
|
public const Int16 HEXPPERIODCol = 43;
|
public const Int16 HLSHCol = 44;
|
public const Int16 HBaNoCol = 45;
|
//
|
public string ModName = "85";
|
public string ModCaption = "浪潮客户标签生成";
|
public const string ModRightName = "Gy_CusBarCodeBill_KaiBei_LangChao";
|
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
public DBUtility.ClsXt_BaseBill BaseBill;
|
ClsGridViewSum oSumGrid = new ClsGridViewSum();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
public Frm_Split oDlg = new Frm_Split();
|
public bool grdStatus;
|
public int selectRow = 0;
|
public Int64 HInterID = 0; //内码
|
public Int64 HOrgID = ClsPub.HOrgID;
|
public string HCusModel = "Z"; //厂商代码
|
public string sDate = ""; //日期
|
public string sYear = ""; //年(2位)
|
public string sYear4 = ""; //年(4位)
|
public string sPeriod = ""; //月
|
public string sPeriod2 = ""; //月(正常)
|
public string sDay = ""; //日
|
|
|
#region 固定代码
|
|
//清空界面
|
public void Sub_ClearBill()
|
{
|
cmbSourceBillType.Items.Clear();
|
//源单类型
|
cmbSourceBillType.Items.Add("生产订单");
|
//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"]);
|
}
|
|
txtHMaker.Text = ClsPub.CurUserName;
|
txtHMakeDate.Text = "";
|
txtHChecker.Text = "";
|
txtHCheckDate.Text = "";
|
txtHCloseMan.Text = "";
|
txtHCloseDate.Text = "";
|
txtHDeleteMan.Text = "";
|
txtHDeleteDate.Text = "";
|
txtHUpDater.Text = "";
|
txtHUpDateDate.Text = "";
|
initGrid();
|
grdSub.DataSource = null;
|
grdList.DataSource = null;
|
}
|
|
//保存列宽
|
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 DelRow_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.DelRow(oSumGrid);
|
}
|
|
//保存按钮
|
private void bc_Click(object sender, EventArgs e)
|
{
|
this.Sub_SaveBill();
|
Display();
|
}
|
|
//重置按纽
|
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 = 0;
|
}
|
|
//新增单据
|
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_CusBarCodeBill_KaiBei_LangChao_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_CusBarCodeBill_KaiBei_LangChao_Load(object sender, EventArgs e)
|
{
|
//打印初始化
|
oSumGrid.NoCol = HSnoCol;
|
oSumGrid.ogrdMain = grdMain;
|
oSumGrid.oGridsum = grdSum;
|
this.Text = ModCaption;
|
this.lblCaption.Text = ModCaption;
|
//加载组织信息
|
Sub_AddOrdList();
|
//加载客户信息
|
Sub_AddHCusNameList();
|
}
|
|
//加载组织信息
|
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.DataSource = null;
|
cmbHOrgID.Items.Clear();
|
cmbHOrgID.DataSource = ds.Tables[0];
|
cmbHOrgID.DisplayMember = "HName";
|
cmbHOrgID.ValueMember = "HItemID";
|
}
|
|
//加载客户信息
|
private void Sub_AddHCusNameList()
|
{
|
DataSet ds = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_Cus " + HOrgID.ToString(), "h_p_Gy_CusBarCodeBill_Cus");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
cmbHCusName.DataSource = null;
|
cmbHCusName.Items.Clear();
|
MessageBox.Show("获取客户信息失败");
|
return;
|
}
|
cmbHCusName.DataSource = null;
|
cmbHCusName.Items.Clear();
|
cmbHCusName.DataSource = ds.Tables[0];
|
cmbHCusName.DisplayMember = "HName";
|
cmbHCusName.ValueMember = "HItemID";
|
}
|
|
//窗体尺寸变化时
|
private void Gy_CusBarCodeBill_KaiBei_LangChao_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_CusBarCodeBill_KaiBei_LangChao_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:
|
//浏览状态
|
ylw.Enabled = true;
|
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 //已作废
|
{
|
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:
|
//新增状态
|
ylw.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:
|
//修改状态
|
ylw.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 生成条码
|
|
private bool Sub_SaveBill()
|
{
|
//获取内码
|
HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
|
|
lblCaption.Focus();
|
//生成条码前控制
|
if (!Sub_AllowSave())
|
{
|
return false;
|
}
|
bc.Enabled = false;
|
SaveBarCode();
|
return true;
|
}
|
|
#region 生成条码前控制
|
private bool Sub_AllowSave()
|
{
|
string sHRemark = "";
|
//明细表是否为零行
|
bool b = false;
|
for (int i = 0; i < grdMain.RowCount; i++)
|
{
|
if (!IsNullRow(i))
|
{
|
b = true;
|
break;
|
}
|
}
|
if (b == false)
|
{
|
MessageBox.Show("明细行不存在!", "提示");
|
return false;
|
}
|
|
//日期获取方式
|
sDate = dtpHDate.Value.ToShortDateString();
|
sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
|
sYear4 = ClsPub.isDate(sDate).Year.ToString();
|
sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
|
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
|
sPeriod2 = sPeriod.Substring(sPeriod.Length - 2, 2);
|
sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
|
sDay = sDay.Substring(sDay.Length - 2, 2);
|
//==================================
|
switch (sYear)
|
{
|
case "22":
|
sYear = "N";
|
break;
|
case "23":
|
sYear = "P";
|
break;
|
case "24":
|
sYear = "Q";
|
break;
|
case "25":
|
sYear = "R";
|
break;
|
case "26":
|
sYear = "S";
|
break;
|
case "27":
|
sYear = "T";
|
break;
|
case "28":
|
sYear = "U";
|
break;
|
case "29":
|
sYear = "V";
|
break;
|
case "30":
|
sYear = "W";
|
break;
|
case "31":
|
sYear = "X";
|
break;
|
case "32":
|
sYear = "Y";
|
break;
|
case "33":
|
sYear = "Z";
|
break;
|
default:
|
sYear = "";
|
break;
|
}
|
if (sYear == "")
|
{
|
MessageBox.Show("错误的年份!");
|
return false;
|
}
|
|
switch (sPeriod)
|
{
|
case "01":
|
sPeriod = "1";
|
break;
|
case "02":
|
sPeriod = "2";
|
break;
|
case "03":
|
sPeriod = "3";
|
break;
|
case "04":
|
sPeriod = "4";
|
break;
|
case "05":
|
sPeriod = "5";
|
break;
|
case "06":
|
sPeriod = "6";
|
break;
|
case "07":
|
sPeriod = "7";
|
break;
|
case "08":
|
sPeriod = "8";
|
break;
|
case "09":
|
sPeriod = "9";
|
break;
|
case "10":
|
sPeriod = "A";
|
break;
|
case "11":
|
sPeriod = "B";
|
break;
|
case "12":
|
sPeriod = "C";
|
break;
|
default:
|
sPeriod = "";
|
break;
|
}
|
if (sPeriod == "")
|
{
|
MessageBox.Show("错误的月份!");
|
return false;
|
}
|
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
long HSno = DBUtility.ClsPub.isLong(grdMain.Rows[j].Cells[HSnoCol].Value); // 序号
|
string HSourceBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillNoCol].Value); // 源单单号
|
long HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value); // 物料内码
|
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); // 内箱最小包装数
|
double HWMinQty = DBUtility.ClsPub.isDoule(grdMain.Rows[j].Cells[HWMinQtyCol].Value); // 外箱最小包装数
|
string HCusModelName = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusModelNameCol].Value); // 客户料号
|
string HCode1 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode1Col].Value); // 物料类别
|
string HCode2 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode2Col].Value); // 批次位
|
HCode2 = HCode2.ToUpper();
|
string HCode3 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value); // 版本号
|
string HBatchNoNumber = HCode1 + sYear + sPeriod + sDay + HCusModel; // 批次生成前缀
|
HBatchNoNumber = HBatchNoNumber.ToUpper();
|
string HBarCodeType = ""; // 条码类型
|
string HInnerBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HInnerBillNoCol].Value); // 客户订单号
|
|
if (HMaterID != 0)
|
{
|
DataSet oDsCheck = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_KaiBeiLC_AddCheck " + HSno.ToString() + ",'" + HSourceBillNo + "'," + HMaterID.ToString() + "," + HSourceQty.ToString() + "," + HQty.ToString() + "," + HMinQty.ToString() + "," + HWMinQty.ToString() + ",'" + HCusModelName + "','" + HCode1 + "','" + HCode2 + "','" + HCode3 + "','" + HBatchNoNumber + "','" + HBarCodeType + "','" + HInnerBillNo + "'", "h_p_Gy_CusBarCodeBill_KaiBeiLC_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
|
{
|
//grdMain.Rows[j].Cells[HBaNoCol].Value = HCode2;
|
//grdMain.Rows[j].Cells[HBatchNoCol].Value = DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0]["HBatchNo"]);
|
//grdMain.Rows[j].Cells[HCode2Col].Value = DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0]["HCode2"]);
|
|
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;
|
}
|
|
#endregion
|
|
#region 写入客户条码档案
|
private void SaveBarCode()
|
{
|
try
|
{
|
string TM = ""; //条码
|
int LSHlen = 4; //流水号长度
|
double HSumQty = 0; //产品数量
|
double HMinQty = 0; //内箱最小包装数
|
int HBQty = 0; //内箱数
|
double HWMinQty = 0; //外箱最小包装数
|
int HWBQty = 0; //外箱数
|
int LSH = 0; //内箱流水号
|
int LWSH = 0; //外箱流水号
|
string LSH2 = ""; //流水号转换成字符
|
string HCode1 = ""; //物料类别
|
string HCode2 = ""; //批次位
|
string HCode3 = ""; //版本号
|
string sTMNumber = ""; //外箱条码前缀
|
DataSet Ds;
|
|
Int64 HEntryID = 0;
|
string HBarCode = ""; //条形码
|
string HBarCodeType = ""; //条码类型
|
Int64 HMaterID = 0; //物料ID
|
Int64 HUnitID = 0; //计量单位ID
|
Int64 HAuxPropID = 0; //辅助属性ID
|
string HBatchNo = ""; //批次
|
double HQty = 0; //数量
|
Int64 HCusID = 0; //客户ID
|
string HCusModelName = ""; //客户料号
|
bool HGiveAwayFlag = false; //赠品标记
|
string HProduceDate; //生产日期(保质期用)
|
string HExpiryDate; //保质期至(保质期用)
|
bool HISKFPERIOD = false; //保质期启用标记
|
Int64 HBarcodeQtys = 0; //总托数
|
Int64 HBarcodeNo = 0; //当前托号
|
Int64 HSourceInterID = 0; //源单主ID
|
Int64 HSourceEntryID = 0; //源单子ID
|
string HSourceBillNo = ""; //源单单号
|
string HSourceBillType = "";//源单类型
|
string HMTONo = ""; //MTO号
|
string HRemark = ""; //备注
|
string HInnerBillNo = ""; //客户订单号
|
Int64 HSno = 0; //批次序列号
|
string HBoxNo = ""; //批次生成前缀
|
string sHBaNo = ""; //界面上输入的批次位
|
int HSumBQty = 0; //同一批生成条码总箱数
|
int n = 0; //同一批生成条码中的第几条
|
pb1.Value = 0;
|
|
oCn.BeginTran();
|
Application.DoEvents();
|
//获取同一批生成条码总箱数
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0)
|
{
|
HSumBQty = HSumBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value) + ClsPub.isInt(grdMain.Rows[j].Cells[HWBQtyCol].Value);
|
pb1.Maximum = HSumBQty;
|
}
|
}
|
//生成内箱条码
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0)
|
{
|
string sHSourceBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillNoCol].Value); // 源单单号
|
long sHMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value); // 物料内码
|
string sHMaterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HMaterNumberCol].Value); // 物料代码
|
string sHCusModelName = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusModelNameCol].Value); // 客户料号
|
string sHCode1 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode1Col].Value); // 物料类别
|
string sHCode2 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode2Col].Value); // 批次位
|
sHCode2 = sHCode2.ToUpper();
|
string HBatchNoNumber = sHCode1 + sYear + sPeriod + sDay + HCusModel; // 批次生成前缀
|
HBatchNoNumber = HBatchNoNumber.ToUpper();
|
|
DataSet oDsBatchNo = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_KaiBeiLC_GetBatchNo '" + sHSourceBillNo + "'," + sHMaterID.ToString() + ",'" + sHMaterNumber + "','" + sHCusModelName + "','" + sHCode2 + "','" + HBatchNoNumber + "'", "h_p_Gy_CusBarCodeBill_KaiBeiLC_GetBatchNo");
|
//
|
if (oDsBatchNo == null && oDsBatchNo.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("获取批次失败!");
|
bc.Enabled = true;
|
oCn.RollBack();
|
return;
|
}
|
else if (DBUtility.ClsPub.isStrNull(oDsBatchNo.Tables[0].Rows[0][0]) == "1")
|
{
|
MessageBox.Show(DBUtility.ClsPub.isStrNull(oDsBatchNo.Tables[0].Rows[0]["HRemark"]));
|
bc.Enabled = true;
|
oCn.RollBack();
|
return;
|
}
|
else
|
{
|
grdMain.Rows[j].Cells[HBaNoCol].Value = sHCode2;
|
grdMain.Rows[j].Cells[HBatchNoCol].Value = DBUtility.ClsPub.isStrNull(oDsBatchNo.Tables[0].Rows[0]["HBatchNo"]);
|
grdMain.Rows[j].Cells[HCode2Col].Value = DBUtility.ClsPub.isStrNull(oDsBatchNo.Tables[0].Rows[0]["HCode2"]);
|
}
|
|
HBatchNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value);
|
HCode3 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value);
|
//获取最大流水号
|
LSH = 0;
|
Ds = oCn.RunProcReturn("select top 1 HSno from Gy_BarCodeBill_Cus where HBatchNo='" + HBatchNo + "' order by HSno desc", "Gy_BarCodeBill_Cus");
|
if (Ds != null && Ds.Tables[0].Rows.Count != 0)
|
{
|
LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
|
}
|
|
HBQty = ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value);
|
HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value);
|
HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value);
|
|
for (int i = 0; i < HBQty; i++)
|
{
|
if (HSumQty - HMinQty > 0)
|
{
|
HSumQty = HSumQty - HMinQty;
|
}
|
else
|
{
|
HMinQty = HSumQty;
|
}
|
//
|
LSH = LSH + 1;
|
LSH2 = LSH.ToString();
|
//LSH2 = ConvertToBase(LSH, 34);
|
while (LSH2.Length < LSHlen) //如果流水号位数小于 LSHlen 前面补0
|
{
|
LSH2 = "0" + LSH2;
|
}
|
//条码编号 = 批次 + 流水号 + 版本号
|
TM = HBatchNo + LSH2 + HCode3;
|
|
HEntryID = j + 1;
|
HBarCode = TM.ToUpper();
|
HBarCodeType = "内箱码";
|
HMaterID = ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value);
|
HUnitID = ClsPub.isLong(grdMain.Rows[j].Cells[HUnitIDCol].Value);
|
HAuxPropID = ClsPub.isLong(grdMain.Rows[j].Cells[HAuxPropIDCol].Value);
|
HQty = HMinQty;
|
HCusID = ClsPub.isLong(cmbHCusName.SelectedValue);
|
HCusModelName = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusModelNameCol].Value);
|
HGiveAwayFlag = ClsPub.isBool(grdMain.Rows[j].Cells[HGiveAwayFlagCol].Value);
|
HISKFPERIOD = ClsPub.isBool(grdMain.Rows[j].Cells[HISKFPERIODCol].Value);
|
HProduceDate = ClsPub.isStrNull(grdMain.Rows[j].Cells[HProduceDateCol].Value);
|
HExpiryDate = ClsPub.isStrNull(grdMain.Rows[j].Cells[HExpiryDateCol].Value);
|
HBarcodeQtys = HBQty;
|
HBarcodeNo = i + 1;
|
HSourceInterID = ClsPub.isLong(grdMain.Rows[j].Cells[HSourceInterIDCol].Value);
|
HSourceEntryID = ClsPub.isLong(grdMain.Rows[j].Cells[HSourceEntryIDCol].Value);
|
HSourceBillNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HSourceBillNoCol].Value);
|
HSourceBillType = ClsPub.isStrNull(grdMain.Rows[j].Cells[HSourceBillTypeCol].Value);
|
HRemark = ClsPub.isStrNull(grdMain.Rows[j].Cells[HRemarkCol].Value);
|
HMTONo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HMTONoCol].Value);
|
HInnerBillNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HInnerBillNoCol].Value);
|
HCode1 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode1Col].Value).ToUpper();
|
HCode2 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode2Col].Value).ToUpper();
|
HCode3 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value).ToUpper();
|
HSno = LSH;
|
HBoxNo = HCode1 + sYear + sPeriod + sDay + HCusModel;
|
HBoxNo = HBoxNo.ToUpper();
|
sHBaNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBaNoCol].Value); // 界面上输入的批次位
|
|
//客户料号HCusModelName、物料类别HCode1、批次位HCode2、版本号HCode3、批次序列号HSno、批次生成前缀HBoxNo、厂商代码HCusModel
|
//界面上输入的批次位HSupName、36进制批次序列号HSupNumber、客户订单号HInnerBillNo
|
oCn.RunProc("insert into Gy_BarCodeBill_Cus" +
|
"(HInterID,HEntryID,HBillType,HBarCode,HBarCodeType" +
|
",HMaterID,HUnitID,HAuxPropID,HBatchNo,HQty" +
|
",HCusID,HCusModel,HCusModelName,HBarCodeDate,HBarCodeStatus" +
|
",HGiveAwayFlag,HISKFPERIOD,HEndQty" +
|
",HProduceDate,HExpiryDate" +
|
",HBarcodeQtys,HBarcodeNo,HPieceQty,HPrintQty" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType " +
|
",HStopflag,HUseFlag,HRemark,HSTOCKORGID,HOWNERID" +
|
",HMaker,HMakeDate,HStopMan,HWorkLineName,HMTONo" +
|
",HKFPeriod,HKFDate,HKFDQDate,HInnerBillNo" +
|
",HStatus,HDeleteMan,HSupNumber,HSupName,HCode1" +
|
",HCode2,HCode3,HBackDataFlag,HSno,HBoxNo" +
|
") values (" + HInterID + "," + HEntryID + ",'','" + HBarCode + "','" + HBarCodeType + "'"
|
+ "," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HAuxPropID.ToString() + ",'" + HBatchNo + "'," + HQty.ToString()
|
+ "," + HCusID.ToString() + ",'" + HCusModel + "','" + HCusModelName + "','" + sDate + "',''"
|
+ "," + DBUtility.ClsPub.BoolToString(HGiveAwayFlag) + "," + DBUtility.ClsPub.BoolToString(HISKFPERIOD) + ",''"
|
+ "," + (HProduceDate == "" ? "NULL" : "'" + HProduceDate + "'") + "," + (HExpiryDate == "" ? "NULL" : "'" + HExpiryDate + "'")
|
+ "," + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + ",1,0"
|
+ "," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "'"
|
+ ",0,'','" + HRemark + "'," + HOrgID.ToString() + "," + HOrgID.ToString()
|
+ ",'" + ClsPub.CurUserName + "',getdate(),'','','" + HMTONo + "'"
|
+ ",0,'','','" + HInnerBillNo + "'"
|
+ ",'','','" + LSH2 + "','" + sHBaNo + "','" + HCode1 + "'"
|
+ ",'" + HCode2 + "','" + HCode3 + "',''," + HSno.ToString() + ",'" + HBoxNo + "')");
|
pb1.Value = n + 1;
|
n = n + 1;
|
}
|
}
|
}
|
|
//生成外箱条码
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0)
|
{
|
HBatchNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value);
|
HCode3 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value);
|
//获取最大流水号
|
//条码前缀 = 供应商代码 + 年 + 月 + 日
|
sTMNumber = HCusModel + sYear4 + sPeriod2 + sDay;
|
Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //获取最大流水号
|
LWSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
|
|
HWBQty = ClsPub.isInt(grdMain.Rows[j].Cells[HWBQtyCol].Value);
|
HWMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HWMinQtyCol].Value);
|
HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value);
|
|
int nn = 0; //本次流水号累计使用个数
|
for (int i = 0; i < HWBQty; i++)
|
{
|
if (HSumQty - HWMinQty > 0)
|
{
|
HSumQty = HSumQty - HWMinQty;
|
}
|
else
|
{
|
HWMinQty = HSumQty;
|
}
|
//
|
LWSH = LWSH + 1;
|
LSH2 = LWSH.ToString();
|
while (LSH2.Length < 5) //如果流水号位数小于 5 前面补0
|
{
|
LSH2 = "0" + LSH2;
|
}
|
TM = sTMNumber + LSH2;
|
|
HEntryID = j + 1;
|
HBarCode = TM.ToUpper();
|
HBarCodeType = "外箱码";
|
HMaterID = ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value);
|
HUnitID = ClsPub.isLong(grdMain.Rows[j].Cells[HUnitIDCol].Value);
|
HAuxPropID = ClsPub.isLong(grdMain.Rows[j].Cells[HAuxPropIDCol].Value);
|
HQty = HWMinQty;
|
HCusID = ClsPub.isLong(cmbHCusName.SelectedValue);
|
HCusModelName = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusModelNameCol].Value);
|
HGiveAwayFlag = ClsPub.isBool(grdMain.Rows[j].Cells[HGiveAwayFlagCol].Value);
|
HISKFPERIOD = ClsPub.isBool(grdMain.Rows[j].Cells[HISKFPERIODCol].Value);
|
HProduceDate = ClsPub.isStrNull(grdMain.Rows[j].Cells[HProduceDateCol].Value);
|
HExpiryDate = ClsPub.isStrNull(grdMain.Rows[j].Cells[HExpiryDateCol].Value);
|
HBarcodeQtys = HWBQty;
|
HBarcodeNo = i + 1;
|
HSourceInterID = ClsPub.isLong(grdMain.Rows[j].Cells[HSourceInterIDCol].Value);
|
HSourceEntryID = ClsPub.isLong(grdMain.Rows[j].Cells[HSourceEntryIDCol].Value);
|
HSourceBillNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HSourceBillNoCol].Value);
|
HSourceBillType = ClsPub.isStrNull(grdMain.Rows[j].Cells[HSourceBillTypeCol].Value);
|
HRemark = ClsPub.isStrNull(grdMain.Rows[j].Cells[HRemarkCol].Value);
|
HMTONo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HMTONoCol].Value);
|
HInnerBillNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HInnerBillNoCol].Value);
|
HCode1 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode1Col].Value).ToUpper();
|
HCode2 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode2Col].Value).ToUpper();
|
HCode3 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value).ToUpper();
|
HSno = 0;
|
HBoxNo = HCode1 + sYear + sPeriod + sDay + HCusModel;
|
HBoxNo = HBoxNo.ToUpper();
|
sHBaNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBaNoCol].Value); // 界面上输入的批次位
|
|
//客户料号HCusModelName、物料类别HCode1、批次位HCode2、版本号HCode3、批次序列号HSno、批次生成前缀HBoxNo、厂商代码HCusModel
|
//界面上输入的批次位HSupName、36进制批次序列号HSupNumber、客户订单号HInnerBillNo
|
oCn.RunProc("insert into Gy_BarCodeBill_Cus" +
|
"(HInterID,HEntryID,HBillType,HBarCode,HBarCodeType" +
|
",HMaterID,HUnitID,HAuxPropID,HBatchNo,HQty" +
|
",HCusID,HCusModel,HCusModelName,HBarCodeDate,HBarCodeStatus" +
|
",HGiveAwayFlag,HISKFPERIOD,HEndQty" +
|
",HProduceDate,HExpiryDate" +
|
",HBarcodeQtys,HBarcodeNo,HPieceQty,HPrintQty" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType " +
|
",HStopflag,HUseFlag,HRemark,HSTOCKORGID,HOWNERID" +
|
",HMaker,HMakeDate,HStopMan,HWorkLineName,HMTONo" +
|
",HKFPeriod,HKFDate,HKFDQDate,HInnerBillNo" +
|
",HStatus,HDeleteMan,HSupNumber,HSupName,HCode1" +
|
",HCode2,HCode3,HBackDataFlag,HSno,HBoxNo" +
|
") values (" + HInterID + "," + HEntryID + ",'','" + HBarCode + "','" + HBarCodeType + "'"
|
+ "," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HAuxPropID.ToString() + ",'" + HBatchNo + "'," + HQty.ToString()
|
+ "," + HCusID.ToString() + ",'" + HCusModel + "','" + HCusModelName + "','" + sDate + "',''"
|
+ "," + DBUtility.ClsPub.BoolToString(HGiveAwayFlag) + "," + DBUtility.ClsPub.BoolToString(HISKFPERIOD) + ",''"
|
+ "," + (HProduceDate == "" ? "NULL" : "'" + HProduceDate + "'") + "," + (HExpiryDate == "" ? "NULL" : "'" + HExpiryDate + "'")
|
+ "," + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + ",1,0"
|
+ "," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "'"
|
+ ",0,'','" + HRemark + "'," + HOrgID.ToString() + "," + HOrgID.ToString()
|
+ ",'" + ClsPub.CurUserName + "',getdate(),'','','" + HMTONo + "'"
|
+ ",0,'','','" + HInnerBillNo + "'"
|
+ ",'','','" + LSH2 + "','" + sHBaNo + "','" + HCode1 + "'"
|
+ ",'" + HCode2 + "','" + HCode3 + "',''," + HSno.ToString() + ",'" + HBoxNo + "')");
|
pb1.Value = n + 1;
|
n = n + 1;
|
nn = nn + 1;
|
}
|
//回填流水号信息
|
oCn.RunProc("exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "'," + nn.ToString() + " ");
|
}
|
}
|
oCn.Commit();
|
MessageBox.Show("客户标签生成完毕!");
|
tabControl1.SelectedIndex = 1;
|
}
|
catch (Exception e)
|
{
|
bc.Enabled = true;
|
oCn.RollBack();
|
MessageBox.Show("客户标签生成失败!" + e.Message);
|
}
|
}
|
|
#endregion
|
|
#region 刷新条码列表
|
private void Display()
|
{
|
//刷新内箱码列表
|
DataSet DSet = oCn.RunProcReturn("select * from h_v_Gy_BarCodeBill_CusList where HInterID=" + HInterID.ToString() + " and 条码类型='内箱码' order by HItemID", "h_v_Gy_BarCodeBill_CusList", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
//MessageBox.Show("没有返回任何结果,条码不存在!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdSub.DataSource = DSet.Tables[0].DefaultView;
|
|
//刷新外箱码列表
|
DataSet DWSet = oCn.RunProcReturn("select * from h_v_Gy_BarCodeBill_CusList where HInterID=" + HInterID.ToString() + " and 条码类型='外箱码' order by HItemID", "h_v_Gy_BarCodeBill_CusList", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DWSet == null)
|
{
|
//MessageBox.Show("没有返回任何结果,条码不存在!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdList.DataSource = DWSet.Tables[0].DefaultView;
|
|
//冻结
|
int FrCol = 0;
|
string s = "是";
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol);
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdList, this.Name + "grdList", s, FrCol);
|
//画线
|
GraphLine();
|
}
|
private void GraphLine()
|
{
|
int MainIDCol = Fun_GetCol("hmainid");
|
int SubIDCol = Fun_GetCol("hsubid");
|
int WMainIDCol = Fun_GetCol_w("hmainid");
|
int WSubIDCol = Fun_GetCol_w("hsubid");
|
string s = "是";
|
long n = 0;
|
DBUtility.Xt_BaseBillFun.GraphLine(grdSub, MainIDCol, SubIDCol, s, ref n);
|
DBUtility.Xt_BaseBillFun.GraphLine(grdList, WMainIDCol, WSubIDCol, s, ref n);
|
}
|
|
#endregion
|
|
#region 将十进制数值转成指定进制数值(num为要转换的十进行数值,nbase为指定进制)
|
public string ConvertToBase(int num, int nbase)
|
{
|
string chars = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
if (nbase < 2 || nbase > chars.Length)
|
return "";
|
int r;
|
string newNumber = "";
|
while (num >= nbase)
|
{
|
r = num % nbase;
|
newNumber = chars[r] + newNumber;
|
num = num / nbase;
|
}
|
newNumber = chars[num] + newNumber;
|
return newNumber;
|
}
|
|
#endregion
|
|
#endregion
|
|
|
#region 窗体处理方法
|
//初始化GRID
|
private void initGrid()
|
{
|
grdMain.RowCount = 0;
|
grdMain.ColumnCount = 46; //总列数
|
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[HCusModelNameCol].HeaderText = "客户料号";
|
grdMain.Columns[HUnitIDCol].HeaderText = "计量单位ID";
|
grdMain.Columns[HUnitNumberCol].HeaderText = "计量单位代码";
|
grdMain.Columns[HUnitNameCol].HeaderText = "计量单位名称";
|
grdMain.Columns[HAuxPropIDCol].HeaderText = "辅助属性ID";
|
grdMain.Columns[HAuxPropNumberCol].HeaderText = "辅助属性代码";
|
grdMain.Columns[HAuxPropNameCol].HeaderText = "辅助属性名称";
|
grdMain.Columns[HBatchManagerCol].HeaderText = "是否启用批次";
|
grdMain.Columns[HBatchNoCol].HeaderText = "批号";
|
grdMain.Columns[HGiveAwayFlagCol].HeaderText = "是否赠品";
|
grdMain.Columns[HQtyCol].HeaderText = "数量";
|
grdMain.Columns[HMinQtyCol].HeaderText = "内箱最小包装数";
|
grdMain.Columns[HBQtyCol].HeaderText = "内箱箱数";
|
grdMain.Columns[HWMinQtyCol].HeaderText = "外箱最小包装数";
|
grdMain.Columns[HWBQtyCol].HeaderText = "外箱箱数";
|
grdMain.Columns[HCusIDCol].HeaderText = "客户ID";
|
grdMain.Columns[HCusNumberCol].HeaderText = "客户代码";
|
grdMain.Columns[HCusNameCol].HeaderText = "客户";
|
grdMain.Columns[HProduceDateCol].HeaderText = "生产日期";
|
grdMain.Columns[HExpiryDateCol].HeaderText = "有效期至";
|
grdMain.Columns[HISKFPERIODCol].HeaderText = "是否启用保质期";
|
grdMain.Columns[HEXPUNITCol].HeaderText = "保质期单位";
|
grdMain.Columns[HEXPPERIODCol].HeaderText = "保质期";
|
grdMain.Columns[HRemarkCol].HeaderText = "备注";
|
grdMain.Columns[HMTONoCol].HeaderText = "计划跟踪号";
|
grdMain.Columns[HCode1Col].HeaderText = "物料类别";
|
grdMain.Columns[HCode2Col].HeaderText = "批次位";
|
grdMain.Columns[HCode3Col].HeaderText = "版本号";
|
grdMain.Columns[HInnerBillNoCol].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[HUnitIDCol].Visible = false;
|
grdMain.Columns[HUnitNumberCol].Visible = false;
|
grdMain.Columns[HUnitNameCol].Visible = false;
|
grdMain.Columns[HAuxPropIDCol].Visible = false;
|
grdMain.Columns[HAuxPropNumberCol].Visible = false;
|
grdMain.Columns[HAuxPropNameCol].Visible = false;
|
grdMain.Columns[HBatchManagerCol].Visible = false;
|
grdMain.Columns[HGiveAwayFlagCol].Visible = false;
|
grdMain.Columns[HProduceDateCol].Visible = false;
|
grdMain.Columns[HExpiryDateCol].Visible = false;
|
grdMain.Columns[HCusIDCol].Visible = false;
|
grdMain.Columns[HCusNumberCol].Visible = false;
|
grdMain.Columns[HCusNameCol].Visible = false;
|
grdMain.Columns[HSourceInterIDCol].Visible = false;
|
grdMain.Columns[HSourceEntryIDCol].Visible = false;
|
grdMain.Columns[HSourceBillNoCol].Visible = false;
|
grdMain.Columns[HSourceBillTypeCol].Visible = false;
|
grdMain.Columns[HInitQtyCol].Visible = false;
|
grdMain.Columns[HMTONoCol].Visible = false;
|
grdMain.Columns[HISKFPERIODCol].Visible = false;
|
grdMain.Columns[HEXPUNITCol].Visible = false;
|
grdMain.Columns[HEXPPERIODCol].Visible = false;
|
grdMain.Columns[HLSHCol].Visible = false;
|
grdMain.Columns[HBaNoCol].Visible = false;
|
|
//设置可编辑列
|
string sAllowCol = HQtyCol.ToString()+
|
"," + HMinQtyCol.ToString() +
|
"," + HWMinQtyCol.ToString() +
|
//"," + HMaterNumberCol.ToString() +
|
"," + HAuxPropNumberCol.ToString() +
|
"," + HUnitNumberCol.ToString() +
|
//"," + HCode1Col.ToString() +
|
//"," + HCode2Col.ToString() +
|
//"," + HCode3Col.ToString() +
|
"," + HInnerBillNoCol.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);
|
DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name);
|
DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub");
|
DBUtility.Xt_BaseBillFun.initGridList(grdList, this.Name + "grdList");
|
}
|
|
//公式重算
|
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;
|
|
//外箱数列=数量/外箱最小包装数
|
double sWMoney = 0;
|
if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HWMinQtyCol].Value) == 0)
|
{
|
sWMoney = 0;
|
}
|
else
|
{
|
sWMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HWMinQtyCol].Value);
|
}
|
sWMoney = Math.Ceiling(sWMoney);
|
grdMain.Rows[sRow].Cells[HWBQtyCol].Value = sWMoney;
|
}
|
else
|
{
|
|
}
|
}
|
|
//是否是空行
|
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;
|
}
|
|
//帮助函数
|
private void Sub_GridKey(int sKeyCode, int sRow, int sCol, DataGridViewTextBoxEditingControl oEdit)
|
{
|
string sWhere = "";
|
DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();//物料
|
DAL.ClsIF_Unit_View oUnit = new DAL.ClsIF_Unit_View();//计量单位
|
DAL.ClsIF_Property_View oProperty = new DAL.ClsIF_Property_View();//辅助属性
|
if (!grdStatus)
|
{
|
return;
|
}
|
oSumGrid.EditStatus = true;
|
|
switch (sKeyCode)
|
{
|
case 118: //F7
|
{
|
switch (sCol)
|
{
|
case HMaterNumberCol:
|
oMater.WherePart = "";
|
sWhere = " and HUSEORGID = " + HOrgID;
|
if (oMater.RefreshViewForBig(sWhere))
|
{
|
if (oMater.GetInfoByID(oMater.oModel.HItemID))
|
{
|
grdMain.Rows[sRow].Cells[HMaterIDCol].Value = oMater.omodel.HItemID.ToString();
|
grdMain.Rows[sRow].Cells[HMaterNumberCol].Value = oMater.omodel.HNumber;
|
grdMain.Rows[sRow].Cells[HMaterNameCol].Value = oMater.omodel.HName;
|
grdMain.Rows[sRow].Cells[HMaterModelCol].Value = oMater.omodel.HModel;
|
grdMain.Rows[sRow].Cells[HMinQtyCol].Value = oMater.omodel.HQtyMin;
|
grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HAuxPropNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HAuxPropNameCol].Value = "";
|
if (oUnit.GetInfoByID(oMater.omodel.HUnitID))
|
{
|
grdMain.Rows[sRow].Cells[HUnitIDCol].Value = oUnit.omodel.HItemID.ToString();
|
grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = oUnit.omodel.HNumber;
|
grdMain.Rows[sRow].Cells[HUnitNameCol].Value = oUnit.omodel.HName;
|
}
|
else
|
{
|
grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HUnitNameCol].Value = "";
|
}
|
GetCusMatNo(2);
|
oEdit.Text = oMater.omodel.HNumber;
|
}
|
else
|
{
|
grdMain.Rows[sRow].Cells[HMaterIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HMaterNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HMaterNameCol].Value = "";
|
grdMain.Rows[sRow].Cells[HMaterModelCol].Value = "";
|
grdMain.Rows[sRow].Cells[HMinQtyCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HUnitNameCol].Value = "";
|
grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HAuxPropNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HAuxPropNameCol].Value = "";
|
}
|
}
|
else
|
{
|
grdMain.Rows[sRow].Cells[HMaterIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HMaterNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HMaterNameCol].Value = "";
|
grdMain.Rows[sRow].Cells[HMaterModelCol].Value = "";
|
grdMain.Rows[sRow].Cells[HMinQtyCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HUnitNameCol].Value = "";
|
grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HAuxPropNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HAuxPropNameCol].Value = "";
|
}
|
break;
|
|
case HUnitNumberCol:
|
oUnit.WherePart = "";
|
if (oUnit.RefreshView())
|
{
|
grdMain.Rows[sRow].Cells[HUnitIDCol].Value = oUnit.oModel.HItemID.ToString();
|
grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = oUnit.oModel.HNumber;
|
grdMain.Rows[sRow].Cells[HUnitNameCol].Value = oUnit.oModel.HName;
|
EditingControl.Text = oUnit.oModel.HNumber;
|
}
|
else
|
{
|
grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HUnitNameCol].Value = "";
|
}
|
break;
|
|
case HCusNumberCol:
|
BLL.ClsBaseSelect_InterFace.SetGridByCus(grdMain, sRow, HCusIDCol, HCusNumberCol, HCusNameCol);
|
oEdit.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HCusNumberCol].Value);
|
break;
|
|
case HAuxPropNumberCol:
|
oProperty.WherePart = "";
|
sWhere = " and HMaterNumber = '" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[HMaterNumberCol].Value) + "'";
|
|
if (oProperty.RefreshView(sWhere))
|
{
|
grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value = oProperty.oModel.HItemID.ToString();
|
grdMain.Rows[sRow].Cells[HAuxPropNumberCol].Value = oProperty.oModel.HNumber;
|
grdMain.Rows[sRow].Cells[HAuxPropNameCol].Value = oProperty.oModel.HName;
|
oEdit.Text = oProperty.oModel.HNumber;
|
}
|
else
|
{
|
grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HAuxPropNumberCol].Value = "";
|
grdMain.Rows[sRow].Cells[HAuxPropNameCol].Value = "";
|
}
|
break;
|
|
default:
|
break;
|
}
|
bc.Enabled = true;
|
break;
|
}
|
case 117: //F6
|
{
|
switch (sCol)
|
{
|
|
|
default:
|
break;
|
}
|
break;
|
}
|
default:
|
break;
|
}
|
}
|
|
//网格编辑前判断
|
private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
|
{
|
int i = grdMain.CurrentCell.ColumnIndex;
|
if (DBUtility.Xt_BaseBillFun.AllowEdit(grdStatus, oSumGrid,i))
|
{
|
e.Cancel = true;
|
}
|
}
|
|
//网格编辑后处理
|
private void grdMain_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
if (e.ColumnIndex == HMinQtyCol)
|
{
|
RowCount(e.RowIndex, 0); //
|
}
|
else if (e.ColumnIndex == HWMinQtyCol)
|
{
|
RowCount(e.RowIndex, 0); //
|
}
|
else if (e.ColumnIndex == HQtyCol)
|
{
|
RowCount(e.RowIndex, 0); //
|
}
|
//
|
if (this.EditingControl != null) //释放事件
|
{
|
EditingControl.KeyDown -= new KeyEventHandler(this.EditingControl_KeyDown);
|
this.EditingControl = null;
|
}
|
}
|
DataGridViewTextBoxEditingControl EditingControl;
|
|
private void grdMain_CellLeave(object sender, DataGridViewCellEventArgs e)
|
{
|
if (!grdStatus)
|
{
|
return;
|
}
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
//
|
//if (oSumGrid.Changelock)
|
// return;
|
//if(oSumGrid.EditStatus)
|
//{
|
if (!CheckGridRow(oSumGrid.OldCell.Row))
|
return;
|
//}
|
}
|
|
private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
}
|
|
private void grdMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
|
{
|
if (grdMain.CurrentCell != null)
|
{
|
if (e.Control is DataGridViewTextBoxEditingControl)
|
{
|
this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control;
|
//增加委托处理
|
this.EditingControl.KeyDown += new KeyEventHandler(this.EditingControl_KeyDown);
|
}
|
}
|
}
|
|
private void EditingControl_KeyDown(object sender, KeyEventArgs e)
|
{
|
//业务处理
|
Sub_GridKey(e.KeyValue, grdMain.CurrentRow.Index, grdMain.CurrentCell.ColumnIndex, EditingControl);
|
}
|
|
private void grdMain_RowHeadersWidthChanged(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
}
|
|
private void grdMain_Scroll(object sender, ScrollEventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
oSumGrid.DisplayCurRow();
|
}
|
|
#endregion
|
|
|
#region 选源单返回信息 按放大镜图标返回
|
|
private void cmdSourceBillNo_Click(object sender, EventArgs e)
|
{
|
if (cmbSourceBillType.Text.Trim() == "生产订单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_ICMOBillList_CusBarCodeBill oIF_ICMOBillList = new DAL.Cls_S_IF_ICMOBillList_CusBarCodeBill();
|
if (oIF_ICMOBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_ICMOBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "生产汇报单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_ICMOReportBillList_CusBarCodeBill oIF_ICMOReportBillList = new DAL.Cls_S_IF_ICMOReportBillList_CusBarCodeBill();
|
if (oIF_ICMOReportBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_ICMOReportBillList.oBillSelectColl);
|
}
|
}
|
}
|
|
private void FillSelectData(List<DBUtility.BillSelect> oList)
|
{
|
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("select * from h_v_Sc_ICMOBillList_CusBarCodeBill where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_Sc_ICMOBillList_CusBarCodeBill");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
GetCusMatNo(1);
|
}
|
//生产汇报单
|
else if (oSelectRow.BillType == "3711")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_Sc_ICMOReportList_CusBarCodeBill where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_Sc_ICMOReportList_CusBarCodeBill");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
GetCusMatNo(1);
|
}
|
}
|
//
|
oSumGrid.Changelock = false;
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
}
|
|
//根据TABLE写入界面
|
private void Sub_WriteInForm1(DataTable oTable, int i)
|
{
|
//加载表体
|
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[HBillTypeCol].Value = oTable.Rows[0]["HBillType"].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[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[HAuxPropIDCol].Value = oTable.Rows[0]["HAuxPropID"].ToString();
|
grdMain.Rows[i].Cells[HAuxPropNumberCol].Value = oTable.Rows[0]["辅助属性代码"].ToString();
|
grdMain.Rows[i].Cells[HAuxPropNameCol].Value = oTable.Rows[0]["辅助属性"].ToString();
|
grdMain.Rows[i].Cells[HBatchManagerCol].Value = oTable.Rows[0]["备注"].ToString();
|
grdMain.Rows[i].Cells[HCode1Col].Value = oTable.Rows[0]["物料类别"].ToString();
|
grdMain.Rows[i].Cells[HCode3Col].Value = oTable.Rows[0]["版本号"].ToString();
|
grdMain.Rows[i].Cells[HMinQtyCol].Value = oTable.Rows[0]["最小包装数"].ToString();
|
grdMain.Rows[i].Cells[HSourceInterIDCol].Value = oTable.Rows[0]["hmainid"].ToString();
|
grdMain.Rows[i].Cells[HSourceEntryIDCol].Value = oTable.Rows[0]["hsubid"].ToString();
|
grdMain.Rows[i].Cells[HSourceBillNoCol].Value = oTable.Rows[0]["单据号"].ToString();
|
grdMain.Rows[i].Cells[HSourceBillTypeCol].Value = oTable.Rows[0]["HBillType"].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[HProduceDateCol].Value = oTable.Rows[0]["生产日期"].ToString();
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = oTable.Rows[0]["有效期至"].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();
|
grdMain.Rows[i].Cells[HInnerBillNoCol].Value = oTable.Rows[0]["销售订单编号"].ToString();
|
//--
|
//设置可编辑列
|
string sAllowCol = HQtyCol.ToString() +
|
"," + HMinQtyCol.ToString() +
|
"," + HWMinQtyCol.ToString() +
|
"," + HAuxPropNumberCol.ToString() +
|
//"," + HCode1Col.ToString() +
|
//"," + HCode2Col.ToString() +
|
//"," + HCode3Col.ToString() +
|
"," + HInnerBillNoCol.ToString() +
|
"," + HRemarkCol.ToString();
|
grdMain.Columns[HBillNoCol].ReadOnly = true;
|
//设置合计列
|
string sTotalCol = HQtyCol.ToString();
|
//
|
DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid);
|
tabControl1.SelectedIndex = 0;
|
bc.Enabled = true;
|
//
|
RowCount(i, 0);
|
}
|
|
#endregion
|
|
|
#region 选源单返回信息 按回车键返回
|
private void txtHSourceBillNo_KeyPress(object sender, KeyPressEventArgs e)
|
{
|
if (e.KeyChar == (char)Keys.Return)//回车带出源单信息
|
{
|
if (txtHSourceBillNo.Text.Length < 4)
|
{
|
MessageBox.Show("请输入4位以上数据!");
|
return;
|
}
|
//根据源单类型 和源单号 获取信息
|
if (cmbSourceBillType.Text.Trim() == "生产订单")
|
{
|
DAL.Cls_S_IF_ICMOBillList_CusBarCodeBill oIF_ICMOBillList = new DAL.Cls_S_IF_ICMOBillList_CusBarCodeBill();
|
if (oIF_ICMOBillList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + HOrgID.ToString())) //选择原单
|
{
|
FillSelectData(oIF_ICMOBillList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "生产汇报单")
|
{
|
DAL.Cls_S_IF_ICMOReportBillList_CusBarCodeBill oIF_ICMOReportBillList = new DAL.Cls_S_IF_ICMOReportBillList_CusBarCodeBill();
|
if (oIF_ICMOReportBillList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + HOrgID.ToString())) //选择原单
|
{
|
FillSelectData(oIF_ICMOReportBillList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("所选源单类型,不支持此功能!");
|
return;
|
}
|
|
}
|
}
|
|
#endregion
|
|
|
#region //打印设置
|
|
GridppReport Report;
|
|
#region 内箱预览、打印
|
|
#region 内箱预览
|
private void yl_Click(object sender, EventArgs e)
|
{
|
//判断是否已经生成条码
|
if (grdSub.Rows.Count < 1)
|
{
|
MessageBox.Show("内箱条码未生成,请先生成条码后再预览!");
|
return;
|
}
|
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.PrintPreview(false);
|
Thread.Sleep(1000);
|
}
|
}
|
|
#endregion
|
|
#region 内箱打印
|
private void dy_Click(object sender, EventArgs e)
|
{
|
//判断是否已经生成条码
|
if (grdSub.Rows.Count < 1)
|
{
|
MessageBox.Show("内箱条码未生成,请先生成条码后再打印!");
|
return;
|
}
|
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption;
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
//循环选中行
|
Sub_SetReport(oFrm.sOpenTmp);
|
Report.Print(true);
|
Thread.Sleep(1000);
|
}
|
}
|
|
#endregion
|
|
private void Sub_SetReport(string sOpenTmp)
|
{
|
//判断行数
|
for (int i = 0; i < grdSub.Rows.Count; i++)
|
{
|
grdSub.Rows[i].Cells[0].Value = "*";
|
}
|
//
|
Report = new GridppReport();
|
Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here .
|
Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
|
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
|
Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
|
}
|
|
//填入单据表头信息
|
private void ReportBeforePostRecord()//
|
{
|
try
|
{
|
//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, grdSub, ds, Fun_GetCol("选择"));
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("内箱条码打印失败!表体:" + e.Message);
|
}
|
}
|
|
//打印结束后回填条码打印次数
|
private void ReportPrintEnd()
|
{
|
try
|
{
|
oCn.RunProc("update Gy_BarCodeBill_Cus set HPrintQty=isnull(HPrintQty,0)+1 where HBarCodeType='内箱码' and HInterID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("内箱条码打印失败!打印结束 :" + e.Message);
|
}
|
}
|
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdSub);
|
}
|
|
#endregion
|
|
#region 外箱预览、打印
|
|
#region 外箱预览
|
private void ylw_Click(object sender, EventArgs e)
|
{
|
//判断是否已经生成条码
|
if (grdList.Rows.Count < 1)
|
{
|
MessageBox.Show("外箱条码未生成,请先生成条码后再预览!");
|
return;
|
}
|
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption + "_外箱";
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
Sub_SetReport_w(oFrm.sOpenTmp);
|
Report.PrintPreview(false);
|
Thread.Sleep(1000);
|
}
|
}
|
|
#endregion
|
|
#region 外箱打印
|
private void dyw_Click(object sender, EventArgs e)
|
{
|
//判断是否已经生成条码
|
if (grdList.Rows.Count < 1)
|
{
|
MessageBox.Show("外箱条码未生成,请先生成条码后再打印!");
|
return;
|
}
|
|
//选择打印模板
|
BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
|
oFrm.sBillName = ModName;
|
oFrm.sBillModel = ModCaption + "_外箱";
|
oFrm.ShowDialog();
|
if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
//循环选中行
|
Sub_SetReport_w(oFrm.sOpenTmp);
|
Report.Print(true);
|
Thread.Sleep(1000);
|
}
|
}
|
|
#endregion
|
|
|
private void Sub_SetReport_w(string sOpenTmp)
|
{
|
//判断行数
|
for (int i = 0; i < grdList.Rows.Count; i++)
|
{
|
grdList.Rows[i].Cells[0].Value = "*";
|
}
|
//
|
Report = new GridppReport();
|
Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here .
|
Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord_w);
|
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable_w);
|
Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd_w);
|
}
|
//填入单据表头信息
|
private void ReportBeforePostRecord_w()//
|
{
|
try
|
{
|
//Report.FieldByName("备注").AsString = ClsPub.isStrNull(grdList.Rows[CurRows].Cells[HRemark2Col].Value);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("外箱条码打印失败!表头:" + e.Message);
|
}
|
}
|
|
//填入单据表体信息
|
private void ReportFetchRecordByDataTable_w()
|
{
|
try
|
{
|
DataTable ds = new DataTable();
|
BLL.Utility.FillRecordToReport_Sel(Report, grdList, ds, Fun_GetCol_w("选择"));
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("外箱条码打印失败!表体:" + e.Message);
|
}
|
}
|
|
//打印结束后回填条码打印次数
|
private void ReportPrintEnd_w()
|
{
|
try
|
{
|
oCn.RunProc("update Gy_BarCodeBill_Cus set HPrintQty=isnull(HPrintQty,0)+1 where HBarCodeType='外箱码' and HInterID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("外箱条码打印失败!打印结束 :" + e.Message);
|
}
|
}
|
|
private Int32 Fun_GetCol_w(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 获取客户料号
|
private void GetCusMatNo(int num)
|
{
|
Int64 HCusID = ClsPub.isLong(cmbHCusName.SelectedValue); //客户ID
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
long HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value); // 物料ID
|
|
if (HMaterID != 0)
|
{
|
DataSet ds = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_CusMatNo " + num.ToString() + "," + HCusID.ToString() + "," + HMaterID.ToString(), "h_p_Gy_CusBarCodeBill_CusMatNo");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
grdMain.Rows[j].Cells[HCusModelNameCol].Value = "";
|
}
|
else
|
{
|
grdMain.Rows[j].Cells[HCusModelNameCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCusRelationNumber"]);
|
if (num == 2)
|
{
|
grdMain.Rows[j].Cells[HCode1Col].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCode1"]);
|
grdMain.Rows[j].Cells[HCode3Col].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCode3"]);
|
}
|
}
|
}
|
}
|
}
|
|
#endregion
|
|
|
#region 选择客户
|
private void cmbHCusName_TextChanged(object sender, EventArgs e)
|
{
|
GetCusMatNo(1);
|
}
|
|
#endregion
|
|
|
#region 选择组织
|
private void cmbHOrgID_SelectionChangeCommitted(object sender, EventArgs e)
|
{
|
HOrgID = ClsPub.isLong(cmbHOrgID.SelectedValue);
|
//加载客户信息
|
Sub_AddHCusNameList();
|
//清空初始化列表
|
initGrid();
|
grdMain.Columns[HBillNoCol].ReadOnly = false;
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
}
|