锐腾搅拌上料功能
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.

678 lines
34 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Linq;
using System.Linq;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid;
using System.IO;
using System.Threading;
using ICSSoft.Base.Language.Tool;
using ICSSoft.Base.Config.AppConfig;
using ICSSoft.Base.UserControl.MessageControl;
using ICSSoft.Base.Config.DBHelper;
using ICSSoft.Base.Report.Filter;
using ICSSoft.Base.UserControl.FormControl;
using ICSSoft.Base.Report.GridReport;
using ICSSoft.Base.ReferForm.AppReferForm;
using ICSSoft.Frame.Data.BLL;
using ICSSoft.Frame.Data.Entity;
namespace ICSSoft.Frame.APP
{
public partial class FormICSONWIPCheckNCR : DevExpress.XtraEditors.XtraForm
{
string = "";
string = "";
private string sqltxt = "";
private string sqlconn = "";
private DataTable dataSource = null;
public string Code = "";
#region 构造函数
public FormICSONWIPCheckNCR()
{
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);
List<Control> ControlList = new List<Control>();
ControlList.Add(btnCreate);
ControlList.Add(btnModify);
ControlList.Add(btnOutPut);
foreach (Control ctr in ControlList)
{
if (ctr.GetType() == typeof(SimpleButton))
{
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 btnClose_Click(object sender, EventArgs e)
{
AppConfig.CloseFormShow(this.Text);
this.Close();
}
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 grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
#endregion
#region 全选
private void btnSelectAll_Click(object sender, EventArgs e)
{
grvDetail.PostEditor();
this.Validate();
for (int i = 0; i < grvDetail.RowCount; i++)
{
grvDetail.SetRowCellValue(i, colisSelect, true);
}
}
#endregion
#region 全消
private void btnCancelAll_Click(object sender, EventArgs e)
{
grvDetail.PostEditor();
this.Validate();
for (int i = 0; i < grvDetail.RowCount; i++)
{
grvDetail.SetRowCellValue(i, colisSelect, false);
}
}
#endregion
#region 导出
private void btnOutPut_Click(object sender, EventArgs e)
{
FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
foe.ShowDialog();
}
#endregion
#region 刷新
private void btnRefresh_Click(object sender, EventArgs e)
{
SearchData();
}
#endregion
#region 上传OA
private void btnCreate_Click(object sender, EventArgs e)
{
int limitResOPs = 29;
DataRow[] drArr = GetSelectedRows();
if (drArr == null)
{
return;
}
List<string> listNotSelectedMsg = new List<string>();
foreach (DataRow dr in drArr)
{
if (!Convert.ToBoolean(dr["isSelect"]))
{
if (listNotSelectedMsg.Count == 0)
{
listNotSelectedMsg.Add("当前是批量处理,以下不良行未选取,是否选取全部?");
}
listNotSelectedMsg.Add("不良类型:" + dr["UNIT"].ToString() + "数量:" + dr["SetValue"].ToString() + "不良备注:" + dr["不良备注"].ToString());
}
}
if (listNotSelectedMsg.Count > 0)
{
DialogResult drSelectAll = MessageBox.Show(string.Join(Environment.NewLine, listNotSelectedMsg), "提示", MessageBoxButtons.OKCancel);
if (drSelectAll != DialogResult.OK)
{
return;
}
for (int i = 0; i < drArr.Length; i++)
{
if (Convert.ToBoolean(drArr[i]["isSelect"]) == false)
{
drArr[i]["isSelect"] = true;
}
}
}
DialogResult drUpload2OA = MessageBox.Show("确定上传OA吗", "提示", MessageBoxButtons.YesNo);
if (drUpload2OA != DialogResult.Yes)
{
return;
}
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在保存...请稍等...");
_wait.Show();
string LOTNO = drArr[0]["LOTNO"].ToString();
int OPSEQ = Convert.ToInt32(drArr[0]["OPSEQ"]);
try
{
DateTime dt = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
List<ICSLOTONWIPCheckNCR> list = new List<ICSLOTONWIPCheckNCR>();
string ncr = "";
foreach (DataRow item in drArr)
{
ICSLOTONWIPCheckNCR Info = new ICSLOTONWIPCheckNCR();
Info.ID = AppConfig.GetGuid();
Info.CheckID = item["ID"].ToString();
Info.Status = "处理中";
Info.UpDateTime = dt;
Info.NCRNo = null;
Info.DownDateTime = null;
Info.Memo = item["Memo"].ToString();
Info.Type = item["CheckMode"].ToString();
Info.IsInput = false;
Info.MUSER = AppConfig.UserCode;
Info.MUSERName = AppConfig.UserName;
Info.MTIME = dt;
Info.WorkPoint = AppConfig.WorkPointCode;
list.Add(Info);
}
string FLOW_ID = ICSLOTONWIPCheckBLL.GetFLOW_ID(AppConfig.AppConnectString, AppConfig.WorkPointCode);//20,25
string Source = ICSSys_EnumValuesBLL.GetNcrNGSource(AppConfig.AppConnectString, AppConfig.WorkPointCode);
DataTable dtOPs = ICSResOPBLL.GetResOPList(LOTNO, OPSEQ, AppConfig.WorkPointCode);
if (dtOPs.Rows.Count > limitResOPs)
{
throw new Exception("途径工序超过" + limitResOPs.ToString() + "道");
}
ICSLOTONWIPCheckBLL.AddNCROA(list, dtOPs, FLOW_ID, Source, AppConfig.AppConnectString);
_wait.Close();
btnRefresh_Click(null, null);
}
catch (Exception ex)
{
_wait.Close();
ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
}
}
#endregion
#region 直接判定
public void GetDirectlyResult(string Result, string ErrOP)
{
txtResult.Text = Result;
txtErrOP.Text = ErrOP;
}
private void btnModify_Click(object sender, EventArgs e)
{
try
{
DataRow[] drArr = GetSelectedRows();
if (drArr == null)
{
return;
}
FormICSONWIPCheckNCRSelect FrmSuspend = new FormICSONWIPCheckNCRSelect(drArr);
FrmSuspend.action += new Action<string, string>(GetDirectlyResult);
DialogResult dr = FrmSuspend.ShowDialog();
if (dr != DialogResult.OK)
{
return;
}
string result = txtResult.Text.Trim();
if (string.IsNullOrWhiteSpace(result))
{
ICSBaseSimpleCode.AppshowMessageBox("请选择结果判定!");
return;
}
DialogResult dr2 = MessageBox.Show("确定直接判定:" + result + "?", "提示", MessageBoxButtons.YesNo);
if (dr2 != DialogResult.Yes)
{
return;
}
NcrNotFromOA(drArr, result);
//saveData(result);
btnRefresh_Click(null, null);
}
catch (Exception ex)
{
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
finally
{
txtResult.Text = "";
txtErrOP.Text = "";
}
}
/// <summary>
/// NCR直接判定
/// </summary>
/// <param name="drArr"></param>
/// <param name="result"></param>
private void NcrNotFromOA(DataRow[] drArr, string result)
{
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在保存...请稍等...");
try
{
_wait.Show();
DateTime timeNow = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
List<ICSLOTONWIPCheckNCR> list = new List<ICSLOTONWIPCheckNCR>();
for (int i = 0; i < drArr.Length; i++)
{
string chkmode = drArr[i]["CheckMode"].ToString();
//if (status == "让步接受" && chkmode != "工序检验" && chkmode != "委外检验")
//{
// throw new Exception("过程检验不可让步接受");
//}
ICSLOTONWIPCheckNCR Info = new ICSLOTONWIPCheckNCR();
Info.ID = AppConfig.GetGuid();
Info.NCRNo = null;
Info.CheckID = drArr[i]["ID"].ToString();
Info.Status = result;
Info.UpDateTime = timeNow;
Info.DownDateTime = timeNow;
Info.Memo = drArr[i]["Memo"].ToString();
Info.Type = chkmode;
Info.IsInput = true;//判定和结算工费合并,这里直接true,结算工费是不再更新此字段
Info.MUSER = AppConfig.UserCode;
Info.MUSERName = AppConfig.UserName;
Info.MTIME = timeNow;
Info.WorkPoint = AppConfig.WorkPointCode;
Info.EATTRIBUTE1 = null;
Info.ResOP = txtErrOP.Text;//责任工序
list.Add(Info);
}
ICSLOTONWIPCheckBLL.AddNCR2(list, AppConfig.AppConnectString);
_wait.Close();
}
catch (Exception ex)
{
_wait.Close();
ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
}
}
#endregion
/// <summary>
/// 选择,同跟踪单,工序,检验方式,且未处理的行
/// 批量时,是同批次所有行,包含未选取的行
/// </summary>
/// <returns></returns>
private DataRow[] GetSelectedRows()
{
if (dataSource == null)
{
return null;
}
DataRow[] drArr = dataSource.Select("(Status is null or Status='') and isSelect=true");
if (drArr.Count() == 0)
{
return null;
}
if (drArr.GroupBy(a => new { LOTNO = a.Field<string>("LOTNO"), OPCODE = a.Field<string>("OPCODE") }).Count() > 1)
{
throw new Exception("所有行只能选择同一跟踪单,工序");
}
if (drArr.GroupBy(a => a.Field<string>("CheckMode")).Count() > 1)
{
throw new Exception("所有行只能选择一种检验类型,过程/工序/委外");
}
if (Convert.ToBoolean(drArr[0]["IsBatch"]) == true)
{
//只有委外才有批量和非批量,其他全是非批量
string LOTNO = drArr[0]["LOTNO"].ToString();
string OPCODE = drArr[0]["OPCODE"].ToString();
string OPSEQ = drArr[0]["OPSEQ"].ToString();
drArr = dataSource.Select(string.Format("(Status is null or Status='') and CheckMode='委外检验' and LOTNO='{0}' and OPSEQ={1} and OPCODE='{2}' ", LOTNO, OPSEQ, OPCODE));
}
return drArr;
}
#region 加载&查询数据
private void FormICSONWIPCheckNCR_Load(object sender, EventArgs e)
{
try
{
SearchData();
}
catch (Exception ex)
{
ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
}
}
private void SearchData()
{
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
try
{
_wait.Show();
#region SQL
// string sql = @"SELECT CAST( 0 AS BIT ) AS isSelect,CASE WHEN us.EATTRIBUTE1='0' THEN '工序检验' ELSE '委外检验' END AS CheckMode,
// us.MOCODE,us.MOSEQ,a.ITEMCODE,b.INVNAME,b.INVSTD,a.LOTNO,a.OPCODE,d.OPDESC,ncr.IsInput,ncr.Status,a.LOTQTY AS Quantity,a.EQPCODE,eqp.EQPName,
// chkdet.ID,ncr.ID AS NcrID,ncr.MTIME,ncr.MUSERName,ncr.Memo,NCRNo,chk.Status AS Result,chkdet.SetValue,chkdet.UNIT
// FROM ICSLOTONWIP a
// INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
// LEFT JOIN ICSEquipment eqp ON a.EQPCODE=eqp.EQPCode AND a.WorkPoint=eqp.WorkPoint
// INNER JOIN ICSMO2User us ON a.LOTNO=us.LOTNO AND a.OPCODE=us.OPCODE AND a.WorkPoint=us.WorkPoint
// INNER JOIN ICSITEMROUTE2OPLot lot ON a.LOTNO=lot.LOTNO AND a.OPCODE=lot.OPCODE AND a.WorkPoint=lot.WorkPoint
// INNER JOIN ICSOP d ON a.OPCODE=d.OPCODE AND a.WorkPoint=d.WorkPoint
// INNER JOIN ICSLOTONWIPCheck chk ON a.ID=chk.FORTRANID AND a.WorkPoint=chk.WorkPoint AND chk.Enable='1'
//-- INNER JOIN (SELECT WorkPoint,FORTRANID,SUM(CONVERT(DECIMAL,ISNULL(SetValue,0))) AS SetValue, STUFF((SELECT ';'+UNIT FROM (select DISTINCT UNIT from ICSLOTONWIPCheckDetail where Type='不良' AND FORTRANID=b.FORTRANID AND WorkPoint=b.WorkPoint)a for xml path('')),1,1,'') AS UNIT
//-- FROM ICSLOTONWIPCheckDetail b
//-- WHERE Type='不良'
//-- GROUP BY WorkPoint,FORTRANID) det ON chk.ID=det.FORTRANID AND chk.WorkPoint=det.WorkPoint
// INNER JOIN ICSLOTONWIPCheckDetail chkdet ON chkdet.FORTRANID=chk.ID AND chkdet.WorkPoint=chk.WorkPoint AND chkdet.Type='不良'
// LEFT JOIN ICSLOTONWIPCheckNCR ncr ON chkdet.ID=ncr.CheckID AND chkdet.WorkPoint=ncr.WorkPoint
// WHERE a.WorkPoint='{0}' AND chk.Status='不良'
// UNION ALL
// SELECT CAST( 0 AS BIT ) AS isSelect,e.CheckMode,
// us.MOCODE,us.MOSEQ,a.ITEMCODE,b.INVNAME,b.INVSTD,a.LOTNO,a.OPCODE,d.OPDESC,ncr.IsInput,ncr.Status,a.LOTQTY AS Quantity,a.EQPCODE,eqp.EQPName,
// chkdet.ID,ncr.ID AS NcrID,ncr.MTIME,ncr.MUSERName,ncr.Memo,NCRNo,chk.Status AS Result,chkdet.SetValue,chkdet.UNIT
// FROM ICSLOTONWIP a
// INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
// LEFT JOIN ICSEquipment eqp ON a.EQPCODE=eqp.EQPCode AND a.WorkPoint=eqp.WorkPoint
// INNER JOIN ICSMO2User us ON a.LOTNO=us.LOTNO AND a.OPCODE=us.OPCODE AND a.WorkPoint=us.WorkPoint
// INNER JOIN ICSITEMROUTE2OPLot lot ON a.LOTNO=lot.LOTNO AND a.OPCODE=lot.OPCODE AND a.WorkPoint=lot.WorkPoint
// INNER JOIN ICSOP d ON a.OPCODE=d.OPCODE AND a.WorkPoint=d.WorkPoint
// INNER JOIN ICSLOTONWIPDetail Wipdet ON Wipdet.LOTNO=a.LOTNO AND Wipdet.OPCode=a.OPCODE AND a.WorkPoint=Wipdet.WorkPoint
// INNER JOIN ICSLOTONWIPInspection e ON Wipdet.ID=e.DetailID AND Wipdet.WorkPoint=e.WorkPoint
// INNER JOIN ICSLOTONWIPCheck chk ON e.ID=chk.FORTRANID AND e.WorkPoint=chk.WorkPoint AND chk.Enable='1'
//-- INNER JOIN (SELECT WorkPoint,FORTRANID,SUM(CONVERT(DECIMAL,ISNULL(SetValue,0))) AS SetValue, STUFF((SELECT ';'+UNIT FROM (select DISTINCT UNIT from ICSLOTONWIPCheckDetail where Type='不良' AND FORTRANID=b.FORTRANID AND WorkPoint=b.WorkPoint)a for xml path('')),1,1,'') AS UNIT
//-- FROM ICSLOTONWIPCheckDetail b
//-- WHERE Type='不良'
//-- GROUP BY WorkPoint,FORTRANID) det ON chk.ID=det.FORTRANID AND chk.WorkPoint=det.WorkPoint
// INNER JOIN ICSLOTONWIPCheckDetail chkdet ON chkdet.FORTRANID=chk.ID AND chkdet.WorkPoint=chk.WorkPoint AND chkdet.Type='不良'
// LEFT JOIN ICSLOTONWIPCheckNCR ncr ON chkdet.ID=ncr.CheckID AND chkdet.WorkPoint=ncr.WorkPoint
// WHERE a.WorkPoint='{0}' AND chk.Status='不良' ORDER BY ncr.MTIME,a.LOTNO
//
// select EnumText as [不合格责任方] from Sys_EnumValues WHERE EnumKey='00102' AND WorkPointCode='{0}'
// select EnumText as [不良起源] from Sys_EnumValues WHERE EnumKey='00101' AND WorkPointCode='{0}'
// select EnumText as [结果判定] from Sys_EnumValues WHERE EnumKey='00103' AND WorkPointCode='{0}'";
string sql = @"
SELECT CAST( 0 AS BIT ) AS isSelect,CASE WHEN us.EATTRIBUTE1='0' THEN '工序检验' ELSE '委外检验' END AS CheckMode,
us.MOCODE,us.MOSEQ,a.ITEMCODE,b.INVNAME,b.INVSTD,a.LOTNO,a.OPSEQ,a.OPCODE,d.OPDESC,ncr.IsInput,ISNULL(ncr.OAError,ncr.Status)AS Status,a.LOTQTY AS Quantity,a.EQPCODE,eqp.EQPName,
chkdet.ID,ncr.ID AS NcrID,ncr.MTIME,ncr.MUSERName,ncr.Memo,NCRNo,chk.Status AS Result,chkdet.SetValue,chkdet.UNIT,
b.[version] AS 物料版本,b.INVMODELGROUP AS 客户料号,b.INVGROUPDESC AS 材料号,
mo.MOVER AS 批次号,u.UserName AS 检验员,chkdet.CKGROUPMETH AS 不良备注,ISNULL(chk.IsBatch,CONVERT(BIT,0)) IsBatch,ISNULL(lot.ISWWRW,CONVERT(BIT,0)) ISWWRW
FROM ICSLOTONWIP a
INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
LEFT JOIN ICSEquipment eqp ON a.EQPCODE=eqp.EQPCode AND a.WorkPoint=eqp.WorkPoint
INNER JOIN ICSMO2User us ON a.LOTNO=us.LOTNO AND a.OPCODE=us.OPCODE AND a.WorkPoint=us.WorkPoint
INNER JOIN dbo.ICSMO mo ON mo.MOCODE=us.MOCODE AND mo.MOSEQ=us.MOSEQ AND mo.WorkPoint=us.WorkPoint
INNER JOIN ICSITEMROUTE2OPLot lot ON a.LOTNO=lot.LOTNO AND a.OPCODE=lot.OPCODE AND a.WorkPoint=lot.WorkPoint
INNER JOIN ICSOP d ON a.OPCODE=d.OPCODE AND a.WorkPoint=d.WorkPoint
INNER JOIN ICSLOTONWIPCheck chk ON a.ID=chk.FORTRANID AND a.WorkPoint=chk.WorkPoint AND chk.Enable='1'
LEFT JOIN Sys_User u ON u.UserCode=chk.EATTRIBUTE1 AND u.WorkPointCode=chk.WorkPoint
-- INNER JOIN (SELECT WorkPoint,FORTRANID,SUM(CONVERT(DECIMAL,ISNULL(SetValue,0))) AS SetValue, STUFF((SELECT ';'+UNIT FROM (select DISTINCT UNIT from ICSLOTONWIPCheckDetail where Type='不良' AND FORTRANID=b.FORTRANID AND WorkPoint=b.WorkPoint)a for xml path('')),1,1,'') AS UNIT
-- FROM ICSLOTONWIPCheckDetail b
-- WHERE Type='不良'
-- GROUP BY WorkPoint,FORTRANID) det ON chk.ID=det.FORTRANID AND chk.WorkPoint=det.WorkPoint
INNER JOIN ICSLOTONWIPCheckDetail chkdet ON chkdet.FORTRANID=chk.ID AND chkdet.WorkPoint=chk.WorkPoint AND chkdet.Type='不良'
LEFT JOIN ICSLOTONWIPCheckNCR ncr ON chkdet.ID=ncr.CheckID AND chkdet.WorkPoint=ncr.WorkPoint
WHERE a.WorkPoint='{0}' AND chk.Status='不良'
UNION ALL
SELECT CAST( 0 AS BIT ) AS isSelect,e.CheckMode,
us.MOCODE,us.MOSEQ,a.ITEMCODE,b.INVNAME,b.INVSTD,a.LOTNO,a.OPSEQ,a.OPCODE,d.OPDESC,ncr.IsInput,ncr.Status,a.LOTQTY AS Quantity,a.EQPCODE,eqp.EQPName,
chkdet.ID,ncr.ID AS NcrID,ncr.MTIME,ncr.MUSERName,ncr.Memo,NCRNo,chk.Status AS Result,chkdet.SetValue,chkdet.UNIT,
b.[version] AS 物料版本,b.INVMODELGROUP AS 客户料号,b.INVGROUPDESC AS 材料号,
mo.MOVER AS 批次号,u.UserName AS 检验员,chkdet.CKGROUPMETH AS 不良备注,ISNULL(chk.IsBatch,CONVERT(BIT,0)) IsBatch,ISNULL(lot.ISWWRW,CONVERT(BIT,0)) ISWWRW
FROM ICSLOTONWIP a
INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
LEFT JOIN ICSEquipment eqp ON a.EQPCODE=eqp.EQPCode AND a.WorkPoint=eqp.WorkPoint
INNER JOIN ICSMO2User us ON a.LOTNO=us.LOTNO AND a.OPCODE=us.OPCODE AND a.WorkPoint=us.WorkPoint
INNER JOIN dbo.ICSMO mo ON mo.MOCODE=us.MOCODE AND mo.MOSEQ=us.MOSEQ AND mo.WorkPoint=us.WorkPoint
INNER JOIN ICSITEMROUTE2OPLot lot ON a.LOTNO=lot.LOTNO AND a.OPCODE=lot.OPCODE AND a.WorkPoint=lot.WorkPoint
INNER JOIN ICSOP d ON a.OPCODE=d.OPCODE AND a.WorkPoint=d.WorkPoint
INNER JOIN ICSLOTONWIPDetail Wipdet ON Wipdet.LOTNO=a.LOTNO AND Wipdet.OPCode=a.OPCODE AND a.WorkPoint=Wipdet.WorkPoint
INNER JOIN ICSLOTONWIPInspection e ON Wipdet.ID=e.DetailID AND Wipdet.WorkPoint=e.WorkPoint
INNER JOIN ICSLOTONWIPCheck chk ON e.ID=chk.FORTRANID AND e.WorkPoint=chk.WorkPoint AND chk.Enable='1'
LEFT JOIN Sys_User u ON u.UserCode=chk.EATTRIBUTE1 AND u.WorkPointCode=chk.WorkPoint
-- INNER JOIN (SELECT WorkPoint,FORTRANID,SUM(CONVERT(DECIMAL,ISNULL(SetValue,0))) AS SetValue, STUFF((SELECT ';'+UNIT FROM (select DISTINCT UNIT from ICSLOTONWIPCheckDetail where Type='不良' AND FORTRANID=b.FORTRANID AND WorkPoint=b.WorkPoint)a for xml path('')),1,1,'') AS UNIT
-- FROM ICSLOTONWIPCheckDetail b
-- WHERE Type='不良'
-- GROUP BY WorkPoint,FORTRANID) det ON chk.ID=det.FORTRANID AND chk.WorkPoint=det.WorkPoint
INNER JOIN ICSLOTONWIPCheckDetail chkdet ON chkdet.FORTRANID=chk.ID AND chkdet.WorkPoint=chk.WorkPoint AND chkdet.Type='不良'
LEFT JOIN ICSLOTONWIPCheckNCR ncr ON chkdet.ID=ncr.CheckID AND chkdet.WorkPoint=ncr.WorkPoint
WHERE a.WorkPoint='{0}' AND chk.Status='不良' ORDER BY ncr.MTIME,a.LOTNO
select EnumText as [不合格责任方] from Sys_EnumValues WHERE EnumKey='00102' AND WorkPointCode='{0}'
select EnumText as [不良起源] from Sys_EnumValues WHERE EnumKey='00101' AND WorkPointCode='{0}'
select EnumText as [结果判定] from Sys_EnumValues WHERE EnumKey='00103' AND WorkPointCode='{0}'
";
#endregion
sql = string.Format(sql, AppConfig.WorkPointCode);
DataSet ds = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql);
dataSource = ds.Tables[0];
grdDetail.DataSource = dataSource;
grvDetail.BestFitColumns();
//#region 不合格责任方
//txtNG.Properties.ValueMember = "不合格责任方";
//txtNG.Properties.DisplayMember = "不合格责任方";
//txtNG.Properties.DataSource = ds.Tables[1];
//txtNG.Properties.NullText = "";//空时的值
//txtNG.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
//txtNG.Properties.ValidateOnEnterKey = true;//回车确认
//txtNG.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
//txtNG.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
////自适应宽度
//txtNG.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
//#endregion
//#region 不良起源
//txtSource.Properties.ValueMember = "不良起源";
//txtSource.Properties.DisplayMember = "不良起源";
//txtSource.Properties.DataSource = ds.Tables[2];
//txtSource.Properties.NullText = "";//空时的值
//txtSource.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
//txtSource.Properties.ValidateOnEnterKey = true;//回车确认
//txtSource.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
//txtSource.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
////自适应宽度
//txtSource.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
//if (ds.Tables[2] == null || ds.Tables[2].Rows.Count <= 0)
// throw new Exception("不良起源未维护!");
//else
// txtSource.Text = ds.Tables[2].Rows[0][0].ToString();
//#endregion
//#region 结果判定
//txtResult.Properties.ValueMember = "结果判定";
//txtResult.Properties.DisplayMember = "结果判定";
//txtResult.Properties.DataSource = ds.Tables[3];
//txtResult.Properties.NullText = "";//空时的值
//txtResult.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
//txtResult.Properties.ValidateOnEnterKey = true;//回车确认
//txtResult.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
//txtResult.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
////自适应宽度
//txtResult.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
//#endregion
_wait.Close();
}
catch (Exception ex)
{
_wait.Close();
ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
}
}
#endregion
#region 保存数据
private void saveData(string status)
{
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在保存...请稍等...");
try
{
_wait.Show();
DateTime dt = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
List<ICSLOTONWIPCheckNCR> list = new List<ICSLOTONWIPCheckNCR>();
for (int i = 0; i < grvDetail.RowCount; i++)
{
if (Convert.ToBoolean(grvDetail.GetRowCellValue(i, colisSelect))
&& string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(i, colStatus).ToString()))
{
string chkmode = grvDetail.GetRowCellValue(i, colCheckMode).ToString();
//if (status == "让步接受" && chkmode != "工序检验" && chkmode != "委外检验")
//{
// throw new Exception("过程检验不可让步接受");
//}
ICSLOTONWIPCheckNCR Info = new ICSLOTONWIPCheckNCR();
Info.ID = AppConfig.GetGuid();
Info.CheckID = grvDetail.GetRowCellValue(i, colID).ToString();
Info.Status = status;
Info.UpDateTime = dt;
Info.DownDateTime = dt;
Info.Memo = grvDetail.GetRowCellValue(i, colMemo).ToString();
Info.Type = chkmode;
Info.IsInput = false;
Info.MUSER = AppConfig.UserCode;
Info.MUSERName = AppConfig.UserName;
Info.MTIME = dt;
Info.WorkPoint = AppConfig.WorkPointCode;
Info.EATTRIBUTE1 = null;
Info.ResOP = txtErrOP.Text == "" ? null : txtErrOP.Text;
list.Add(Info);
}
}
if (list.Count == 0)
{
_wait.Close();
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
return;
}
ICSLOTONWIPCheckBLL.AddNCR(list, AppConfig.AppConnectString);
_wait.Close();
}
catch (Exception ex)
{
_wait.Close();
ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
}
}
#endregion
#region 结算工费
private void btnCalculate_Click(object sender, EventArgs e)
{
List<string> IDs = new List<string>();
for (int i = 0; i < grvDetail.RowCount; i++)
{
if (Convert.ToBoolean(grvDetail.GetRowCellValue(i, colisSelect))
&& grvDetail.GetRowCellValue(i, colCheckMode).ToString().Equals("委外检验")
&& grvDetail.GetRowCellValue(i, colStatus).ToString().Equals("让步接受")
&& !Convert.ToBoolean(grvDetail.GetRowCellValue(i, colIsInput)))
{
IDs.Add(grvDetail.GetRowCellValue(i, colNcrID).ToString());
}
}
if (IDs.Count <= 0)
{
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
return;
}
DialogResult DDR = MessageBox.Show("确定结算工费吗?", "提示", MessageBoxButtons.YesNo);
if (DDR != DialogResult.Yes)
{
return;
}
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在保存...请稍等...");
try
{
_wait.Show();
ICSLOTONWIPCheckBLL.AddNCRNC(IDs, AppConfig.AppConnectString);
_wait.Close();
btnRefresh_Click(null, null);
}
catch (Exception ex)
{
_wait.Close();
ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
}
}
#endregion
}
}