using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Threading;
|
using System.Windows.Forms;
|
|
namespace SCM
|
{
|
public partial class Xs_SeOrderAutoSortBill : Form
|
{
|
public Xs_SeOrderAutoSortBill()
|
{
|
InitializeComponent();
|
}
|
|
|
SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1();
|
|
private void txtHProcID_TextChanged(object sender, EventArgs e)
|
{
|
|
}
|
|
private void label4_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void yd_Click(object sender, EventArgs e)
|
{
|
Display_UnSort();
|
}
|
|
private void Display_UnSort()
|
{
|
DataSet DSet;
|
string sSql = "";
|
string sWhere = "";
|
//过滤条件
|
sSql = "EXEC h_p_Xs_SeOrderAutoSortBill_UnSort '',0 ";
|
|
//
|
DSet = oWeb.getDataSetBySQL(sSql, "h_p_Xs_SeOrderAutoSortBill_UnSort", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
MessageBox.Show("没有返回任何结果,请在过滤框中点击【恢复】按钮,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdSourceBill.DataSource = DSet.Tables[0].DefaultView;
|
|
////设置合计列
|
//string sTotalCol = "";
|
//sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet);
|
//string[] sT;
|
//sT = sTotalCol.Split(Convert.ToChar(","));
|
//oSumGrid.BuildTotalCols(sT);
|
//冻结
|
int FrCol = 0;
|
string s = "是";
|
ClsPub1.DisplayGrid(grdSourceBill, this.Name, s, FrCol);
|
//画线
|
//GraphLine();
|
//Total();
|
}
|
|
private void Xs_SeOrderAutoSortBill_Load(object sender, EventArgs e)
|
{
|
//设置动态URL
|
oWeb.Url = SCM.ClsPub1.WEBSURL;
|
oWeb.Timeout = 30000;
|
}
|
|
private void pc_Click(object sender, EventArgs e)
|
{
|
//if (CheckSetupData() == false)
|
//{
|
// return;
|
//}
|
if (MessageBox.Show("是否启动裁切排产?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
|
{
|
//this.DateSetup(false);
|
return;
|
}
|
else
|
{
|
this.DateSetup(true);
|
}
|
}
|
|
//排程
|
private bool DateSetup(bool bAuto)
|
{
|
|
//得到一个内码
|
//HRelationInterID = DBUtility.ClsPub.CreateBillID(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
|
//HBillNo = "";
|
//弹出前置非模式窗体,显示进度
|
DBUtility.Xt_ProcessWait oWait = new DBUtility.Xt_ProcessWait();
|
oWait.lblCaption.Text = "正在排产请稍候...";
|
oWait.lblHCount.Text = "";
|
oWait.lblHMaterName.Text = "";
|
oWait.pb1.Maximum = grdSourceBill.RowCount;
|
oWait.pb1.Value = 0;
|
oWait.Show();
|
//grdMain.RowCount = 0;
|
////清空未锁定 排程记录
|
//Sub_DeleteBillUnLock();
|
//按任务单优先级 循环
|
for (int i = 0; i < grdSourceBill.RowCount; i++)
|
{
|
// //如果锁定计划,则不需要再排程
|
// if (DBUtility.ClsPub.isBool(grdSourceBill.Rows[i].Cells[HLockedCol].Value) == true)
|
// {
|
// continue;
|
// }
|
// //找到本任务单 可用生产资源
|
// lMainID = DBUtility.ClsPub.isLong(grdSourceBill.Rows[i].Cells[HICMOInterIDCol].Value);
|
// sICMOBillNo = DBUtility.ClsPub.isStrNull(grdSourceBill.Rows[i].Cells[HICMOBillNoCol].Value);
|
// dEndDate = DBUtility.ClsPub.isDate(grdSourceBill.Rows[i].Cells[HLastEndDateCol].Value);
|
// sProdTimes = DBUtility.ClsPub.isSingle(grdSourceBill.Rows[i].Cells[HProdTimesCol].Value);
|
// sPlanQty = DBUtility.ClsPub.isSingle(grdSourceBill.Rows[i].Cells[HPlanQtyCol].Value);
|
// lHGroupID = DBUtility.ClsPub.isLong(grdSourceBill.Rows[i].Cells[HGroupIDCol].Value);
|
// sGroupName = DBUtility.ClsPub.isStrNull(grdSourceBill.Rows[i].Cells[HGroupNameCol].Value);
|
// lMaterID = DBUtility.ClsPub.isLong(grdSourceBill.Rows[i].Cells[HMaterIDCol].Value);
|
// sMaterNumber = DBUtility.ClsPub.isStrNull(grdSourceBill.Rows[i].Cells[HMaterNumberCol].Value);
|
// sMaterName = DBUtility.ClsPub.isStrNull(grdSourceBill.Rows[i].Cells[HMaterNameCol].Value);
|
// sMaterModel = DBUtility.ClsPub.isStrNull(grdSourceBill.Rows[i].Cells[HMaterModelCol].Value);
|
// sWorkQty = DBUtility.ClsPub.isSingle(grdSourceBill.Rows[i].Cells[HWorkQtyCol].Value);
|
// sYX = DBUtility.ClsPub.isLong(grdSourceBill.Rows[i].Cells[HYXCol].Value);
|
// //
|
// if (sICMOBillNo == "WORK155356")
|
// {
|
// sICMOBillNo = sICMOBillNo;
|
// }
|
// //剩余需求工时
|
// iLeftQty = sPlanQty;
|
// if (sWorkQty <= 0)
|
// {
|
// sLeftProdTimes = 0;
|
// }
|
// else
|
// {
|
// sLeftProdTimes = iLeftQty / sWorkQty;
|
// }
|
// //若本任务单已有安排资源(上次排程或者手工排程) 则不再寻找资源,直接排程
|
// if (DBUtility.ClsPub.isLong(grdSourceBill.Rows[i].Cells[HSourceIDCol].Value) != 0 &&
|
// DBUtility.ClsPub.isStrNull(grdSourceBill.Rows[i].Cells[HSourceNameCol].Value) != ""
|
// )
|
// {
|
// //获取该生产资源的剩余工时进行排程。
|
// lSourceID = DBUtility.ClsPub.isLong(grdSourceBill.Rows[i].Cells[HSourceIDCol].Value);
|
// sSourceName = DBUtility.ClsPub.isStrNull(grdSourceBill.Rows[i].Cells[HSourceNameCol].Value);
|
// sSourceNumber = DBUtility.ClsPub.isStrNull(grdSourceBill.Rows[i].Cells[HSourceNumberCol].Value);
|
// //
|
// ds = Sc_ICMOSortBillFun.GetWorkSourceByICMO(oCn, lMaterID, dEndDate, lSourceID, sLeftProdTimes);
|
// }
|
// else //没有资源则 自动找到资源
|
// {
|
// //
|
// ds = Sc_ICMOSortBillFun.GetWorkSourceByICMO(oCn, lMaterID, dEndDate, sLeftProdTimes);
|
// }
|
// if (ds == null || ds.Tables[0].Rows.Count == 0) //没有可以排的资源
|
// {
|
// //跳到下一单 本单红色显示
|
// grdSourceBill.Rows[i].DefaultCellStyle.BackColor = Color.Brown;
|
// continue;
|
// }
|
// else
|
// {
|
// grdSourceBill.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
// //开始排单
|
// bFind = false;
|
// //超交货期 仍然排程
|
// for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
|
// {
|
// //判断资源剩余工时,是否大于 生产周期
|
// if (DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[j]["剩余工时"]) > sLeftProdTimes)
|
// {
|
// if (iLeftQty > 0)
|
// {
|
// //在本资源上生产
|
// //获取该生产资源的剩余工时进行排程。
|
// lSourceID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[j]["HitemID"]);
|
// sSourceName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[j]["资源名称"]);
|
// sSourceNumber = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[j]["资源代码"]);
|
// grdSourceBill.Rows[i].Cells[HSourceIDCol].Value = lSourceID;
|
// grdSourceBill.Rows[i].Cells[HSourceNameCol].Value = sSourceName;
|
// grdSourceBill.Rows[i].Cells[HSourceNumberCol].Value = sSourceNumber;
|
// dsSub = Sc_ICMOSortBillFun.GetWorkSourceTimeBySource(oCn, lSourceID);
|
// if (dsSub == null || dsSub.Tables[0].Rows.Count == 0)
|
// {
|
// continue;
|
// }
|
// if (dsSub != null)//不加班排程
|
// {
|
// //将数据排到网格中
|
// grdMain.RowCount = grdMain.RowCount + 1; // grdmain 新增一行
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOBillNoCol].Value = sICMOBillNo;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOInterIDCol].Value = lMainID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecLeftQtyCol].Value = iLeftQty;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupIDCol].Value = lHGroupID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupNameCol].Value = sGroupName;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterIDCol].Value = lMaterID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNameCol].Value = sMaterName;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNumberCol].Value = sMaterNumber;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterModelCol].Value = sMaterModel;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanEndDateCol].Value = dEndDate;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanQtyCol].Value = sPlanQty;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceIDCol].Value = lSourceID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNameCol].Value = sSourceName;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNumberCol].Value = sSourceNumber;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecYXCol].Value = sYX;
|
// Sc_ICMOSortBillFun.SetInfoToGrid(grdMain, dsSub, null, grdMain.RowCount - 1, ref iLeftQty, sWorkQty, false, oClsGridValues);
|
// }
|
// bFind = true;
|
// }
|
// }
|
// }
|
// if (!bFind)
|
// {
|
// for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
|
// {
|
// //判断资源最大剩余工时,是否大于 生产周期
|
// if (DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[j]["最大剩余工时"]) > sLeftProdTimes)
|
// {
|
// if (iLeftQty > 0)
|
// {
|
|
// //在本资源上生产
|
// grdMain.RowCount = grdMain.RowCount + 1;
|
// //获取该生产资源的剩余工时进行排程。
|
// lSourceID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[j]["HitemID"]);
|
// sSourceName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[j]["资源名称"]);
|
// sSourceNumber = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[j]["资源代码"]);
|
// grdSourceBill.Rows[i].Cells[HSourceIDCol].Value = lSourceID;
|
// grdSourceBill.Rows[i].Cells[HSourceNameCol].Value = sSourceName;
|
// grdSourceBill.Rows[i].Cells[HSourceNumberCol].Value = sSourceNumber;
|
// dsSub = Sc_ICMOSortBillFun.GetWorkSourceTimeBySource(oCn, lSourceID);
|
// if (dsSub == null || dsSub.Tables[0].Rows.Count == 0)
|
// {
|
// continue;
|
// }
|
// if (dsSub != null)//加班排程
|
// {
|
// //将数据排到网格中
|
// grdMain.RowCount = grdMain.RowCount + 1; // grdmain 新增一行
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOBillNoCol].Value = sICMOBillNo;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOInterIDCol].Value = lMainID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecLeftQtyCol].Value = iLeftQty;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupIDCol].Value = lHGroupID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupNameCol].Value = sGroupName;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterIDCol].Value = lMaterID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNameCol].Value = sMaterName;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNumberCol].Value = sMaterNumber;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterModelCol].Value = sMaterModel;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanEndDateCol].Value = dEndDate;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanQtyCol].Value = sPlanQty;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceIDCol].Value = lSourceID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNameCol].Value = sSourceName;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNumberCol].Value = sSourceNumber;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecYXCol].Value = sYX;
|
// Sc_ICMOSortBillFun.SetInfoToGrid(grdMain, dsSub, null, grdMain.RowCount - 1, ref iLeftQty, sWorkQty, true, oClsGridValues);
|
// }
|
// }
|
// bFind = true;
|
// }
|
// }
|
// }
|
// if (!bFind)
|
// {
|
// //如果没有找到合适资源则,直接排最后一个剩余最大的资源。
|
// //获取该生产资源的剩余工时进行排程。
|
// lSourceID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["HitemID"]);
|
// sSourceName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["资源名称"]);
|
// sSourceNumber = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["资源代码"]);
|
// grdSourceBill.Rows[i].Cells[HSourceIDCol].Value = lSourceID;
|
// grdSourceBill.Rows[i].Cells[HSourceNameCol].Value = sSourceName;
|
// grdSourceBill.Rows[i].Cells[HSourceNumberCol].Value = sSourceNumber;
|
|
// //获取该生产资源的剩余工时进行排程。
|
// dsSub = Sc_ICMOSortBillFun.GetWorkSourceTimeBySource(oCn, lSourceID);
|
// if (dsSub == null || dsSub.Tables[0].Rows.Count == 0)
|
// {
|
// continue;
|
// }
|
// if (dsSub != null)//加班排程
|
// {
|
// //将数据排到网格中
|
// grdMain.RowCount = grdMain.RowCount + 1; // grdmain 新增一行
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOBillNoCol].Value = sICMOBillNo;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecICMOInterIDCol].Value = lMainID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecLeftQtyCol].Value = iLeftQty;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupIDCol].Value = lHGroupID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecGroupNameCol].Value = sGroupName;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterIDCol].Value = lMaterID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNameCol].Value = sMaterName;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterNumberCol].Value = sMaterNumber;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecMaterModelCol].Value = sMaterModel;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanEndDateCol].Value = dEndDate;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecPlanQtyCol].Value = sPlanQty;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceIDCol].Value = lSourceID;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNameCol].Value = sSourceName;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecSourceNumberCol].Value = sSourceNumber;
|
// grdMain.Rows[grdMain.RowCount - 1].Cells[HSecYXCol].Value = sYX;
|
// Sc_ICMOSortBillFun.SetInfoToGrid(grdMain, dsSub, null, grdMain.RowCount - 1, ref iLeftQty, sWorkQty, true, oClsGridValues);
|
// }
|
// }
|
// }
|
// //
|
// //保存生成派工单
|
// SaveSingeBill(i, grdMain.RowCount - 1, HRelationInterID, oClsGridValues);
|
//////更新生产订单
|
|
////写入 进度等待框
|
Thread.Sleep(100);
|
Application.DoEvents();
|
oWait.pb1.Value = i + 1;
|
oWait.lblHCount.Text = oWait.pb1.Value.ToString() + "/" + oWait.pb1.Maximum.ToString();
|
oWait.lblHMaterName.Text = "";
|
Application.DoEvents();
|
}
|
oWeb.getRunProc(" EXEC h_p_Xs_SeOrderAutoSortBill_ToSort 1 " , ref DBUtility.ClsPub.sExeReturnInfo);
|
////
|
oWait.Close();
|
Display_Sort();
|
Display_UnSort();
|
return true;
|
}
|
|
private void Display_Sort()
|
{
|
DataSet DSet;
|
string sSql = "";
|
string sWhere = "";
|
//过滤条件
|
sSql = "EXEC h_p_Xs_SeOrderAutoSortBill_Sort '',0 ";
|
|
//
|
DSet = oWeb.getDataSetBySQL(sSql, "h_p_Xs_SeOrderAutoSortBill_Sort", ref DBUtility.ClsPub.sExeReturnInfo);
|
//生成首行标题
|
if (DSet == null)
|
{
|
MessageBox.Show("没有返回任何结果,请在过滤框中点击【恢复】按钮,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdMain.DataSource = DSet.Tables[0].DefaultView;
|
|
////设置合计列
|
//string sTotalCol = "";
|
//sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet);
|
//string[] sT;
|
//sT = sTotalCol.Split(Convert.ToChar(","));
|
//oSumGrid.BuildTotalCols(sT);
|
//冻结
|
int FrCol = 0;
|
string s = "是";
|
ClsPub1.DisplayGrid(grdMain, this.Name, s, FrCol);
|
//画线
|
//GraphLine();
|
//Total();
|
}
|
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
initGrid();
|
}
|
|
//
|
private void initGrid()
|
{
|
ClsPub1.initGridList(grdMain, this.Name);
|
ClsPub1.initGridList(grdSourceBill, this.Name + "grdSourceBill");
|
ClsPub1.initGridList(grdSourceStatus, this.Name + "grdSourceStatus");
|
grdMain.ReadOnly = true;
|
grdSourceBill.ReadOnly = true;
|
grdSourceStatus.ReadOnly = true;
|
}
|
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void xs_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void sx_Click(object sender, EventArgs e)
|
{
|
Display_Sort();
|
Display_UnSort();
|
}
|
|
}
|
}
|