You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
733 lines
36 KiB
733 lines
36 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using DevExpress.XtraEditors.Repository;
|
|
using System.Drawing;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSITEMROUTE2OPLotEdit : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
private DataTable data;
|
|
private string LotNo = "";
|
|
private int max = 0;
|
|
#region 构造函数
|
|
public FormICSITEMROUTE2OPLotEdit()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
}
|
|
#endregion
|
|
|
|
#region 操作权限
|
|
public DataTable RightOfExute()
|
|
{
|
|
DataTable rData = new DataTable();
|
|
rData.Columns.Add("BtnName");
|
|
rData.Columns.Add("ActionName");
|
|
//查看权限(必须有)
|
|
DataRow seeRow = rData.NewRow();
|
|
seeRow["BtnName"] = "see";
|
|
seeRow["ActionName"] = "查看";
|
|
rData.Rows.Add(seeRow);
|
|
foreach (Control ctr in this.Controls)
|
|
{
|
|
|
|
if (ctr.GetType() == typeof(SimpleButton))
|
|
{
|
|
if (ctr.Name == btnExit.Name || ctr.Name == btnSelect.Name || ctr.Name == btnCanSelect.Name)
|
|
continue;
|
|
DataRow dr = rData.NewRow();
|
|
dr["BtnName"] = ctr.Name;
|
|
dr["ActionName"] = ctr.Text;
|
|
rData.Rows.Add(dr);
|
|
}
|
|
}
|
|
|
|
rData.AcceptChanges();
|
|
return rData;
|
|
}
|
|
public DataTable RightOfData()// 数据权限
|
|
{
|
|
DataTable rData = new DataTable();
|
|
rData.Columns.Add("BodyName");
|
|
rData.Columns.Add("ControlName");
|
|
rData.Columns.Add("ControlCaption");
|
|
|
|
rData.AcceptChanges();
|
|
return rData;
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭 退出
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 移动窗体
|
|
private const int WM_NCHITTEST = 0x84;
|
|
private const int HTCLIENT = 0x1;
|
|
private const int HTCAPTION = 0x2;
|
|
//首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
|
|
//系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
|
|
//假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
|
|
//同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
|
|
|
|
//重写窗体,使窗体可以不通过自带标题栏实现移动
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
//当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
|
|
//当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
|
|
//这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
|
|
//注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
|
|
switch (m.Msg)
|
|
{
|
|
case WM_NCHITTEST:
|
|
base.WndProc(ref m);
|
|
if ((int)m.Result == HTCLIENT)
|
|
m.Result = (IntPtr)HTCAPTION;
|
|
return;
|
|
}
|
|
//拦截双击标题栏、移动窗体的系统消息
|
|
if (m.Msg != 0xA3)
|
|
{
|
|
base.WndProc(ref m);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 页面加载
|
|
private void FormICSINVENTORYEditAdd_Load(object sender, EventArgs e)
|
|
{
|
|
init();
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化查询条件
|
|
private void init()
|
|
{
|
|
//string sql = @" SELECT MOCODE+'-'+MOSEQ AS 工单,MOCODE AS 生产订单号,MOSEQ AS 生产订单行号,ITEMCODE AS 存货编码,b.INVNAME AS 存货名称,MOPLANQTY AS 工单数量,b.INVSTD AS 规格型号,
|
|
// MOVER AS 零件号,MOTYPE AS 工单类型
|
|
// FROM ICSMO a
|
|
// INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE
|
|
// WHERE MOCODE+MOSEQ IN (SELECT TransNO+TransLine FROM ICSITEMLot WHERE TYPE='工单')
|
|
// AND NOT exists (SELECT TransNO+TransLine--,COUNT(a.LotNO),COUNT(b.LotNO)
|
|
// FROM ICSITEMLot e
|
|
// LEFT JOIN ICSLOTSIMULATION b ON e.LotNO=b.LOTNO AND b.ISCOM='1'
|
|
// GROUP BY TransNO+TransLine
|
|
// HAVING COUNT(e.LotNO)=COUNT(b.LotNO) and TransNO+TransLine=a.MOCODE+a.MOSEQ)
|
|
// ORDER BY MOCODE,MOSEQ";
|
|
string sql = @" select distinct 生产订单号 FROM ( SELECT MOCODE AS 生产订单号,MOSEQ AS 生产订单行号,ITEMCODE AS 存货编码,b.INVNAME AS 存货名称,MOPLANQTY AS 工单数量,b.INVSTD AS 规格型号,
|
|
MOVER AS 零件号,MOTYPE AS 工单类型
|
|
FROM ICSMO a
|
|
INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE
|
|
WHERE MOCODE+MOSEQ IN (SELECT TransNO+TransLine FROM ICSITEMLot WHERE TYPE='工单')
|
|
AND NOT exists (SELECT TransNO+TransLine--,COUNT(a.LotNO),COUNT(b.LotNO)
|
|
FROM ICSITEMLot e
|
|
LEFT JOIN ICSLOTSIMULATION b ON e.LotNO=b.LOTNO AND b.ISCOM='1'
|
|
GROUP BY TransNO+TransLine
|
|
HAVING COUNT(e.LotNO)=COUNT(b.LotNO) and TransNO+TransLine=a.MOCODE+a.MOSEQ))A
|
|
ORDER BY 生产订单号";
|
|
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
txtMOCode.Properties.ValueMember = "生产订单号";
|
|
txtMOCode.Properties.DisplayMember = "生产订单号";
|
|
txtMOCode.Properties.DataSource = dt;
|
|
txtMOCode.Properties.NullText = "";//空时的值
|
|
txtMOCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
txtMOCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
txtMOCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
txtMOCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
txtMOCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
|
|
|
|
#region 工序
|
|
sql = "select OPCODE as [工序代码],OPDESC as [工序] from ICSOP";
|
|
dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
repositoryItemGridLookUpEdit1.ValueMember = "工序代码";
|
|
repositoryItemGridLookUpEdit1.DisplayMember = "工序代码";
|
|
repositoryItemGridLookUpEdit1.DataSource = dt;
|
|
repositoryItemGridLookUpEdit1.NullText = "";//空时的值
|
|
repositoryItemGridLookUpEdit1.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
repositoryItemGridLookUpEdit1.ValidateOnEnterKey = true;//回车确认
|
|
repositoryItemGridLookUpEdit1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
repositoryItemGridLookUpEdit1.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
repositoryItemGridLookUpEdit1.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
|
|
}
|
|
#endregion
|
|
|
|
private void grvDetail_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (grvDetail.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
//for (int i = 0; i < grdDetail.RowCount; i++)
|
|
//{
|
|
// grdDetail.SetRowCellValue(i, colisSelect, "");
|
|
//}
|
|
bool hasSelect = false;
|
|
if (grvDetail.FocusedColumn == colisSelect)
|
|
{
|
|
if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "" && !Convert.ToBoolean(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colCollect)))
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
|
|
|
|
//LotNo = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colLotNO).ToString();
|
|
//load();
|
|
}
|
|
else
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
|
|
}
|
|
}
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
LotNo = grvDetail.GetRowCellValue(i, colLotNO).ToString();
|
|
hasSelect = true;
|
|
}
|
|
}
|
|
if (hasSelect)
|
|
{
|
|
if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "Y" )
|
|
LotNo = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colLotNO).ToString();
|
|
gridControl1.DataSource = null;
|
|
load();
|
|
}
|
|
else
|
|
{
|
|
max = 0;
|
|
LotNo = "";
|
|
gridControl1.DataSource = null;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
private void load()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(LotNo))
|
|
return;
|
|
|
|
string sql = @"SELECT '' as isSelect,c.ID,a.LotNO,a.MCODE,b.INVNAME,b.INVSTD,CAST(a.LOTQTY AS DECIMAL(18,2)) AS LOTQTY,b.INVUOM,CAST(a.LOTQTY*a.EATTRIBUTE3 AS DECIMAL(18,2))AS num,b.INVEXPORTIMPORT,
|
|
c.ROUTECODE,c.OPSEQ,c.OPCODE,CAST(CASE WHEN d.LotNO IS NULL THEN '0' ELSE '1' END AS BIT) AS ONWIP,e.OPDESC AS OPNAME,CAST('1' AS BIT) AS OLD,CAST(ISNULL(f.EATTRIBUTE1, 0) AS BIT) AS EATTRIBUTE1,CAST(case
|
|
when f.id is null
|
|
then '0'
|
|
else '1' end as BIT) AS mo2user
|
|
FROM ICSITEMLot a
|
|
INNER JOIN ICSINVENTORY b ON a.MCODE=b.INVCODE
|
|
INNER JOIN ICSITEMROUTE2OPLot c ON a.LotNO=c.LotNO
|
|
LEFT JOIN ICSOP e ON c.OPCODE=e.OPCODE
|
|
LEFT JOIN ICSMO2User f ON c.LotNO=f.LotNO AND c.OPCODE=f.OPCODE
|
|
LEFT JOIN (SELECT LotNO,OPCODE FROM ICSLOTONWIP GROUP BY LotNO,OPCODE) d ON c.LotNO=d.LotNO AND c.OPCODE=d.OPCODE
|
|
WHERE a.LotNO='{0}'
|
|
ORDER BY a.LotNO,c.OPSEQ,c.OPCODE";
|
|
sql = string.Format(sql, LotNo);
|
|
data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
//if (gridView1.RowCount == 0)
|
|
//{
|
|
// gridControl1.DataSource = data;
|
|
// gridView1.BestFitColumns();
|
|
//}
|
|
if (gridView1.RowCount > 0)
|
|
{
|
|
if (data != null && data.Rows.Count != gridView1.RowCount)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("条码:" + LotNo + " 中工序行数与已选择行数不同!");
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
DataRow[] drs = data.Select("ONWIP='True'", "OPSEQ desc");
|
|
|
|
if ((drs.Length > 0 && max != Convert.ToInt32(drs[0]["OPSEQ"])) || (drs.Length == 0 && max > 0))
|
|
{
|
|
//if (max < Convert.ToInt32(drs[0]["OPSEQ"]))
|
|
//{
|
|
// //gridControl1.DataSource = data;
|
|
// //gridView1.BestFitColumns();
|
|
// max = Convert.ToInt32(drs[0]["OPSEQ"]);
|
|
//}
|
|
ICSBaseSimpleCode.AppshowMessageBox("条码:" + LotNo + " 中报工状态与已选择报工状态不同!");
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DataRow[] drs = data.Select("ONWIP='True'", "OPSEQ desc");
|
|
|
|
if (drs.Length > 0)
|
|
{
|
|
max = Convert.ToInt32(drs[0]["OPSEQ"]);
|
|
}
|
|
else
|
|
{
|
|
max = 0;
|
|
}
|
|
}
|
|
gridControl1.DataSource = data;
|
|
gridView1.BestFitColumns();
|
|
}
|
|
private void txtMOCode_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
gridControl1.DataSource = null;
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit.EditValue != null && edit.EditValue.ToString() != "" && edit.EditValue.ToString() != "nulltext")
|
|
{
|
|
var o = edit.Properties.GetRowByKeyValue(edit.EditValue);
|
|
if (o is DataRowView)
|
|
{
|
|
//DataRowView RowView = o as DataRowView;
|
|
//txtMORow.Text = RowView.Row["生产订单行号"].ToString();
|
|
//txtCode.Text = RowView.Row["存货编码"].ToString();
|
|
//txtcInvName.Text = RowView.Row["存货名称"].ToString();
|
|
//txtMoverCode.Text = RowView.Row["零件号"].ToString();
|
|
//txtcInvStd.Text = RowView.Row["规格型号"].ToString();
|
|
//txtMOType.Text = RowView.Row["工单类型"].ToString();
|
|
//txtiQuantity.Text = RowView.Row["工单数量"].ToString();
|
|
|
|
//string sql = @"SELECT '' as isSelect,a.LotNO,a.MCODE,b.INVNAME,b.INVSTD,CAST(a.LOTQTY AS DECIMAL(18,2)) AS LOTQTY,b.INVUOM,CAST(a.LOTQTY*a.EATTRIBUTE3 AS DECIMAL(18,2)) AS num,b.INVEXPORTIMPORT,ISNULL(c.LotNoSum, 0) AS OPlotSum,ISNULL(d.LotNoSum, 0) AS WipSum,CAST(ISNULL(e.ISCOM, 0) AS BIT) AS Collect,a.VenderLotNO
|
|
// FROM ICSITEMLot a
|
|
// INNER JOIN ICSINVENTORY b ON a.MCODE=b.INVCODE
|
|
// LEFT JOIN (SELECT LotNo,COUNT(LotNo) AS LotNoSum FROM ICSITEMROUTE2OPLot GROUP BY LotNo) c ON a.LotNO=c.LotNo
|
|
// LEFT JOIN (SELECT LotNo,COUNT(DISTINCT OPCODE) AS LotNoSum FROM ICSLOTONWIP GROUP BY LotNo) d ON a.LotNO=d.LotNo
|
|
// LEFT JOIN ICSLOTSIMULATION e ON a.LotNO=e.LOTNO
|
|
// WHERE a.TransNO='{0}'
|
|
// AND a.TransLine='{1}'
|
|
// ORDER BY a.LotNO";
|
|
//sql = string.Format(sql, txtMOCode.Text.Trim(), txtMORow.Text.Trim());
|
|
//DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
|
|
//grdDetail.DataSource = dt;
|
|
//grvDetail.BestFitColumns();
|
|
|
|
string sql = @" SELECT MOCODE+'-'+MOSEQ AS 工单,MOCODE AS 生产订单号,MOSEQ AS 生产订单行号,ITEMCODE AS 存货编码,b.INVNAME AS 存货名称,MOPLANQTY AS 工单数量,b.INVSTD AS 规格型号,
|
|
MOVER AS 零件号,MOTYPE AS 工单类型
|
|
FROM ICSMO a
|
|
INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE
|
|
WHERE MOCODE+MOSEQ IN (SELECT TransNO+TransLine FROM ICSITEMLot WHERE TYPE='工单')
|
|
AND NOT exists (SELECT TransNO+TransLine--,COUNT(a.LotNO),COUNT(b.LotNO)
|
|
FROM ICSITEMLot e
|
|
LEFT JOIN ICSLOTSIMULATION b ON e.LotNO=b.LOTNO AND b.ISCOM='1'
|
|
GROUP BY TransNO+TransLine
|
|
HAVING COUNT(e.LotNO)=COUNT(b.LotNO) and TransNO+TransLine=a.MOCODE+a.MOSEQ)
|
|
AND MOCODE='"+ edit.EditValue.ToString()+@"' ";
|
|
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
txtMORow.Properties.ValueMember = "生产订单行号";
|
|
txtMORow.Properties.DisplayMember = "生产订单行号";
|
|
txtMORow.Properties.DataSource = dt;
|
|
txtMORow.Properties.NullText = "";//空时的值
|
|
txtMORow.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
txtMORow.Properties.ValidateOnEnterKey = true;//回车确认
|
|
txtMORow.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
txtMORow.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
txtMORow.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void btnCreate_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (data == null || data.Rows.Count <= 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请重新选择跟踪单信息!");
|
|
return;
|
|
}
|
|
DataRow dr = data.NewRow();
|
|
dr["isSelect"] = "Y";
|
|
dr["ID"] = "";
|
|
dr["LotNO"] = data.Rows[0]["LotNO"].ToString();
|
|
dr["MCODE"] = data.Rows[0]["MCODE"].ToString();
|
|
dr["INVNAME"] = data.Rows[0]["INVNAME"].ToString();
|
|
dr["INVSTD"] = data.Rows[0]["INVSTD"].ToString();
|
|
dr["LOTQTY"] = data.Rows[0]["LOTQTY"].ToString();
|
|
dr["INVUOM"] = data.Rows[0]["INVUOM"].ToString();
|
|
dr["num"] = data.Rows[0]["num"];
|
|
dr["INVEXPORTIMPORT"] = data.Rows[0]["INVEXPORTIMPORT"].ToString();
|
|
dr["ROUTECODE"] = data.Rows[0]["ROUTECODE"].ToString();
|
|
dr["OPSEQ"] = 0;
|
|
dr["OPCODE"] = "";
|
|
dr["OPNAME"] = "";
|
|
dr["ONWIP"] = false;
|
|
dr["OLD"] = false;
|
|
dr["EATTRIBUTE1"] = false;
|
|
dr["mo2user"] = false;
|
|
data.Rows.Add(dr);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void btnModify_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
#region 产品
|
|
List<ICSITEMROUTE2OPLot> modelList = new List<ICSITEMROUTE2OPLot>();
|
|
ICSITEMROUTE2OPLot model;
|
|
|
|
for (int j = 0; j < grvDetail.RowCount; j++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(j, colisSelect).ToString() == "Y")
|
|
{
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, gridColumn1).ToString() == "Y" && !Convert.ToBoolean(gridView1.GetRowCellValue(i, ONWIP)) && !Convert.ToBoolean(gridView1.GetRowCellValue(i, OLD)) && !Convert.ToBoolean(gridView1.GetRowCellValue(i, mo2user)))
|
|
{
|
|
model = new ICSITEMROUTE2OPLot();
|
|
|
|
model.ID = gridView1.GetRowCellValue(i, ID).ToString();
|
|
model.ITEMCODE = gridView1.GetRowCellValue(i, MCODE).ToString();
|
|
//model.LotNo = gridView1.GetRowCellValue(i, LotNO).ToString();
|
|
model.LotNo = grvDetail.GetRowCellValue(j, colLotNO).ToString();
|
|
model.ROUTECODE = gridView1.GetRowCellValue(i, ROUTECODE).ToString();
|
|
model.OPCODE = gridView1.GetRowCellValue(i, OPCODE).ToString();
|
|
model.OPSEQ = Convert.ToInt32(gridView1.GetRowCellValue(i, OPSEQ));
|
|
model.OPCONTROL = "00000000000000";
|
|
model.OPTIONALOP = "";
|
|
model.IDMERGETYPE = "";
|
|
model.IDMERGERULE = 0;
|
|
model.MUSER = AppConfig.UserId;
|
|
model.MUSERName = AppConfig.UserName;
|
|
model.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
model.WorkPoint = AppConfig.WorkPointCode;
|
|
if (model.OPSEQ <= 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("第" + (i + 1) + "行工序次序必须大于零!");
|
|
return;
|
|
}
|
|
else if (model.OPSEQ < max)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("第" + (i + 1) + "行工序次序必须大于已报工的次序!");
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(model.OPCODE))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("第" + (i + 1) + "行工序代码不能为空!");
|
|
return;
|
|
}
|
|
modelList.Add(model);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (modelList.Count <= 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!!!");
|
|
return;
|
|
}
|
|
|
|
ICSMO2LotBLL.AddList(modelList, AppConfig.AppConnectString);
|
|
|
|
#endregion
|
|
ICSBaseSimpleCode.AppshowMessageBox("保存成功");
|
|
load();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//throw ex;
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void btnDel_Click(object sender, EventArgs e)
|
|
{
|
|
//List<string> moidList = new List<string>();
|
|
//for (int i = 0; i < gridView1.RowCount; i++)
|
|
//{
|
|
// if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y" && !Convert.ToBoolean(gridView1.GetRowCellValue(i, ONWIP)))
|
|
// {
|
|
// moidList.Add(gridView1.GetRowCellValue(i, ID).ToString());
|
|
// }
|
|
//}
|
|
//if (moidList.Count == 0 || moidList == null)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
|
|
// return;
|
|
//}
|
|
List<ICSITEMROUTE2OPLot> list = new List<ICSITEMROUTE2OPLot>();
|
|
|
|
for (int j = 0; j < grvDetail.RowCount; j++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(j, colisSelect).ToString() == "Y")
|
|
{
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, gridColumn1).ToString() == "Y" && !Convert.ToBoolean(gridView1.GetRowCellValue(i, ONWIP)) && Convert.ToBoolean(gridView1.GetRowCellValue(i, OLD)) && !Convert.ToBoolean(gridView1.GetRowCellValue(i, mo2user)))
|
|
{
|
|
ICSITEMROUTE2OPLot lot = new ICSITEMROUTE2OPLot();
|
|
lot.LotNo = grvDetail.GetRowCellValue(j, colLotNO).ToString();
|
|
lot.OPCODE = gridView1.GetRowCellValue(i, OPCODE).ToString();
|
|
|
|
|
|
list.Add(lot);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (list == null || list.Count == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
|
|
return;
|
|
}
|
|
if (list.Count == data.Rows.Count) {
|
|
ICSBaseSimpleCode.AppshowMessageBox("无法删除全部工序!");
|
|
return;
|
|
}
|
|
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除吗?删除后无法恢复,确定吗?") != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
//ICSMO2LotBLL.deleteLot(moidList);
|
|
ICSMO2LotBLL.deleteLot(list);
|
|
ICSBaseSimpleCode.AppshowMessageBox("删除成功");
|
|
|
|
gridControl1.DataSource = null;
|
|
load();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void grdDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
}
|
|
|
|
private void txtMOCode_QueryPopUp(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
//txtMOCode.Properties.View.Columns["工单"].Visible = false;
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit1_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit.EditValue != null || edit.EditValue.ToString() != "" || edit.EditValue.ToString() != "nulltext")
|
|
{
|
|
var o = edit.Properties.GetRowByKeyValue(edit.EditValue);
|
|
if (o is DataRowView)
|
|
{
|
|
DataRowView RowView = o as DataRowView;
|
|
string OPNAME = RowView.Row["工序"].ToString();
|
|
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, colOPNAME, OPNAME);
|
|
}
|
|
else
|
|
{
|
|
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, colOPNAME, "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void gridView1_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (gridView1.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
if (gridView1.FocusedColumn == gridColumn1)
|
|
{
|
|
if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridColumn1).ToString() == "" && !Convert.ToBoolean(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, ONWIP)) && !Convert.ToBoolean(gridView1.GetRowCellValue(gridView1.FocusedRowHandle,mo2user)))
|
|
{
|
|
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridColumn1, "Y");
|
|
}
|
|
else
|
|
{
|
|
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridColumn1, "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
RepositoryItem _disabledItem;
|
|
private void grvDetail_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
|
|
{
|
|
if (e.Column == OPSEQ || e.Column == OPCODE)
|
|
{
|
|
if (_disabledItem == null)
|
|
{
|
|
_disabledItem = (RepositoryItem)e.RepositoryItem.Clone();
|
|
_disabledItem.ReadOnly = true;
|
|
_disabledItem.Enabled = false;
|
|
}
|
|
//满足条件,设置成只读
|
|
if (Convert.ToBoolean(gridView1.GetRowCellValue(e.RowHandle, OLD)))
|
|
{
|
|
e.RepositoryItem = _disabledItem;
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 全选
|
|
private void btnSelectAll_Click(object sender, EventArgs e)
|
|
{
|
|
string msg = "";
|
|
int OPlotSum = 0;
|
|
int WipSum = 0;
|
|
grvDetail.PostEditor();
|
|
this.Validate();
|
|
gridControl1.DataSource = null;
|
|
max = 0;
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
grvDetail.SetRowCellValue(i, colisSelect, "");
|
|
}
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
OPlotSum = Convert.ToInt32(grvDetail.GetRowCellValue(i, colOPlotSum));
|
|
WipSum = Convert.ToInt32(grvDetail.GetRowCellValue(i, colWipSum));
|
|
grvDetail.SetRowCellValue(i, colisSelect, "Y");
|
|
LotNo = grvDetail.GetRowCellValue(i, colLotNO).ToString();
|
|
load();
|
|
}
|
|
else
|
|
{
|
|
if (OPlotSum != Convert.ToInt32(grvDetail.GetRowCellValue(i, colOPlotSum)))
|
|
{
|
|
msg += "条码:" + grvDetail.GetRowCellValue(i, colLotNO).ToString() + " 中工序数量与第一条不同!"+Environment.NewLine;
|
|
}
|
|
else if (WipSum != Convert.ToInt32(grvDetail.GetRowCellValue(i, colWipSum)))
|
|
{
|
|
msg += "条码:" + grvDetail.GetRowCellValue(i, colLotNO).ToString() + " 中已报工工序数量与第一条不同!" + Environment.NewLine;
|
|
}
|
|
else
|
|
grvDetail.SetRowCellValue(i, colisSelect, "Y");
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(msg))
|
|
ICSBaseSimpleCode.AppshowMessageBox(msg);
|
|
}
|
|
#endregion
|
|
|
|
#region 全消
|
|
private void btnCancelAll_Click(object sender, EventArgs e)
|
|
{
|
|
grvDetail.PostEditor();
|
|
this.Validate();
|
|
max = 0;
|
|
gridControl1.DataSource = null;
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
grvDetail.SetRowCellValue(i, colisSelect, "");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
private void txtMORow_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
gridControl1.DataSource = null;
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit.EditValue != null && edit.EditValue.ToString() != "" && edit.EditValue.ToString() != "nulltext")
|
|
{
|
|
var o = edit.Properties.GetRowByKeyValue(edit.EditValue);
|
|
if (o is DataRowView)
|
|
{
|
|
DataRowView RowView = o as DataRowView;
|
|
txtCode.Text = RowView.Row["存货编码"].ToString();
|
|
txtcInvName.Text = RowView.Row["存货名称"].ToString();
|
|
txtMoverCode.Text = RowView.Row["零件号"].ToString();
|
|
txtcInvStd.Text = RowView.Row["规格型号"].ToString();
|
|
txtMOType.Text = RowView.Row["工单类型"].ToString();
|
|
txtiQuantity.Text = RowView.Row["工单数量"].ToString();
|
|
|
|
string sql = @"SELECT '' as isSelect,a.LotNO,a.MCODE,b.INVNAME,b.INVSTD,CAST(a.LOTQTY AS DECIMAL(18,2)) AS LOTQTY,b.INVUOM,CAST(a.LOTQTY*a.EATTRIBUTE3 AS DECIMAL(18,2)) AS num,b.INVEXPORTIMPORT,ISNULL(c.LotNoSum, 0) AS OPlotSum,ISNULL(d.LotNoSum, 0) AS WipSum,CAST(ISNULL(e.ISCOM, 0) AS BIT) AS Collect,a.VenderLotNO
|
|
FROM ICSITEMLot a
|
|
INNER JOIN ICSINVENTORY b ON a.MCODE=b.INVCODE
|
|
LEFT JOIN (SELECT LotNo,COUNT(LotNo) AS LotNoSum FROM ICSITEMROUTE2OPLot GROUP BY LotNo) c ON a.LotNO=c.LotNo
|
|
LEFT JOIN (SELECT LotNo,COUNT(DISTINCT OPCODE) AS LotNoSum FROM ICSLOTONWIP GROUP BY LotNo) d ON a.LotNO=d.LotNo
|
|
LEFT JOIN ICSLOTSIMULATION e ON a.LotNO=e.LOTNO
|
|
WHERE a.TransNO='{0}'
|
|
AND a.TransLine='{1}'
|
|
ORDER BY a.LotNO";
|
|
sql = string.Format(sql, txtMOCode.Text.Trim(), txtMORow.Text.Trim());
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
|
|
grdDetail.DataSource = dt;
|
|
grvDetail.BestFitColumns();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception EX) {
|
|
ICSBaseSimpleCode.AppshowMessageBox(EX.Message);
|
|
}
|
|
}
|
|
|
|
private void txtMORow_QueryPopUp(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
if (txtMORow.Properties.View.Columns.Count > 0)
|
|
{
|
|
txtMORow.Properties.View.Columns["工单"].Visible = false;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|