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_BarCodeBill_Rework : Form
|
{
|
public Gy_BarCodeBill_Rework()
|
{
|
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 HAuxPropIDCol = 11;
|
public const Int16 HAuxPropNumberCol = 12;
|
public const Int16 HAuxPropNameCol = 13;
|
public const Int16 HBatchManagerCol = 14;
|
public const Int16 HBatchNoCol = 15;
|
public const Int16 HBarCodeTypeCol = 16;
|
public const Int16 HQtyCol = 17;
|
public const Int16 HMinQtyCol = 18;
|
public const Int16 HBQtyCol = 19;
|
public const Int16 HinitQtyCol = 20;
|
public const Int16 HISKFPERIODCol = 21;
|
public const Int16 HProduceDateCol = 22;
|
public const Int16 HExpiryDateCol = 23;
|
public const Int16 HEXPUNITCol = 24;
|
public const Int16 HEXPPERIODCol = 25;
|
public const Int16 HGiveAwayFlagCol = 26;
|
public const Int16 HUnitIDCol = 27;
|
public const Int16 HUnitNumberCol = 28;
|
public const Int16 HUnitNameCol = 29;
|
public const Int16 HWhIDCol = 30;
|
public const Int16 HWhNumberCol = 31;
|
public const Int16 HWhNameCol = 32;
|
public const Int16 HSPIDCol = 33;
|
public const Int16 HSPNumberCol = 34;
|
public const Int16 HSPNameCol = 35;
|
public const Int16 HMTONoCol = 36;
|
public const Int16 HRemarkCol = 37;
|
public const Int16 HDeptIDCol = 38;
|
public const Int16 HDeptNumberCol = 39;
|
public const Int16 HDeptNameCol = 40;
|
public const Int16 HSourceIDCol = 41;
|
public const Int16 HSourceNumberCol = 42;
|
public const Int16 HSourceNameCol = 43;
|
public const Int16 HSupIDCol = 44;
|
public const Int16 HSupNumberCol = 45;
|
public const Int16 HSupNameCol = 46;
|
public const Int16 HGroupIDCol = 47;
|
public const Int16 HGroupNumberCol = 48;
|
public const Int16 HGroupNameCol = 49;
|
public const Int16 HCusIDCol = 50;
|
public const Int16 HCusNumberCol = 51;
|
public const Int16 HCusNameCol = 52;
|
public const Int16 HCusTypeCol = 53;
|
public const Int16 HSeOrderBillNoCol = 54;
|
public const Int16 HSeOrderSEQCol = 55;
|
public const Int16 HInnerBillNoCol = 56;
|
public const Int16 HEndDateCol = 57;
|
public const Int16 HSourceBillQtyCol = 58;
|
//
|
public string ModName = "85";
|
public string ModCaption = "条码生成";
|
public const string ModRightName = "Gy_BarCodeBill_Rework";
|
public const string ModRightNameSourceQty = ModRightName + "_SourceQty"; //超源单数量控制
|
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
public DBUtility.ClsXt_BaseBill BaseBill;
|
public DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
|
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 HOrgNumber = ClsPub.HOrgNumber;
|
public string HOrgName = ClsPub.HOrgName;
|
public string ERPMode = ""; //ERP模式(WISE、CLOUD)
|
public string CampanyName = ""; //客户定制化名称
|
public string SourceQtyCtl = ""; //超源单数量控制
|
public long PrintQty = 0; //允许条码打印次数
|
public string PrintQtyCtl = ""; //条码打印次数控制
|
public string UpdatePrintQtyCtl = ""; //条码打印次数更新
|
public string sReturn = "";
|
public string HExpiryDate = "";
|
|
#region 固定代码
|
|
//清空界面
|
public void Sub_ClearBill()
|
{
|
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();
|
grdList.DataSource = null;
|
}
|
|
//保存列宽
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
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(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 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_BarCodeBill_Rework_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_Rework_Load(object sender, EventArgs e)
|
{
|
//打印初始化
|
oSumGrid.NoCol = HSnoCol;
|
oSumGrid.ogrdMain = grdMain;
|
oSumGrid.oGridsum = grdSum;
|
this.Text = ModCaption;
|
this.lblCaption.Text = ModCaption;
|
//加载组织信息
|
Sub_AddOrdList();
|
//加载源单类型
|
Sub_AddHSourceBillTypeList();
|
|
//获取系统参数
|
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; //ERP模式(WISE、CLOUD)
|
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";
|
}
|
}
|
}
|
|
//加载组织信息
|
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_AddHSourceBillTypeList()
|
{
|
DataSet ds = oCn.RunProcReturn("exec h_p_Gy_BarCodeBill_SourceBillType " + HOrgID.ToString(), "h_p_Gy_BarCodeBill_SourceBillType");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
cmbSourceBillType.DataSource = null;
|
cmbSourceBillType.Items.Clear();
|
MessageBox.Show("获取源单类型失败");
|
return;
|
}
|
cmbSourceBillType.DataSource = null;
|
cmbSourceBillType.Items.Clear();
|
cmbSourceBillType.DataSource = ds.Tables[0];
|
cmbSourceBillType.DisplayMember = "HName";
|
cmbSourceBillType.ValueMember = "HItemID";
|
}
|
|
//窗体尺寸变化时
|
private void Gy_BarCodeBill_Rework_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_Rework_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 生成条码
|
|
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;
|
}
|
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
long HSno = DBUtility.ClsPub.isLong(grdMain.Rows[j].Cells[HSnoCol].Value); // 序号
|
string HBarCodeType = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBarCodeTypeCol].Value); // 条码类型
|
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[HSourceBillQtyCol].Value); // 源单数量
|
double HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); // 数量
|
double HMinQty = DBUtility.ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value); // 最小包装数
|
bool HISKFPERIOD = DBUtility.ClsPub.isBool(grdMain.Rows[j].Cells[HISKFPERIODCol].Value); // 是否启用保质期
|
DateTime HProduceDate = DBUtility.ClsPub.isDate(grdMain.Rows[j].Cells[HProduceDateCol].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"]);
|
}
|
//判断录入的生产日期、有效期至是否正确
|
if(HISKFPERIOD && HProduceDate<DBUtility.ClsPub.isDate("2000-01-01"))
|
{
|
sHRemark = sHRemark + " 第" + ClsPub.isLong(grdMain.Rows[j].Cells[HSnoCol].Value) + "行,物料:" + ClsPub.isStrNull(grdMain.Rows[j].Cells[HMaterNameCol].Value) + " 启用保质期管理,生产日期录入错误;";
|
}
|
else if (HISKFPERIOD && ClsPub.isStrNull(grdMain.Rows[j].Cells[HExpiryDateCol].Value)=="")
|
{
|
sHRemark = sHRemark + " 第" + ClsPub.isLong(grdMain.Rows[j].Cells[HSnoCol].Value) + "行,物料:" + ClsPub.isStrNull(grdMain.Rows[j].Cells[HMaterNameCol].Value) + " 启用保质期管理,有效期至不能为空;";
|
}
|
}
|
}
|
if (sHRemark != "")
|
{
|
MessageBox.Show(sHRemark);
|
return false;
|
}
|
return true;
|
}
|
|
#endregion
|
|
#region 生成条码
|
private void SaveBarCode()
|
{
|
try
|
{
|
string TM = ""; //条码
|
int LSHlen = 6; //流水号长度
|
double HSumQty = 0; //产品数量
|
double HMinQty = 0; //最小包装数
|
Int64 HBQty = 0; //箱数
|
Int64 LSH = 0; //流水号
|
string LSH2 = ""; //流水号转换成字符
|
string sDate = ""; //日期
|
string sYear = ""; //年
|
string sPeriod = ""; //月
|
string sDay = ""; //日
|
string sMaterID = ""; //物料ID转换成字符
|
string sSourceEntryID = ""; //源单子ID转换成字符
|
string sTMNumber = ""; //条码自定义前缀
|
int HSumBQty = 0; //同一批生成条码总箱数
|
int n = 0; //同一批生成条码中的第几条
|
DataSet Ds;
|
pb1.Value = 0;
|
|
Int64 HEntryID = 0; //子ID
|
string HBarCode = ""; //条形码
|
string HBarCodeType = ""; //条码类型
|
Int64 HMaterID = 0; //物料ID
|
Int64 HUnitID = 0; //计量单位ID
|
Int64 HAuxPropID = 0; //辅助属性ID
|
string HBatchNo = ""; //批次号
|
string HMTONo = ""; //MTO号
|
double HQty = 0; //数量
|
double HinitQty = 0; //初始化数量(生成条码时数量)
|
double HSourceBillQty = 0; //源单可生成条码数量
|
bool HGiveAwayFlag = false; //是否赠品
|
string HProduceDate; //生产日期(保质期用)
|
string HExpiryDate; //保质期至(保质期用)
|
bool HISKFPERIOD = false; //是否启用保质期
|
string HEXPUNIT = ""; //保质期单位
|
double HEXPPERIOD = 0; //保质期
|
Int64 HWhID = 0; //仓库ID
|
Int64 HSPID = 0; //仓位ID
|
Int64 HBarcodeQtys = 0; //总托数
|
Int64 HBarcodeNo = 0; //当前托号
|
string HEndQty = ""; //尾数
|
Int64 HSourceInterID = 0; //源单ID
|
Int64 HSourceEntryID = 0; //源单子ID
|
string HSourceBillNo = ""; //源单单号
|
string HSourceBillType = ""; //源单类型
|
Int64 HInitSourceEntryID = 0; //初始化源单子ID(生成条码时源单子ID)
|
string HRemark = ""; //备注
|
Int64 HPrintQty = 0; //打印次数
|
Int64 HSTOCKORGID = 0; //组织ID
|
Int64 HOWNERID = 0; //货主ID
|
Int64 HDeptID = 0; //部门ID
|
Int64 HSupID = 0; //往来单位ID
|
Int64 HGroupID = 0; //生产班组ID
|
Int64 HCusID = 0; //客户ID
|
string HCusType = ""; //客户型号
|
string HSeOrderBillNo = ""; //销售订单号
|
Int64 HSeOrderSEQ = 0; //销售订单行号
|
string HInnerBillNo = ""; //内部采购订单号
|
string HWorkLineName = ""; //生产线
|
string HMaterName = ""; //产品名称
|
string HMaterModel = ""; //产品规格型号
|
string HPinfan = ""; //品番
|
DateTime HEndDate; //计划完工日期
|
|
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);
|
pb1.Maximum = HSumBQty;
|
}
|
}
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0)
|
{
|
sMaterID = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HMaterIDCol].Value);
|
HBatchNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value);
|
HBarCodeType = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBarCodeTypeCol].Value);
|
//日期获取方式
|
sDate = dtpHDate.Value.ToShortDateString();
|
sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
|
sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
|
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
|
sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
|
sDay = sDay.Substring(sDay.Length - 2, 2);
|
//==================================
|
if (HBarCodeType == "唯一条码")
|
{
|
if (CampanyName == "中控")
|
{
|
HSourceBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillNoCol].Value);
|
sSourceEntryID = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HSubIDCol].Value);
|
if (HSourceBillNo == "")
|
{
|
//条码前缀 = 组织代码 + 物料代码 + 年 + 月 + 日
|
sTMNumber = HOrgNumber + sMaterID + sYear + sPeriod + sDay;
|
Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //获取最大流水号
|
LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
|
}
|
else
|
{
|
//条码 = 源单单号 + 物料ID + 行号
|
sTMNumber = HSourceBillNo + sMaterID + sSourceEntryID;
|
}
|
}
|
else //通用方法
|
{
|
//条码前缀 = 组织代码 + 物料代码 + 年 + 月 + 日
|
sTMNumber = HOrgNumber + sMaterID + sYear + sPeriod + sDay;
|
Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //获取最大流水号
|
LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
|
}
|
}
|
else if (HBarCodeType == "品种条码")
|
{
|
TM = HOrgNumber + sMaterID;
|
}
|
else if (HBarCodeType == "批次条码")
|
{
|
TM = HOrgNumber + sMaterID + HBatchNo;
|
}
|
else
|
{
|
MessageBox.Show("错误的条码类型,不能生成条码!");
|
bc.Enabled = true;
|
oCn.RollBack();
|
return;
|
}
|
|
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);
|
|
int nn = 0; //本次流水号累计使用个数
|
for (int i = 0; i < HBQty; i++)
|
{
|
if (HSumQty - HMinQty > 0)
|
{
|
HEndQty = "";
|
HSumQty = HSumQty - HMinQty;
|
}
|
else
|
{
|
if (HSumQty == HMinQty)
|
{
|
HEndQty = "";
|
}
|
else
|
{
|
HEndQty = "尾数";
|
}
|
HMinQty = HSumQty;
|
}
|
//
|
LSH = LSH + 1;
|
LSH2 = LSH.ToString();
|
while (LSH2.Length < LSHlen) //如果流水号位数小于 LSHlen 前面补0
|
{
|
LSH2 = "0" + LSH2;
|
}
|
if (HBarCodeType == "唯一条码")
|
{
|
if (CampanyName == "中控")
|
{
|
if (HSourceBillNo == "")
|
{
|
//条码编号 = 条码前缀 + 流水号
|
TM = sTMNumber + LSH2;
|
}
|
else
|
{
|
if (HBQty > 1)
|
{
|
MessageBox.Show("生产汇报单、收料通知单生成条码时,箱数不能大于1!");
|
bc.Enabled = true;
|
oCn.RollBack();
|
return;
|
}
|
//条码编号 = 条码前缀
|
TM = sTMNumber;
|
}
|
}
|
else
|
{
|
//条码编号 = 条码前缀 + 流水号
|
TM = sTMNumber + LSH2;
|
}
|
}
|
|
HEntryID = j + 1;
|
HBarCode = TM;
|
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);
|
HBatchNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value);
|
HMTONo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HMTONoCol].Value);
|
HQty = HMinQty;
|
HinitQty = HMinQty;
|
HSourceBillQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HSourceBillQtyCol].Value);
|
HGiveAwayFlag = ClsPub.isBool(grdMain.Rows[j].Cells[HGiveAwayFlagCol].Value);
|
HISKFPERIOD = ClsPub.isBool(grdMain.Rows[j].Cells[HISKFPERIODCol].Value);
|
if(HISKFPERIOD)
|
{
|
HProduceDate = ClsPub.isStrNull(ClsPub.isDate(grdMain.Rows[j].Cells[HProduceDateCol].Value));
|
HExpiryDate = ClsPub.isStrNull(grdMain.Rows[j].Cells[HExpiryDateCol].Value);
|
}
|
else
|
{
|
HProduceDate = "";
|
HExpiryDate = "";
|
}
|
HEXPUNIT = ClsPub.isStrNull(grdMain.Rows[j].Cells[HEXPUNITCol].Value);
|
HEXPPERIOD = ClsPub.isDoule(grdMain.Rows[j].Cells[HEXPPERIODCol].Value);
|
HWhID = ClsPub.isLong(grdMain.Rows[j].Cells[HWhIDCol].Value);
|
HSPID = ClsPub.isLong(grdMain.Rows[j].Cells[HSPIDCol].Value);
|
HBarcodeQtys = HBQty;
|
HBarcodeNo = i + 1;
|
HSourceInterID = ClsPub.isLong(grdMain.Rows[j].Cells[HMainIDCol].Value);
|
HSourceEntryID = ClsPub.isLong(grdMain.Rows[j].Cells[HSubIDCol].Value);
|
HSourceBillNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillNoCol].Value);
|
HSourceBillType = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillTypeCol].Value);
|
HInitSourceEntryID = ClsPub.isLong(grdMain.Rows[j].Cells[HSubIDCol].Value);
|
HRemark = ClsPub.isStrNull(grdMain.Rows[j].Cells[HRemarkCol].Value);
|
HPrintQty = 0;
|
HSTOCKORGID = HOrgID;
|
HOWNERID = HOrgID;
|
HDeptID = ClsPub.isLong(grdMain.Rows[j].Cells[HDeptIDCol].Value);
|
HSupID = ClsPub.isLong(grdMain.Rows[j].Cells[HSupIDCol].Value);
|
HGroupID = ClsPub.isLong(grdMain.Rows[j].Cells[HGroupIDCol].Value);
|
HCusID = ClsPub.isLong(grdMain.Rows[j].Cells[HCusIDCol].Value);
|
HCusType = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusTypeCol].Value);
|
HSeOrderBillNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value);
|
HSeOrderSEQ = ClsPub.isLong(grdMain.Rows[j].Cells[HSeOrderSEQCol].Value);
|
HInnerBillNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HInnerBillNoCol].Value);
|
HWorkLineName = ClsPub.isStrNull(grdMain.Rows[j].Cells[HSourceNameCol].Value);
|
HMaterName = ClsPub.isStrNull(grdMain.Rows[j].Cells[HMaterNameCol].Value);
|
HMaterModel = ClsPub.isStrNull(grdMain.Rows[j].Cells[HMaterModelCol].Value);
|
HPinfan = ClsPub.isStrNull(grdMain.Rows[j].Cells[HPinfanCol].Value);
|
HEndDate = ClsPub.isDate(grdMain.Rows[j].Cells[HEndDateCol].Value);
|
|
oCn.RunProc("insert into Gy_BarCodeBill" +
|
"(HInterID,HEntryID,HBarCode,HBarCodeType,HMaterID,HUnitID" +
|
",HAuxPropID,HBatchNo,HMTONo,HQty,HinitQty,HSourceBillQty" +
|
",HProduceDate,HExpiryDate" +
|
",HISKFPERIOD,HEXPUNIT,HEXPPERIOD,HBarCodeDate,HGiveAwayFlag" +
|
",HWhID,HSPID,HBarcodeQtys,HBarcodeNo,HEndQty" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HInitSourceEntryID,HRemark" +
|
",HPrintQty,HSTOCKORGID,HOWNERID,HDeptID,HSupID,HGroupID" +
|
",HCusID,HCusType,HSeOrderBillNo,HSeOrderSEQ,HInnerBillNo,HWorkLineName" +
|
",HMaterName,HMaterModel,HPinfan,HEndDate,HMaker,HMakeDate" +
|
") values ("
|
+ " " + HInterID.ToString() + "," + HEntryID.ToString() + ",'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString()
|
+ ", " + HAuxPropID.ToString() + ",'" + HBatchNo + "','" + HMTONo + "'," + HQty.ToString() + "," + HinitQty.ToString() + "," + HSourceBillQty.ToString()
|
+ ", " + (HProduceDate == "" ? "NULL" : "'" + HProduceDate + "'") + "," + (HExpiryDate == "" ? "NULL" : "'" + HExpiryDate + "'")
|
+ ", " + DBUtility.ClsPub.BoolToString(HISKFPERIOD) + ",'" + HEXPUNIT + "'," + HEXPPERIOD.ToString() + ",'" + sDate + "'," + DBUtility.ClsPub.BoolToString(HGiveAwayFlag)
|
+ ", " + HWhID.ToString() + "," + HSPID.ToString() + "," + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + ",'" + HEndQty + "'"
|
+ ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "'," + HInitSourceEntryID.ToString() + ",'" + HRemark + "'"
|
+ ", " + HPrintQty.ToString() + "," + HSTOCKORGID.ToString() + "," + HOWNERID.ToString() + "," + HDeptID.ToString() + "," + HSupID.ToString() + "," + HGroupID.ToString()
|
+ ", " + HCusID.ToString() + ",'" + HCusType + "','" + HSeOrderBillNo + "'," + HSeOrderSEQ.ToString() + ",'" + HInnerBillNo + "','" + HWorkLineName + "'"
|
+ ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "','" + HEndDate.ToShortDateString() + "','" + ClsPub.CurUserName + "',getdate()" +
|
")");
|
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_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 GraphLine()
|
{
|
int MainIDCol = Fun_GetCol("hmainid");
|
int SubIDCol = Fun_GetCol("hsubid");
|
string s = "是";
|
long n = 0;
|
DBUtility.Xt_BaseBillFun.GraphLine(grdList, MainIDCol, SubIDCol, s, ref n);
|
}
|
|
#endregion
|
|
#endregion
|
|
|
#region 窗体处理方法
|
//初始化GRID
|
private void initGrid()
|
{
|
grdMain.RowCount = 0;
|
grdMain.ColumnCount = 59; //总列数
|
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[HPinfanCol].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[HQtyCol].HeaderText = "数量";
|
grdMain.Columns[HMinQtyCol].HeaderText = "最小包装数";
|
grdMain.Columns[HBQtyCol].HeaderText = "箱数";
|
grdMain.Columns[HinitQtyCol].HeaderText = "初始化数量";
|
grdMain.Columns[HSourceBillQtyCol].HeaderText = "源单可生成条码数量";
|
grdMain.Columns[HBarCodeTypeCol].HeaderText = "条码类型";
|
grdMain.Columns[HISKFPERIODCol].HeaderText = "是否启用保质期";
|
grdMain.Columns[HProduceDateCol].HeaderText = "生产日期";
|
grdMain.Columns[HExpiryDateCol].HeaderText = "有效期至";
|
grdMain.Columns[HEXPUNITCol].HeaderText = "保质期单位";
|
grdMain.Columns[HEXPPERIODCol].HeaderText = "保质期";
|
grdMain.Columns[HGiveAwayFlagCol].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[HMTONoCol].HeaderText = "计划跟踪号";
|
grdMain.Columns[HRemarkCol].HeaderText = "备注";
|
grdMain.Columns[HDeptIDCol].HeaderText = "车间ID";
|
grdMain.Columns[HDeptNumberCol].HeaderText = "车间代码";
|
grdMain.Columns[HDeptNameCol].HeaderText = "车间";
|
grdMain.Columns[HSourceIDCol].HeaderText = "生产线ID";
|
grdMain.Columns[HSourceNumberCol].HeaderText = "生产线代码";
|
grdMain.Columns[HSourceNameCol].HeaderText = "生产线";
|
grdMain.Columns[HSupIDCol].HeaderText = "供应商ID";
|
grdMain.Columns[HSupNumberCol].HeaderText = "供应商代码";
|
grdMain.Columns[HSupNameCol].HeaderText = "供应商";
|
grdMain.Columns[HGroupIDCol].HeaderText = "生产班组ID";
|
grdMain.Columns[HGroupNumberCol].HeaderText = "生产班组代码";
|
grdMain.Columns[HGroupNameCol].HeaderText = "生产班组";
|
grdMain.Columns[HCusIDCol].HeaderText = "客户ID";
|
grdMain.Columns[HCusNumberCol].HeaderText = "客户代码";
|
grdMain.Columns[HCusNameCol].HeaderText = "客户";
|
grdMain.Columns[HCusTypeCol].HeaderText = "客户型号";
|
grdMain.Columns[HSeOrderBillNoCol].HeaderText = "销售订单号";
|
grdMain.Columns[HSeOrderSEQCol].HeaderText = "销售订单行号";
|
grdMain.Columns[HInnerBillNoCol].HeaderText = "内部采购订单号";
|
grdMain.Columns[HEndDateCol].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[HPinfanCol].Visible = false;
|
grdMain.Columns[HUnitIDCol].Visible = false;
|
grdMain.Columns[HAuxPropIDCol].Visible = false;
|
grdMain.Columns[HinitQtyCol].Visible = false;
|
grdMain.Columns[HSourceBillQtyCol].Visible = false;
|
//grdMain.Columns[HExpiryDateCol].Visible = false;
|
//grdMain.Columns[HEXPUNITCol].Visible = false;
|
//grdMain.Columns[HEXPPERIODCol].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[HMTONoCol].Visible = false;
|
grdMain.Columns[HDeptIDCol].Visible = false;
|
grdMain.Columns[HDeptNumberCol].Visible = false;
|
grdMain.Columns[HDeptNameCol].Visible = false;
|
grdMain.Columns[HSourceIDCol].Visible = false;
|
grdMain.Columns[HSourceNumberCol].Visible = false;
|
grdMain.Columns[HSourceNameCol].Visible = false;
|
grdMain.Columns[HSupIDCol].Visible = false;
|
grdMain.Columns[HSupNumberCol].Visible = false;
|
grdMain.Columns[HSupNameCol].Visible = false;
|
grdMain.Columns[HGroupIDCol].Visible = false;
|
grdMain.Columns[HGroupNumberCol].Visible = false;
|
grdMain.Columns[HGroupNameCol].Visible = false;
|
grdMain.Columns[HCusIDCol].Visible = false;
|
grdMain.Columns[HCusNumberCol].Visible = false;
|
grdMain.Columns[HCusNameCol].Visible = false;
|
grdMain.Columns[HCusTypeCol].Visible = false;
|
grdMain.Columns[HSeOrderBillNoCol].Visible = false;
|
grdMain.Columns[HSeOrderSEQCol].Visible = false;
|
grdMain.Columns[HInnerBillNoCol].Visible = false;
|
grdMain.Columns[HEndDateCol].Visible = false;
|
|
//设置可编辑列
|
string sAllowCol = HQtyCol.ToString() +
|
"," + HMinQtyCol.ToString() +
|
"," + HMaterNumberCol.ToString() +
|
"," + HUnitNumberCol.ToString() +
|
"," + HAuxPropNumberCol.ToString() +
|
"," + HBatchNoCol.ToString() +
|
"," + HBarCodeTypeCol.ToString() +
|
"," + HProduceDateCol.ToString() +
|
"," + HRemarkCol.ToString();
|
|
//设置合计列
|
string sTotalCol = HQtyCol.ToString();
|
|
//设置特殊列
|
for (int i = 0; i < grdMain.Rows.Count; i++)
|
{
|
//网格打勾
|
//是否启用批次
|
DataGridViewCheckBoxCell oCell1 = new DataGridViewCheckBoxCell();
|
oCell1.ThreeState = false;
|
oCell1.Value = 0;
|
oCell1.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdMain.Rows[i].Cells[HBatchManagerCol] = oCell1;
|
//是否启用保质期
|
DataGridViewCheckBoxCell oCell2 = new DataGridViewCheckBoxCell();
|
oCell2.ThreeState = false;
|
oCell2.Value = 0;
|
oCell2.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdMain.Rows[i].Cells[HISKFPERIODCol] = oCell2;
|
//是否赠品
|
DataGridViewCheckBoxCell oCell3 = new DataGridViewCheckBoxCell();
|
oCell3.ThreeState = false;
|
oCell3.Value = 0;
|
oCell3.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdMain.Rows[i].Cells[HGiveAwayFlagCol] = oCell3;
|
//网格下拉选择框
|
DataGridViewComboBoxCell column = new DataGridViewComboBoxCell();
|
if (CampanyName == "中控")
|
{
|
column.Items.Add("批次条码");
|
column.Items.Add("品种条码");
|
}
|
else
|
{
|
column.Items.Add("唯一条码");
|
column.Items.Add("批次条码");
|
column.Items.Add("品种条码");
|
}
|
grdMain.Rows[i].Cells[HBarCodeTypeCol] = column;
|
}
|
|
DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol,oSumGrid);
|
DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name);
|
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;
|
}
|
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[HUnitIDCol].Value = oMater.omodel.HUnitID.ToString();
|
grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = oMater.omodel.HUnitNumber;
|
grdMain.Rows[sRow].Cells[HUnitNameCol].Value = oMater.omodel.HUnitName;
|
grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value = oMater.omodel.HAuxPropID.ToString();
|
grdMain.Rows[sRow].Cells[HAuxPropNumberCol].Value = oMater.omodel.HAuxPropNumber;
|
grdMain.Rows[sRow].Cells[HAuxPropNameCol].Value = oMater.omodel.HAuxPropName;
|
grdMain.Rows[sRow].Cells[HBatchManagerCol].Value = oMater.omodel.HBatchManager;
|
grdMain.Rows[sRow].Cells[HISKFPERIODCol].Value = oMater.omodel.HISKFPERIOD;
|
grdMain.Rows[sRow].Cells[HBarCodeTypeCol].Value = oMater.omodel.HBarCodeType;
|
//启用批次
|
if (oMater.omodel.HBatchManager)
|
{
|
grdMain.Rows[sRow].Cells[HBatchNoCol].Value = oMater.omodel.HBatchNo;
|
}
|
//启用保质期
|
if (oMater.omodel.HISKFPERIOD)
|
{
|
grdMain.Rows[sRow].Cells[HEXPUNITCol].Value = oMater.omodel.HEXPUNIT;
|
grdMain.Rows[sRow].Cells[HEXPPERIODCol].Value = oMater.omodel.HEXPPERIOD;
|
grdMain.Rows[sRow].Cells[HProduceDateCol].Value = dtpHDate.Value.ToShortDateString();
|
//获取有效期至
|
if (GetExpiryDate(dtpHDate.Value, oMater.omodel.HEXPUNIT, DBUtility.ClsPub.isInt(oMater.omodel.HEXPPERIOD), ref sReturn, ref HExpiryDate))
|
{
|
grdMain.Rows[sRow].Cells[HExpiryDateCol].Value = HExpiryDate;
|
}
|
}
|
else
|
{
|
grdMain.Rows[sRow].Cells[HEXPUNITCol].Value = "";
|
grdMain.Rows[sRow].Cells[HEXPPERIODCol].Value = "";
|
grdMain.Rows[sRow].Cells[HProduceDateCol].Value = "";
|
grdMain.Rows[sRow].Cells[HExpiryDateCol].Value = "";
|
}
|
|
if (CampanyName == "中控")
|
{
|
grdMain.Rows[sRow].Cells[HQtyCol].Value = oMater.omodel.HQtyMin;
|
grdMain.Rows[sRow].Cells[HBQtyCol].Value = 1;
|
}
|
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 = "";
|
grdMain.Rows[sRow].Cells[HBatchManagerCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HBatchNoCol].Value = "";
|
grdMain.Rows[sRow].Cells[HBarCodeTypeCol].Value = "";
|
grdMain.Rows[sRow].Cells[HISKFPERIODCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HEXPUNITCol].Value = "";
|
grdMain.Rows[sRow].Cells[HEXPPERIODCol].Value = "";
|
grdMain.Rows[sRow].Cells[HProduceDateCol].Value = "";
|
grdMain.Rows[sRow].Cells[HExpiryDateCol].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 = "";
|
grdMain.Rows[sRow].Cells[HBatchManagerCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HBatchNoCol].Value = "";
|
grdMain.Rows[sRow].Cells[HBarCodeTypeCol].Value = "";
|
grdMain.Rows[sRow].Cells[HISKFPERIODCol].Value = 0;
|
grdMain.Rows[sRow].Cells[HEXPUNITCol].Value = "";
|
grdMain.Rows[sRow].Cells[HEXPPERIODCol].Value = "";
|
grdMain.Rows[sRow].Cells[HProduceDateCol].Value = "";
|
grdMain.Rows[sRow].Cells[HExpiryDateCol].Value = "";
|
}
|
break;
|
|
case HUnitNumberCol:
|
BLL.ClsBaseSelect_InterFace.SetGridByUnit(grdMain, sRow, HUnitIDCol, HUnitNumberCol, HUnitNameCol);
|
oEdit.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HUnitNumberCol].Value);
|
break;
|
|
case HAuxPropNumberCol:
|
oProperty.WherePart = "";
|
if (ERPMode == "CLOUD")
|
{
|
sWhere = " and HMaterNumber = '" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[HMaterNumberCol].Value) + "'";
|
}
|
else
|
{
|
sWhere = "";
|
}
|
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;
|
|
case HDeptNumberCol:
|
BLL.ClsBaseSelect_InterFace.SetGridByDept(grdMain, sRow, HDeptIDCol, HDeptNumberCol, HDeptNameCol);
|
oEdit.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HDeptNumberCol].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 HProduceDateCol:
|
BLL.ClsPub_BLL.Sub_SelectDate(grdMain, sRow, HProduceDateCol);
|
//获取有效期至
|
DateTime HProduceDate= DBUtility.ClsPub.isDate(grdMain.Rows[sRow].Cells[HProduceDateCol].Value); //生产日期
|
string HEXPUNIT = DBUtility.ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HEXPUNITCol].Value); //保质期单位
|
int HEXPPERIOD = DBUtility.ClsPub.isInt(grdMain.Rows[sRow].Cells[HEXPPERIODCol].Value); //保质期
|
if (GetExpiryDate(HProduceDate, HEXPUNIT, HEXPPERIOD, ref sReturn, ref HExpiryDate))
|
{
|
grdMain.Rows[sRow].Cells[HExpiryDateCol].Value = HExpiryDate;
|
}
|
oEdit.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HProduceDateCol].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 == HQtyCol)
|
{
|
RowCount(e.RowIndex, 0); //
|
}
|
else if (e.ColumnIndex == HProduceDateCol)
|
{
|
//获取有效期至
|
DateTime HProduceDate = DBUtility.ClsPub.isDate(grdMain.Rows[e.RowIndex].Cells[HProduceDateCol].Value); //生产日期
|
string HEXPUNIT = DBUtility.ClsPub.isStrNull(grdMain.Rows[e.RowIndex].Cells[HEXPUNITCol].Value); //保质期单位
|
int HEXPPERIOD = DBUtility.ClsPub.isInt(grdMain.Rows[e.RowIndex].Cells[HEXPPERIODCol].Value); //保质期
|
if (GetExpiryDate(HProduceDate, HEXPUNIT, HEXPPERIOD, ref sReturn, ref HExpiryDate))
|
{
|
grdMain.Rows[e.RowIndex].Cells[HExpiryDateCol].Value = HExpiryDate;
|
}
|
}
|
//
|
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 = "";
|
//系统参数,生成条码数量可否超源单数量控制(N为不可超源单数量)
|
if (SourceQtyCtl == "N")
|
{
|
sWhere = " and HOrgID =" + HOrgID.ToString() + " and 任务数量>0";
|
}
|
else
|
{
|
sWhere = " and HOrgID =" + HOrgID.ToString();
|
}
|
|
DAL.Cls_S_IFCLD_ICMOList oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList();
|
if (oIFCLD_ICMOList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIFCLD_ICMOList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "生产汇报单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_ICMOReportBillList oIF_ICMOReportBillList = new DAL.Cls_S_IF_ICMOReportBillList();
|
if (oIF_ICMOReportBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_ICMOReportBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "收料通知单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_POInStockBillList oIF_POInStockBillList = new DAL.Cls_S_IF_POInStockBillList();
|
if (oIF_POInStockBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_POInStockBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "采购订单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_POOrderBillList oIF_POOrderBillList = new DAL.Cls_S_IF_POOrderBillList();
|
if (oIF_POOrderBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_POOrderBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "委外订单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_EntrustOrderBillList oIF_EntrustOrderBillList = new DAL.Cls_S_IF_EntrustOrderBillList();
|
if (oIF_EntrustOrderBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_EntrustOrderBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "采购入库单")
|
{
|
string sWhere = "";
|
DAL.Cls_S_IF_POStockInBillList oIF_POStockInBillList = new DAL.Cls_S_IF_POStockInBillList();
|
if (oIF_POStockInBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_POStockInBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "退货通知单")
|
{
|
string sWhere = "";
|
DAL.Cls_S_IF_SeOutStockBackBillList oIF_SeOutStockBackBillList = new DAL.Cls_S_IF_SeOutStockBackBillList();
|
if (oIF_SeOutStockBackBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_SeOutStockBackBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "其他入库单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_OtherInBillList oIF_OtherInBillList = new DAL.Cls_S_IF_OtherInBillList();
|
if (oIF_OtherInBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_OtherInBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "直接调拨单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_MoveStockBillList oIF_MoveStockBillList = new DAL.Cls_S_IF_MoveStockBillList();
|
if (oIF_MoveStockBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_MoveStockBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "采购退料单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_POStockInBackBillList oIF_POStockInBackBillList = new DAL.Cls_S_IF_POStockInBackBillList();
|
if (oIF_POStockInBackBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_POStockInBackBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "生产退料单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_MateOutBackBillList oIF_MateOutBackBillList = new DAL.Cls_S_IF_MateOutBackBillList();
|
if (oIF_MateOutBackBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_MateOutBackBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "组装拆卸单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_PackageDismantleBillList oIF_PackageDismantleBillList = new DAL.Cls_S_IF_PackageDismantleBillList();
|
if (oIF_PackageDismantleBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_PackageDismantleBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "工序流转卡")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_ProcessExchangeBillList oIF_ProcessExchangeBillList = new DAL.Cls_S_IF_ProcessExchangeBillList();
|
if (oIF_ProcessExchangeBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_ProcessExchangeBillList.oBillSelectColl);
|
}
|
}
|
else if (cmbSourceBillType.Text.Trim() == "工序汇报单")
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
DAL.Cls_S_IF_ProcessReportBillList oIF_ProcessReportBillList = new DAL.Cls_S_IF_ProcessReportBillList();
|
if (oIF_ProcessReportBillList.Refresh(sWhere)) //选择原单
|
{
|
FillSelectData(oIF_ProcessReportBillList.oBillSelectColl);
|
}
|
}
|
else
|
{
|
|
}
|
}
|
|
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("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);
|
}
|
//生产汇报单
|
if (oSelectRow.BillType == "3711")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_ICMOReportList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_ICMOReportList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//收料通知单
|
if (oSelectRow.BillType == "1103")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_POInStockList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_POInStockList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//采购订单
|
if (oSelectRow.BillType == "1102")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_POOrderList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_POOrderList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//委外订单
|
if (oSelectRow.BillType == "1601")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_EntrustOrderList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_EntrustOrderList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//采购入库单
|
if (oSelectRow.BillType == "1201")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_POStockInBillList_Source where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_POStockInBillList_Source");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//退货通知单
|
if (oSelectRow.BillType == "1403")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_SeOutStockBackList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_SeOutStockBackList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//其他入库单
|
if (oSelectRow.BillType == "1203")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_OtherInList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_OtherInList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//直接调拨单
|
if (oSelectRow.BillType == "1207")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_MoveStockList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_MoveStockList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//采购退料单
|
if (oSelectRow.BillType == "1239")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_POStockInBackList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_POStockInBackList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//生产退料单
|
if (oSelectRow.BillType == "1244")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_MateOutBackList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_MateOutBackList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//组装拆卸单
|
if (oSelectRow.BillType == "1255")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_PackageDismantleList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_PackageDismantleList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//工序流转卡
|
if (oSelectRow.BillType == "3772")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_ProcessExchangeList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_ProcessExchangeList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//工序汇报单
|
if (oSelectRow.BillType == "3714")
|
{
|
grdMain.Rows.Add();
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_IF_ProcessReportList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_ProcessReportList");
|
//写入信息
|
Sub_WriteInForm1(Ds.Tables[0], i);
|
}
|
//即时库存
|
if (oSelectRow.BillType == "JSKC")
|
{
|
grdMain.Rows.Add();
|
Application.DoEvents();
|
//得到信息
|
Ds = oCn.RunProcReturn("select * from h_v_KF_ICInventoryList_IF where hmaterid=" + oSelectRow.BillMainID + " and hwhid=" + oSelectRow.BillSubID + " and hspid=" + oSelectRow.SPID + " and HAuxPropID=" + oSelectRow.HAuxPropID + " and 批次='" + oSelectRow.BatchNo + "' and 计划跟踪号='" + oSelectRow.BillNo + "' and 生产日期='" + oSelectRow.HProduceDate + "' and 有效期至='" + oSelectRow.HExpiryDate + "'", "h_v_KF_ICInventoryList_IF");
|
//写入信息
|
Sub_WriteInForm2(Ds.Tables[0], i);
|
}
|
}
|
//
|
oSumGrid.Changelock = false;
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
}
|
|
//根据TABLE写入界面(生产任务单)
|
private void Sub_WriteInForm(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[HSourceBillQtyCol].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[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]["HBatchManager"].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[HPinfanCol].Value = oTable.Rows[0]["HPinfan"].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[HMinQtyCol].Value = oTable.Rows[0]["最小包装数"].ToString();
|
grdMain.Rows[i].Cells[HBarCodeTypeCol].Value = oTable.Rows[0]["HBarCodeType"].ToString();
|
grdMain.Rows[i].Cells[HISKFPERIODCol].Value = oTable.Rows[0]["HISKFPERIOD"].ToString();
|
|
//启用保质期
|
if (DBUtility.ClsPub.isBool(oTable.Rows[0]["HISKFPERIOD"].ToString()))
|
{
|
grdMain.Rows[i].Cells[HEXPUNITCol].Value = oTable.Rows[0]["HEXPUNIT"].ToString();
|
grdMain.Rows[i].Cells[HEXPPERIODCol].Value = DBUtility.ClsPub.isInt(oTable.Rows[0]["HEXPPERIOD"]).ToString();
|
//源单上有生产日期、有效期至取源单上,没有生产日期取界面所选日期
|
if (oTable.Rows[0]["HProduceDate"].ToString()=="" || oTable.Rows[0]["HExpiryDate"].ToString()=="")
|
{
|
grdMain.Rows[i].Cells[HProduceDateCol].Value = dtpHDate.Value.ToShortDateString();
|
//获取有效期至
|
string HEXPUNIT = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HEXPUNITCol].Value); //保质期单位
|
int HEXPPERIOD = DBUtility.ClsPub.isInt(grdMain.Rows[i].Cells[HEXPPERIODCol].Value); //保质期
|
if (GetExpiryDate(dtpHDate.Value, HEXPUNIT, HEXPPERIOD, ref sReturn, ref HExpiryDate))
|
{
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = HExpiryDate;
|
}
|
}
|
else
|
{
|
grdMain.Rows[i].Cells[HProduceDateCol].Value = oTable.Rows[0]["HProduceDate"].ToString();
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = oTable.Rows[0]["HExpiryDate"].ToString();
|
}
|
}
|
else
|
{
|
grdMain.Rows[i].Cells[HEXPUNITCol].Value = "";
|
grdMain.Rows[i].Cells[HEXPPERIODCol].Value = "";
|
grdMain.Rows[i].Cells[HProduceDateCol].Value = "";
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = "";
|
}
|
|
//--
|
//设置可编辑列
|
string sAllowCol = HQtyCol.ToString() +
|
"," + HMinQtyCol.ToString() +
|
"," + HAuxPropNumberCol.ToString() +
|
"," + HBatchNoCol.ToString() +
|
"," + HBarCodeTypeCol.ToString() +
|
"," + HProduceDateCol.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);
|
}
|
|
//根据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[HSourceBillQtyCol].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[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]["HBatchManager"].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[HBarCodeTypeCol].Value = oTable.Rows[0]["HBarCodeType"].ToString();
|
grdMain.Rows[i].Cells[HISKFPERIODCol].Value = oTable.Rows[0]["HISKFPERIOD"].ToString();
|
|
//启用保质期
|
if (DBUtility.ClsPub.isBool(oTable.Rows[0]["HISKFPERIOD"].ToString()))
|
{
|
grdMain.Rows[i].Cells[HEXPUNITCol].Value = oTable.Rows[0]["HEXPUNIT"].ToString();
|
grdMain.Rows[i].Cells[HEXPPERIODCol].Value = DBUtility.ClsPub.isInt(oTable.Rows[0]["HEXPPERIOD"]).ToString();
|
//源单上有生产日期、有效期至取源单上,没有生产日期取界面所选日期
|
if (oTable.Rows[0]["生产日期"].ToString() == "" || oTable.Rows[0]["有效期至"].ToString() == "")
|
{
|
grdMain.Rows[i].Cells[HProduceDateCol].Value = dtpHDate.Value.ToShortDateString();
|
//获取有效期至
|
string HEXPUNIT = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HEXPUNITCol].Value); //保质期单位
|
int HEXPPERIOD = DBUtility.ClsPub.isInt(grdMain.Rows[i].Cells[HEXPPERIODCol].Value); //保质期
|
if (GetExpiryDate(dtpHDate.Value, HEXPUNIT, HEXPPERIOD, ref sReturn, ref HExpiryDate))
|
{
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = HExpiryDate;
|
}
|
}
|
else
|
{
|
grdMain.Rows[i].Cells[HProduceDateCol].Value = oTable.Rows[0]["生产日期"].ToString();
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = oTable.Rows[0]["有效期至"].ToString();
|
}
|
}
|
else
|
{
|
grdMain.Rows[i].Cells[HEXPUNITCol].Value = "";
|
grdMain.Rows[i].Cells[HEXPPERIODCol].Value = "";
|
grdMain.Rows[i].Cells[HProduceDateCol].Value = "";
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = "";
|
}
|
|
if (CampanyName == "中控")
|
{
|
grdMain.Rows[i].Cells[HMinQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["未生成条码数量"]);
|
}
|
else
|
{
|
grdMain.Rows[i].Cells[HMinQtyCol].Value = oTable.Rows[0]["最小包装数"].ToString();
|
}
|
if (cmbSourceBillType.Text.Trim() == "收料通知单" || cmbSourceBillType.Text.Trim() == "采购订单"
|
|| cmbSourceBillType.Text.Trim() == "委外订单" || cmbSourceBillType.Text.Trim() == "采购入库单")
|
{
|
grdMain.Rows[i].Cells[HInnerBillNoCol].Value = oTable.Rows[0]["内部采购订单号"].ToString();
|
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();
|
if (cmbSourceBillType.Text.Trim() == "收料通知单")
|
{
|
if (oTable.Rows[0]["是否赠品"].ToString() == "是")
|
{
|
grdMain.Rows[i].Cells[HGiveAwayFlagCol].Value = 1;
|
}
|
else
|
{
|
grdMain.Rows[i].Cells[HGiveAwayFlagCol].Value = 0;
|
}
|
grdMain.Rows[i].Cells[HSeOrderBillNoCol].Value = oTable.Rows[0]["销售订单号"].ToString();
|
grdMain.Rows[i].Cells[HSeOrderSEQCol].Value = oTable.Rows[0]["销售订单行号"].ToString();
|
}
|
|
}
|
if (cmbSourceBillType.Text.Trim() == "退货通知单")
|
{
|
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();
|
}
|
if (cmbSourceBillType.Text.Trim() == "其他入库单")
|
{
|
grdMain.Rows[i].Cells[HWhIDCol].Value = oTable.Rows[0]["HWhID"].ToString();
|
grdMain.Rows[i].Cells[HWhNumberCol].Value = oTable.Rows[0]["仓库代码"].ToString();
|
grdMain.Rows[i].Cells[HWhNameCol].Value = oTable.Rows[0]["仓库"].ToString();
|
grdMain.Rows[i].Cells[HSPIDCol].Value = oTable.Rows[0]["HSPID"].ToString();
|
grdMain.Rows[i].Cells[HSPNumberCol].Value = oTable.Rows[0]["仓位代码"].ToString();
|
grdMain.Rows[i].Cells[HSPNameCol].Value = oTable.Rows[0]["仓位"].ToString();
|
}
|
//--
|
//设置可编辑列
|
string sAllowCol = HQtyCol.ToString() +
|
"," + HMinQtyCol.ToString() +
|
"," + HAuxPropNumberCol.ToString() +
|
"," + HBatchNoCol.ToString() +
|
"," + HBarCodeTypeCol.ToString() +
|
"," + HProduceDateCol.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);
|
}
|
|
//根据TABLE写入界面(金蝶即时库存)
|
private void Sub_WriteInForm2(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[HSourceBillQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["数量"]);
|
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[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]["HBatchManager"].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[HSupIDCol].Value = oTable.Rows[0]["HSupplyID"].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[HWhIDCol].Value = oTable.Rows[0]["HWhID"].ToString();
|
grdMain.Rows[i].Cells[HWhNumberCol].Value = oTable.Rows[0]["仓库代码"].ToString();
|
grdMain.Rows[i].Cells[HWhNameCol].Value = oTable.Rows[0]["仓库"].ToString();
|
grdMain.Rows[i].Cells[HSPIDCol].Value = oTable.Rows[0]["HSPID"].ToString();
|
grdMain.Rows[i].Cells[HSPNumberCol].Value = oTable.Rows[0]["仓位代码"].ToString();
|
grdMain.Rows[i].Cells[HSPNameCol].Value = oTable.Rows[0]["仓位"].ToString();
|
grdMain.Rows[i].Cells[HRemarkCol].Value = "按库存生成";
|
grdMain.Rows[i].Cells[HMTONoCol].Value = oTable.Rows[0]["计划跟踪号"].ToString();
|
grdMain.Rows[i].Cells[HBarCodeTypeCol].Value = oTable.Rows[0]["HBarCodeType"].ToString();
|
grdMain.Rows[i].Cells[HISKFPERIODCol].Value = oTable.Rows[0]["HISKFPERIOD"].ToString();
|
|
//启用保质期
|
if (DBUtility.ClsPub.isBool(oTable.Rows[0]["HISKFPERIOD"].ToString()))
|
{
|
grdMain.Rows[i].Cells[HEXPUNITCol].Value = oTable.Rows[0]["HEXPUNIT"].ToString();
|
grdMain.Rows[i].Cells[HEXPPERIODCol].Value = DBUtility.ClsPub.isInt(oTable.Rows[0]["HEXPPERIOD"]).ToString();
|
grdMain.Rows[i].Cells[HProduceDateCol].Value = oTable.Rows[0]["生产日期"].ToString();
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = oTable.Rows[0]["有效期至"].ToString();
|
}
|
else
|
{
|
grdMain.Rows[i].Cells[HEXPUNITCol].Value = "";
|
grdMain.Rows[i].Cells[HEXPPERIODCol].Value = "";
|
grdMain.Rows[i].Cells[HProduceDateCol].Value = "";
|
grdMain.Rows[i].Cells[HExpiryDateCol].Value = "";
|
}
|
|
if (CampanyName == "中控")
|
{
|
grdMain.Rows[i].Cells[HMinQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["数量"]);
|
}
|
//--
|
//设置可编辑列
|
string sAllowCol = HQtyCol.ToString() +
|
"," + HBarCodeTypeCol.ToString() +
|
"," + HMinQtyCol.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_IFCLD_ICMOList oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList();
|
//系统参数,生成条码数量可否超源单数量控制(N为不可超源单数量)
|
if (SourceQtyCtl == "N")
|
{
|
if (oIFCLD_ICMOList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + HOrgID.ToString() + " and 任务数量>0")) //选择原单
|
{
|
FillSelectData(oIFCLD_ICMOList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
else
|
{
|
if (oIFCLD_ICMOList.RefreshBySourceBillNo(" Where 单据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + HOrgID.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 + "' and HOrgID =" + HOrgID.ToString())) //选择原单
|
{
|
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 + "' and HOrgID =" + HOrgID.ToString())) //选择原单
|
{
|
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 + "' and HOrgID =" + HOrgID.ToString())) //选择原单
|
{
|
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 + "' and HOrgID =" + HOrgID.ToString())) //选择原单
|
{
|
FillSelectData(oIF_EntrustOrderBillList.oBillSelectColl);
|
txtHSourceBillNo.Text = "";
|
}
|
else
|
{
|
MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("所选源单类型,不支持此功能!");
|
return;
|
}
|
}
|
}
|
|
#endregion
|
|
|
#region //打印设置
|
|
GridppReport Report;
|
string sBarCodeItemID = ""; //条码自增列
|
|
#region 预览
|
private void yl_Click(object sender, EventArgs e)
|
{
|
//判断是否已经生成条码
|
if (grdList.Rows.Count < 1)
|
{
|
MessageBox.Show("条码未生成,请先生成条码后再预览!");
|
return;
|
}
|
|
//打印前判断条码是否已打印过
|
if (ReportPrintBegin())
|
{
|
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 (grdList.Rows.Count < 1)
|
{
|
MessageBox.Show("条码未生成,请先生成条码后再打印!");
|
return;
|
}
|
|
//打印前判断条码是否已打印过
|
if (ReportPrintBegin())
|
{
|
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 bool ReportPrintBegin()
|
{
|
string sHRemark = "";
|
if (PrintQtyCtl == "Y")
|
{
|
if (oBar.Set_CheckPrintQty_SD(HInterID, PrintQty, ref sHRemark))
|
{
|
MessageBox.Show(sHRemark);
|
return true;
|
}
|
return false;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
private void Sub_SetReport(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);
|
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, grdList, ds, Fun_GetCol("选择"));
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表体:" + e.Message);
|
}
|
}
|
|
//打印结束后回填条码打印次数
|
private void ReportPrintEnd()
|
{
|
if (UpdatePrintQtyCtl == "Y")
|
{
|
oBar.Set_UpdatePrintQty_SD(HInterID);
|
}
|
}
|
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
|
}
|
|
#region 试打印
|
private void sdy_Click(object sender, EventArgs e)
|
{
|
//判断是否已经生成条码
|
if (grdList.Rows.Count < 1)
|
{
|
MessageBox.Show("条码未生成,请先生成条码后再浏览!");
|
return;
|
}
|
|
//打印前判断条码是否已打印过
|
if (ReportPrintBegin_SDY())
|
{
|
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_SetReportView(oFrm.sOpenTmp);
|
Report.PrintPreview(false);
|
Thread.Sleep(1000);
|
}
|
}
|
|
//打印前判断条码是否超过允许可打印次数
|
private bool ReportPrintBegin_SDY()
|
{
|
string sHRemark = "";
|
sBarCodeItemID = "";
|
for (int i = 0; i < grdList.SelectedRows.Count; i++)
|
{
|
sBarCodeItemID = sBarCodeItemID + "," + DBUtility.ClsPub.isLong(grdList.Rows[grdList.SelectedRows[i].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
|
}
|
sBarCodeItemID = sBarCodeItemID.Remove(0, 1);
|
|
if (PrintQtyCtl == "Y")
|
{
|
if (oBar.Set_CheckPrintQty(sBarCodeItemID, PrintQty, ref sHRemark))
|
{
|
MessageBox.Show(sHRemark);
|
return true;
|
}
|
return false;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
private void Sub_SetReportView(string sOpenTmp)
|
{
|
//判断行数
|
for (int i = 0; i < grdList.Rows.Count; i++)
|
{
|
grdList.Rows[i].Cells[0].Value = "";
|
}
|
for (int i = 0; i < grdList.SelectedRows.Count; i++)
|
{
|
grdList.Rows[grdList.SelectedRows[i].Index].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_SDY);
|
}
|
|
//打印结束后回填条码打印次数
|
private void ReportPrintEnd_SDY()
|
{
|
if (UpdatePrintQtyCtl == "Y")
|
{
|
oBar.Set_UpdatePrintQty(sBarCodeItemID);
|
}
|
}
|
|
#endregion
|
|
#endregion
|
|
|
#region 选择组织
|
private void cmbHOrgID_SelectionChangeCommitted(object sender, EventArgs e)
|
{
|
HOrgID = ClsPub.isLong(cmbHOrgID.SelectedValue);
|
//清空初始化列表
|
initGrid();
|
grdMain.Columns[HBillNoCol].ReadOnly = false;
|
}
|
|
#endregion
|
|
#region 选择日期
|
private void dtpHDate_ValueChanged(object sender, EventArgs e)
|
{
|
if (chkUpdateSubDate.Checked == true)
|
{
|
for (int j = 0; j < grdMain.Rows.Count; j++)
|
{
|
long HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value); // 物料内码
|
if (HMaterID != 0 && DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HRemarkCol].Value) != "按库存生成")
|
{
|
//获取生产日期、有效期至
|
DateTime HProduceDate = dtpHDate.Value; //生产日期
|
string HEXPUNIT = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HEXPUNITCol].Value); //保质期单位
|
int HEXPPERIOD = DBUtility.ClsPub.isInt(grdMain.Rows[j].Cells[HEXPPERIODCol].Value); //保质期
|
//生产日期
|
grdMain.Rows[j].Cells[HProduceDateCol].Value = dtpHDate.Value.ToShortDateString();
|
|
if (GetExpiryDate(HProduceDate, HEXPUNIT, HEXPPERIOD, ref sReturn, ref HExpiryDate))
|
{
|
//有效期至
|
grdMain.Rows[j].Cells[HExpiryDateCol].Value = HExpiryDate;
|
}
|
}
|
}
|
}
|
}
|
|
#endregion
|
|
#region 获取有效期至
|
public bool GetExpiryDate(DateTime HProduceDate, string HEXPUNIT, int HEXPPERIOD, ref string sReturn, ref string HExpiryDate)
|
{
|
if (HEXPUNIT != "Y" && HEXPUNIT != "M" && HEXPUNIT != "D")
|
{
|
sReturn = "物料启用保质期管理,物料基础资料中的保质期单位不允许为空!";
|
return false;
|
}
|
else if (HEXPPERIOD == 0)
|
{
|
sReturn = "物料启用保质期管理,物料基础资料中的保质期不允许为空!";
|
return false;
|
}
|
else if (HEXPUNIT == "Y")
|
{
|
HExpiryDate = HProduceDate.AddYears(HEXPPERIOD).ToShortDateString();
|
return true;
|
}
|
else if (HEXPUNIT == "M")
|
{
|
HExpiryDate = HProduceDate.AddMonths(HEXPPERIOD).ToShortDateString();
|
return true;
|
}
|
else
|
{
|
HExpiryDate = HProduceDate.AddDays(HEXPPERIOD).ToShortDateString();
|
return true;
|
}
|
}
|
|
#endregion
|
|
|
#region 拆行
|
private void spRow_Click(object sender, EventArgs e)
|
{
|
oDlg.ShowDialog();
|
if (oDlg.IsOk == 1)
|
{
|
grdMainData_CF(DBUtility.ClsPub.isInt(oDlg.txtHQ.Text));
|
}
|
}
|
private void grdMainData_CF(int HQty)
|
{
|
double hq = 0;
|
int Qty = HQty - 1;
|
int row = grdMain.CurrentCell.RowIndex;
|
grdMain.Rows.Insert(row + 1, Qty);
|
hq = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HQtyCol].Value) / HQty;
|
grdMain.Rows[row].Cells[HQtyCol].Value = hq;
|
for (int i = 0; i < Qty; i++)
|
{
|
int r = i + 1;
|
grdMain.Rows[row + r].Cells[HTagCol].Value = grdMain.Rows[row].Cells[HTagCol].Value;
|
grdMain.Rows[row + r].Cells[HMainIDCol].Value = grdMain.Rows[row].Cells[HMainIDCol].Value;
|
grdMain.Rows[row + r].Cells[HSubIDCol].Value = grdMain.Rows[row].Cells[HSubIDCol].Value;
|
grdMain.Rows[row + r].Cells[HBillNoCol].Value = grdMain.Rows[row].Cells[HBillNoCol].Value;
|
grdMain.Rows[row + r].Cells[HBillTypeCol].Value = grdMain.Rows[row].Cells[HBillTypeCol].Value;
|
grdMain.Rows[row + r].Cells[HMaterIDCol].Value = grdMain.Rows[row].Cells[HMaterIDCol].Value;
|
grdMain.Rows[row + r].Cells[HMaterNumberCol].Value = grdMain.Rows[row].Cells[HMaterNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HMaterNameCol].Value = grdMain.Rows[row].Cells[HMaterNameCol].Value;
|
grdMain.Rows[row + r].Cells[HPinfanCol].Value = grdMain.Rows[row].Cells[HPinfanCol].Value;
|
grdMain.Rows[row + r].Cells[HMaterModelCol].Value = grdMain.Rows[row].Cells[HMaterModelCol].Value;
|
grdMain.Rows[row + r].Cells[HAuxPropIDCol].Value = grdMain.Rows[row].Cells[HAuxPropIDCol].Value;
|
grdMain.Rows[row + r].Cells[HAuxPropNumberCol].Value = grdMain.Rows[row].Cells[HAuxPropNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HAuxPropNameCol].Value = grdMain.Rows[row].Cells[HAuxPropNameCol].Value;
|
grdMain.Rows[row + r].Cells[HBatchNoCol].Value = grdMain.Rows[row].Cells[HBatchNoCol].Value;
|
grdMain.Rows[row + r].Cells[HQtyCol].Value = DBUtility.ClsPub.isDoule(hq, 4);
|
grdMain.Rows[row + r].Cells[HMinQtyCol].Value = 0;
|
grdMain.Rows[row + r].Cells[HSourceBillQtyCol].Value = DBUtility.ClsPub.isDoule(hq, 4);
|
grdMain.Rows[row + r].Cells[HProduceDateCol].Value = grdMain.Rows[row].Cells[HProduceDateCol].Value;
|
grdMain.Rows[row + r].Cells[HExpiryDateCol].Value = grdMain.Rows[row].Cells[HExpiryDateCol].Value;
|
grdMain.Rows[row + r].Cells[HEXPUNITCol].Value = grdMain.Rows[row].Cells[HEXPUNITCol].Value;
|
grdMain.Rows[row + r].Cells[HEXPPERIODCol].Value = grdMain.Rows[row].Cells[HEXPPERIODCol].Value;
|
grdMain.Rows[row + r].Cells[HUnitIDCol].Value = grdMain.Rows[row].Cells[HUnitIDCol].Value;
|
grdMain.Rows[row + r].Cells[HUnitNumberCol].Value = grdMain.Rows[row].Cells[HUnitNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HUnitNameCol].Value = grdMain.Rows[row].Cells[HUnitNameCol].Value;
|
grdMain.Rows[row + r].Cells[HWhIDCol].Value = grdMain.Rows[row].Cells[HWhIDCol].Value;
|
grdMain.Rows[row + r].Cells[HWhNumberCol].Value = grdMain.Rows[row].Cells[HWhNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HWhNameCol].Value = grdMain.Rows[row].Cells[HWhNameCol].Value;
|
grdMain.Rows[row + r].Cells[HSPIDCol].Value = grdMain.Rows[row].Cells[HSPIDCol].Value;
|
grdMain.Rows[row + r].Cells[HSPNumberCol].Value = grdMain.Rows[row].Cells[HSPNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HSPNameCol].Value = grdMain.Rows[row].Cells[HSPNameCol].Value;
|
grdMain.Rows[row + r].Cells[HMTONoCol].Value = grdMain.Rows[row].Cells[HMTONoCol].Value;
|
grdMain.Rows[row + r].Cells[HRemarkCol].Value = grdMain.Rows[row].Cells[HRemarkCol].Value;
|
grdMain.Rows[row + r].Cells[HDeptIDCol].Value = grdMain.Rows[row].Cells[HDeptIDCol].Value;
|
grdMain.Rows[row + r].Cells[HDeptNumberCol].Value = grdMain.Rows[row].Cells[HDeptNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HDeptNameCol].Value = grdMain.Rows[row].Cells[HDeptNameCol].Value;
|
grdMain.Rows[row + r].Cells[HSourceIDCol].Value = grdMain.Rows[row].Cells[HSourceIDCol].Value;
|
grdMain.Rows[row + r].Cells[HSourceNumberCol].Value = grdMain.Rows[row].Cells[HSourceNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HSourceNameCol].Value = grdMain.Rows[row].Cells[HSourceNameCol].Value;
|
grdMain.Rows[row + r].Cells[HSupIDCol].Value = grdMain.Rows[row].Cells[HSupIDCol].Value;
|
grdMain.Rows[row + r].Cells[HSupNumberCol].Value = grdMain.Rows[row].Cells[HSupNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HSupNameCol].Value = grdMain.Rows[row].Cells[HSupNameCol].Value;
|
grdMain.Rows[row + r].Cells[HGroupIDCol].Value = grdMain.Rows[row].Cells[HGroupIDCol].Value;
|
grdMain.Rows[row + r].Cells[HGroupNumberCol].Value = grdMain.Rows[row].Cells[HGroupNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HGroupNameCol].Value = grdMain.Rows[row].Cells[HGroupNameCol].Value;
|
grdMain.Rows[row + r].Cells[HCusIDCol].Value = grdMain.Rows[row].Cells[HCusIDCol].Value;
|
grdMain.Rows[row + r].Cells[HCusNumberCol].Value = grdMain.Rows[row].Cells[HCusNumberCol].Value;
|
grdMain.Rows[row + r].Cells[HCusNameCol].Value = grdMain.Rows[row].Cells[HCusNameCol].Value;
|
grdMain.Rows[row + r].Cells[HCusTypeCol].Value = grdMain.Rows[row].Cells[HCusTypeCol].Value;
|
grdMain.Rows[row + r].Cells[HSeOrderBillNoCol].Value = grdMain.Rows[row].Cells[HSeOrderBillNoCol].Value;
|
grdMain.Rows[row + r].Cells[HSeOrderSEQCol].Value = grdMain.Rows[row].Cells[HSeOrderSEQCol].Value;
|
grdMain.Rows[row + r].Cells[HInnerBillNoCol].Value = grdMain.Rows[row].Cells[HInnerBillNoCol].Value;
|
grdMain.Rows[row + r].Cells[HEndDateCol].Value = grdMain.Rows[row].Cells[HEndDateCol].Value;
|
//网格打勾
|
//是否启用批次
|
DataGridViewCheckBoxCell oCell1 = new DataGridViewCheckBoxCell();
|
oCell1.ThreeState = false;
|
oCell1.Value = grdMain.Rows[row].Cells[HBatchManagerCol].Value;
|
oCell1.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdMain.Rows[row + r].Cells[HBatchManagerCol] = oCell1;
|
//是否启用保质期
|
DataGridViewCheckBoxCell oCell2 = new DataGridViewCheckBoxCell();
|
oCell2.ThreeState = false;
|
oCell2.Value = grdMain.Rows[row].Cells[HISKFPERIODCol].Value;
|
oCell2.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdMain.Rows[row + r].Cells[HISKFPERIODCol] = oCell2;
|
//是否赠品
|
DataGridViewCheckBoxCell oCell3 = new DataGridViewCheckBoxCell();
|
oCell3.ThreeState = false;
|
oCell3.Value = grdMain.Rows[row].Cells[HGiveAwayFlagCol].Value;
|
oCell3.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
grdMain.Rows[row + r].Cells[HGiveAwayFlagCol] = oCell3;
|
//网格下拉选择框
|
DataGridViewComboBoxCell column = new DataGridViewComboBoxCell();
|
if (CampanyName == "中控")
|
{
|
column.Items.Add("批次条码");
|
column.Items.Add("品种条码");
|
}
|
else
|
{
|
column.Items.Add("唯一条码");
|
column.Items.Add("批次条码");
|
column.Items.Add("品种条码");
|
}
|
grdMain.Rows[row + r].Cells[HBarCodeTypeCol] = column;
|
}
|
DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
|
}
|
|
#endregion
|
|
|
#region 按库存生成条码
|
|
private void kc_Click(object sender, EventArgs e)
|
{
|
string sWhere = " and HOrgID =" + HOrgID.ToString();
|
BLL.Cls_S_KF_ICInventoryList_IF oadd = new BLL.Cls_S_KF_ICInventoryList_IF();
|
if (oadd.Refresh(sWhere)) //选择原单
|
//if (oadd.Refresh(" and HErpClsID in (1,2,3) ")) //选择原单
|
{
|
FillSelectData(oadd.oBillSelectColl);
|
}
|
}
|
#endregion
|
|
|
#region 同步基础资料信息
|
private void tb_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
oCn.RunProc("exec h_p_IF_ERPDataToLocal", ref DBUtility.ClsPub.sExeReturnInfo);
|
MessageBox.Show("同步基础资料成功!");
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show("同步基础资料失败!" + ex);
|
}
|
}
|
#endregion
|
|
|
#region 关联按钮
|
private void gl_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
long HInterID = DBUtility.ClsPub.isLong(grdList.Rows[0].Cells[Fun_GetCol("HInterID")].Value);
|
string HBarCode = DBUtility.ClsPub.isStrNull(grdList.Rows[0].Cells[Fun_GetCol("条码编号")].Value);
|
string HBarCodeType = DBUtility.ClsPub.isStrNull(grdList.Rows[0].Cells[Fun_GetCol("条码类型")].Value);
|
string HSourceBillType = DBUtility.ClsPub.isStrNull(grdList.Rows[0].Cells[Fun_GetCol("HSourceBillType")].Value);
|
|
DataSet oDs = oCn.RunProcReturn("exec h_p_WMS_BarCodeToICStockBillSub_Insert " + HInterID.ToString() + ",'" + HBarCode + "','" + HBarCodeType + "','" + HSourceBillType + "'", "h_p_WMS_BarCodeToICStockBillSub_Insert");
|
//
|
if (oDs == null && oDs.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("关联自动生成条码出入库记录失败!");
|
}
|
else
|
{
|
MessageBox.Show(DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HRemark"]));
|
}
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show("关联自动生成条码出入库记录失败22!" + ex);
|
}
|
}
|
#endregion
|
|
|
#region 批次按钮
|
private void BatchNo_Click(object sender, EventArgs e)
|
{
|
lblCaption.Focus();
|
bool b = false;
|
for (int i = 0; i < grdMain.RowCount; i++)
|
{
|
long HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value); // 物料内码
|
string HBatchNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HBatchNoCol].Value); // 批号
|
|
if (HMaterID != 0)
|
{
|
DataSet oDs = oCn.RunProcReturn("exec h_p_Gy_BarCodeBill_GetBatchNo " + HMaterID.ToString() + ",'" + HBatchNo + "','" + dtpHDate.Value.ToShortDateString() + "','" + CampanyName + "'", "h_p_Gy_BarCodeBill_GetBatchNo");
|
//
|
if (oDs == null && oDs.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("生成批次失败!");
|
return;
|
}
|
else if (DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0][0]) == "1")
|
{
|
grdMain.Rows[i].Cells[HBatchNoCol].Value = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HBatchNo"]);
|
b = true;
|
}
|
}
|
}
|
//明细表是否为零行
|
if (b == false)
|
{
|
MessageBox.Show("没有需要生成批次的明细行!", "提示");
|
return;
|
}
|
}
|
|
#endregion
|
|
}
|
}
|