using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace MES
|
{
|
public partial class Sc_DynamicDataQuery : Form
|
{
|
private int HItemIDCol = 0;
|
private int HNumberCol = 0;
|
const string ModName = "资源";
|
const string BillName = "Gy_Source";
|
public long HItemID;//项目ID
|
public string sCondition; //过滤条件
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
TreeNode CurNode = new TreeNode();
|
public long HInterID = 0;
|
public long HEntryID = 0;
|
public string HBillNo = "";
|
public string HSourceNumber = "";
|
public string HSourceName = "";
|
public string HMaterNumber = "";
|
public string HMaterName = "";
|
public string HMaterModel = "";
|
public string HUnitName = "";
|
public double HPlanQty = 0;
|
public double HQty = 0;
|
|
|
public Sc_DynamicDataQuery()
|
{
|
InitializeComponent();
|
}
|
//以下代码基本不需要修改
|
#region 固定代码
|
//保存GRID列宽
|
private void Sc_DynamicDataQuery_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);
|
}
|
//窗体加载
|
private void Sc_DynamicDataQuery_Load(object sender, EventArgs e)
|
{
|
LoadTree();
|
initGrid();
|
}
|
private void LoadAllNodes(TreeNode sNode) //Lock
|
{
|
DBUtility.Gy_BaseFun.LoadAllNodes(sNode, BillName);
|
}
|
private void LoadTree()//Lock
|
{
|
DBUtility.Gy_BaseFun.LoadTree(tv, imageList1, txtHDeptID.Text, BillName,DBUtility.ClsPub.isLong(txtHDeptID.Tag));
|
}
|
|
//退出模块
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
//查询
|
private void cx_Click(object sender, EventArgs e)
|
{
|
string sCode="0";
|
if (CurNode.Name.Length >= 2)
|
{
|
sCode = CurNode.Name.Substring(1, CurNode.Name.Length - 1);
|
}
|
Display(sCode);
|
}
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Gy_BaseFun.Fun_GetCol(sCol, grdMain);
|
}
|
|
//树型 单击
|
private void tv_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
{
|
CurNode = e.Node;
|
if (CurNode != null)
|
{
|
if (CurNode.Nodes.Count == 0)
|
LoadAllNodes(CurNode);
|
//找到选中结点
|
FindRow(CurNode.Name);
|
}
|
}
|
//过滤资料
|
private void FindRow(string sCode)//Lock
|
{
|
if (sCode.Length >= 2)
|
{
|
sCode=sCode.Substring(1, sCode.Length - 1);
|
}
|
Display(sCode);
|
}
|
|
|
|
//保存列宽
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);
|
}
|
//默认列宽
|
private void mrlk_Click(object sender, EventArgs e)//Lock
|
{
|
DBUtility.ClsPub.DefaultGridView(grdMain);
|
//参数解释 开始列 ,结束列,是否以最大列宽为准,最小列宽
|
DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);
|
}
|
//时间控件
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
Display("0");
|
}
|
|
//初始化GRID
|
private void initGrid()
|
{
|
DBUtility.Gy_BaseFun.initGrid(grdMain);
|
grdMain.ColumnHeadersHeight =45; //标题行高
|
}
|
//显示列表
|
private void Display(string sSource) // 幻心
|
{
|
SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN();
|
DataSet DSet;
|
string sSql = "";
|
//过滤条件
|
sSql = "exec h_p_Sc_DynamicDataQueryList '%" + txtHICMOBillNo.Text + "%'," + DBUtility.ClsPub.isLong(sSource).ToString();
|
//执行SQL
|
DSet = SubCn.RunProcReturn(sSql, "xt_xtgnb", ref DBUtility.ClsPub.sExeReturnInfo);
|
//
|
if (DSet == null)
|
{
|
MessageBox.Show("显示失败!原因:" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
grdMain.DataSource = DSet.Tables[0].DefaultView;
|
//加载列宽
|
DBUtility.Gy_BaseFun.DisplayGrid(grdMain, this.Name);
|
//
|
HItemIDCol = Fun_GetCol("HItemID");
|
HNumberCol = Fun_GetCol(ModName + "代码");
|
sCondition = "";
|
}
|
|
|
|
private void cmdLoadTree_Click(object sender, EventArgs e)
|
{
|
LoadTree();
|
}
|
|
#endregion
|
|
#region 类的读写
|
|
|
|
#endregion
|
|
|
|
#region 界面控件处理
|
|
private void cmdHDeptID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsK3_Department_View oDept = new DAL.ClsK3_Department_View();
|
if (oDept.RefreshView())
|
{
|
this.txtHDeptID.Text = oDept.oModel.HName;
|
this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString();
|
this.txtHDeptNumber.Text = oDept.oModel.HNumber;
|
}
|
else
|
{
|
this.txtHDeptID.Text = "";
|
this.txtHDeptNumber.Text = "";
|
}
|
LoadTree();
|
}
|
|
#endregion
|
//开工按钮
|
private void kg_Click(object sender, EventArgs e)
|
{
|
Sub_Start();
|
}
|
|
//开工
|
private void Sub_Start()
|
{
|
DAL.ClsSc_ICMOBillStatus_Tmp oTmp = new DAL.ClsSc_ICMOBillStatus_Tmp();
|
long HInterID = 0;
|
long HEntryID = 0;
|
long HSourceID = 0;
|
string HBillNo = "";
|
if (grdMain.CurrentRow == null)
|
return;
|
HSourceID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hsourceid")].Value);
|
HInterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
|
HEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hsubid")].Value);
|
HBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("生产订单")].Value);
|
if (HInterID == 0)
|
return;
|
//判断是否已经完工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsEnded(),结束时间大于1950-01-01)
|
if (!oTmp.IsEnded(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
//判断是否已经开工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsStarted(),开工日期大于1950-01-01)
|
if (!oTmp.IsStarted(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
//未开工,则UPDATE生产状态表(在类中增加方法Fun_SetStart(),设置开始时间、当前生产标记、任务单状态1)
|
if (oTmp.Fun_SetStart(HInterID, HEntryID,HSourceID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
MessageBox.Show("生产订单号:" + HBillNo + ",开工!", "提示");
|
}
|
}
|
else
|
{
|
MessageBox.Show("生产订单号:" + HBillNo + ",正在工作中!", "提示");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("生产订单号:" + HBillNo + ",已经完工,无需开工!", "提示");
|
return;
|
}
|
//刷新界面
|
Display("0");
|
}
|
|
|
private void txtHDeptID_TextChanged(object sender, EventArgs e)
|
{
|
if (txtHDeptID.Text.Trim()=="")
|
{
|
txtHDeptID.Tag = "0";
|
}
|
}
|
|
|
//完工按钮
|
private void wg_Click(object sender, EventArgs e)
|
{
|
Sub_End();
|
}
|
//完工
|
private void Sub_End()
|
{
|
DAL.ClsSc_ICMOBillStatus_Tmp oTmp = new DAL.ClsSc_ICMOBillStatus_Tmp();
|
long HInterID = 0;
|
long HEntryID = 0;
|
string HBillNo = "";
|
if (grdMain.CurrentRow == null)
|
return;
|
HInterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
|
HEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hsubid")].Value);
|
HBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("生产订单")].Value);
|
if (HInterID == 0)
|
return;
|
//判断是否已经开工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsStarted(),开工日期大于1950-01-01)
|
if (oTmp.IsStarted(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
|
//判断是否已经完工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsEnded(),结束时间大于1950-01-01)
|
if (!oTmp.IsEnded(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
//未完工,则UPDATE生产状态表(在类中增加方法Fun_SetEnd(),设置结束时间、当前生产标记、任务单状态3)
|
if (oTmp.Fun_SetEnd(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
MessageBox.Show("生产订单号:" + HBillNo + ",完工!", "提示");
|
}
|
}
|
else
|
{
|
MessageBox.Show("生产订单号:" + HBillNo + ",已完工!", "提示");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("生产订单号:" + HBillNo + ",未开工!", "提示");
|
return;
|
}
|
//刷新界面
|
Display("0");
|
}
|
|
//挂起按钮
|
private void gq_Click(object sender, EventArgs e)
|
{
|
Sub_Pause();
|
}
|
|
//挂起
|
private void Sub_Pause()
|
{
|
|
}
|
//引出按钮
|
private void yc_Click(object sender, EventArgs e)
|
{
|
Sub_DataIn();
|
}
|
|
//引出
|
private void Sub_DataIn()
|
{
|
|
}
|
|
//产量汇报按钮
|
private void clhb_Click(object sender, EventArgs e)
|
{
|
Sub_WorkQtyReport();
|
}
|
|
|
//产量汇报
|
private void Sub_WorkQtyReport()
|
{
|
|
//弹出 产量汇报窗体,对应DAL,MODEL类ClsSc_ICMOBillWorkQtyStatus_Tmp已经建立.窗体需要重新制作。
|
MES.Sc_ICMOBillWorkQtyStatus_Tmp oSc_ICMOReportBill_WMS = new Sc_ICMOBillWorkQtyStatus_Tmp();
|
DAL.ClsSc_ICMOBillWorkQtyStatus_Tmp oWms = new DAL.ClsSc_ICMOBillWorkQtyStatus_Tmp();
|
DAL.ClsSc_ICMOBillStatus_Tmp oTmp = new DAL.ClsSc_ICMOBillStatus_Tmp();
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
|
DAL.ClsK3_Unit_View oUnit = new DAL.ClsK3_Unit_View();
|
long HInterID_Tmp = 0;
|
if (grdMain.CurrentRow == null)
|
return;
|
HInterID_Tmp = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("HInterID_Tmp")].Value);
|
HInterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
|
HEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hsubid")].Value);
|
HBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("生产订单")].Value);
|
//判断是否已经开工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsStarted(),开工日期大于1950-01-01)
|
if (oTmp.IsStarted(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
|
//判断是否已经完工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsEnded(),结束时间大于1950-01-01)
|
if (!oTmp.IsEnded(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oTmp.ShowBill(HInterID_Tmp, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
oSc_ICMOReportBill_WMS.txtHICMOBillNo.Text = oTmp.omodel.HICMOBillNo;
|
oSc_ICMOReportBill_WMS.txtHSplitNO.Text = oTmp.omodel.HSplitNO;
|
oSc_ICMOReportBill_WMS.txtHSourceNumber.Tag = oTmp.omodel.HSourceID;
|
if (oSource.GetInfoByID(oTmp.omodel.HSourceID))
|
{
|
oSc_ICMOReportBill_WMS.txtHSourceNumber.Text = oSource.omodel.HNumber;
|
oSc_ICMOReportBill_WMS.txtHSourceName.Text = oSource.omodel.HName;
|
}
|
if (oMater.GetInfoByID(oTmp.omodel.HMaterID))
|
{
|
oSc_ICMOReportBill_WMS.txtHMaterNumber.Text = oMater.omodel.HNumber;
|
oSc_ICMOReportBill_WMS.txtHMaterName.Text = oMater.omodel.HName;
|
oSc_ICMOReportBill_WMS.txtHMaterModel.Text = oMater.omodel.HModel;
|
}
|
if (oUnit.GetInfoByID(oTmp.omodel.HUnitID))
|
{
|
oSc_ICMOReportBill_WMS.txtHUnitName.Text = oUnit.omodel.HName;
|
}
|
oSc_ICMOReportBill_WMS.txtHPlanQty.Text = oTmp.omodel.HPlanQty.ToString();
|
oSc_ICMOReportBill_WMS.txtHDayQty.Text = oTmp.omodel.HDatePlanQty.ToString();
|
oSc_ICMOReportBill_WMS.txtHBarCode.Text = "";
|
oSc_ICMOReportBill_WMS.txtHPieceQty.Text = "";
|
oSc_ICMOReportBill_WMS.txtHQty.Text = oTmp.omodel.HDatePlanQty.ToString();
|
oSc_ICMOReportBill_WMS.HSourceInterID = HInterID_Tmp;
|
oSc_ICMOReportBill_WMS.ShowDialog();
|
}
|
//汇报完毕,需要判断,新增汇报数量后,是否完工,更改生产状态表状态。
|
if (oWms.IsEnded(HInterID_Tmp, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
//如果已经完工,调用方法Fun_SetEnd(),设置结束时间、当前生产标记、任务单状态3
|
oTmp.Fun_SetEnd(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
}
|
else
|
{
|
MessageBox.Show("生产订单号:" + HBillNo + ",已经完工!", "提示");
|
return;
|
}
|
}
|
else
|
{
|
MessageBox.Show("生产订单号:" + HBillNo + ",未开工!", "提示");
|
return;
|
}
|
//刷新界面
|
Display("0");
|
}
|
|
|
|
|
|
|
|
//质量汇报
|
private void Sub_QualityReport()
|
{
|
///弹出 质量汇报窗体,对应DAL,MODEL类ClsSc_ICMOBillQualityStatus_Tmp已经建立.窗体需要重新制作。
|
MES.Sc_ICMOBillQualityStatus_Tmp oSc_QualityReportBill_WMS = new Sc_ICMOBillQualityStatus_Tmp();
|
DAL.ClsSc_ICMOBillStatus_Tmp oTmp = new DAL.ClsSc_ICMOBillStatus_Tmp();
|
DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
|
DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
|
DAL.ClsK3_Unit_View oUnit = new DAL.ClsK3_Unit_View();
|
long HInterID_Tmp = 0;
|
if (grdMain.CurrentRow == null)
|
return;
|
HInterID_Tmp = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("HInterID_Tmp")].Value);
|
HBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("生产订单")].Value);
|
//
|
if (oTmp.ShowBill(HInterID_Tmp, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
oSc_QualityReportBill_WMS.txtHICMOBillNo.Text = oTmp.omodel.HICMOBillNo;
|
oSc_QualityReportBill_WMS.txtHSplitNO.Text = oTmp.omodel.HSplitNO;
|
oSc_QualityReportBill_WMS.txtHSourceNumber.Tag = oTmp.omodel.HSourceID;
|
if (oSource.GetInfoByID(oTmp.omodel.HSourceID))
|
{
|
oSc_QualityReportBill_WMS.txtHSourceNumber.Text = oSource.omodel.HNumber;
|
oSc_QualityReportBill_WMS.txtHSourceName.Text = oSource.omodel.HName;
|
}
|
if (oMater.GetInfoByID(oTmp.omodel.HMaterID))
|
{
|
oSc_QualityReportBill_WMS.txtHMaterNumber.Text = oMater.omodel.HNumber;
|
oSc_QualityReportBill_WMS.txtHMaterName.Text = oMater.omodel.HName;
|
oSc_QualityReportBill_WMS.txtHMaterModel.Text = oMater.omodel.HModel;
|
}
|
if (oUnit.GetInfoByID(oTmp.omodel.HUnitID))
|
{
|
oSc_QualityReportBill_WMS.txtHUnitName.Text = oUnit.omodel.HName;
|
}
|
oSc_QualityReportBill_WMS.txtHPlanQty.Text = oTmp.omodel.HPlanQty.ToString();
|
oSc_QualityReportBill_WMS.txtHDayQty.Text = oTmp.omodel.HDatePlanQty.ToString();
|
oSc_QualityReportBill_WMS.txtHBarCode.Text = "";
|
oSc_QualityReportBill_WMS.HSourceInterID = HInterID_Tmp;
|
oSc_QualityReportBill_WMS.ShowDialog();
|
}
|
//刷新界面
|
Display("0");
|
}
|
|
|
//质量汇报按钮
|
private void zlhb_Click(object sender, EventArgs e)
|
{
|
Sub_QualityReport();
|
}
|
|
|
|
|
|
|
}
|
}
|