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.
323 lines
13 KiB
323 lines
13 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 FormICSCreateXunjian : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
private string sqltxt = "";
|
|
private string sqlconn = "";
|
|
private DataTable dataSource = null;
|
|
public string id = "";
|
|
|
|
#region 构造函数
|
|
public FormICSCreateXunjian()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
SearchData();
|
|
}
|
|
#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 RowIndicator序号
|
|
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 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)
|
|
{
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查询...");
|
|
_wait.Show();
|
|
try
|
|
{
|
|
dataSource = ICSLOTONWIPInspectionBLL.QueryXunjian(null, AppConfig.WorkPointCode, AppConfig.AppConnectString);
|
|
grdDetail.DataSource = dataSource;
|
|
grvDetail.BestFitColumns();
|
|
_wait.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 查询数据
|
|
private void SearchData()
|
|
{
|
|
dataSource = ICSLOTONWIPInspectionBLL.QueryXunjian(null, AppConfig.WorkPointCode, AppConfig.AppConnectString);
|
|
grdDetail.DataSource = dataSource;
|
|
grvDetail.BestFitColumns();
|
|
}
|
|
#endregion
|
|
|
|
private void grvDetail_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
MouseEventArgs me = (MouseEventArgs)e;
|
|
DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo info = grvDetail.CalcHitInfo(me.Location);
|
|
if (info.HitTest != DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitTest.RowIndicator)
|
|
{
|
|
return;
|
|
}
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在保存...");
|
|
_wait.Show();
|
|
int row = grvDetail.FocusedRowHandle;
|
|
try
|
|
{
|
|
id = CheckCreateXunjian(row);
|
|
_wait.Close();
|
|
this.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
|
|
btnRefresh_Click(null, null);
|
|
}
|
|
}
|
|
|
|
private string CheckCreateXunjian(int row)
|
|
{
|
|
string CostCenter = "";
|
|
string MOCODE = grvDetail.GetRowCellValue(row, colMOCODE).ToString();
|
|
string MOSEQ = grvDetail.GetRowCellValue(row, colMOSEQ).ToString();
|
|
string LOTNO = grvDetail.GetRowCellValue(row, colLOTNO).ToString();
|
|
string ROUTECODE = grvDetail.GetRowCellValue(row, colROUTECODE).ToString();
|
|
string OPCODE = grvDetail.GetRowCellValue(row, colOPCODE).ToString();
|
|
string EQPCODE = grvDetail.GetRowCellValue(row, colEQPCODE).ToString();
|
|
string wipDetID = grvDetail.GetRowCellValue(row, colDetailID).ToString();
|
|
string CurrentQTY = grvDetail.GetRowCellValue(row, colCurrentQTY).ToString().Trim();
|
|
//1.Check
|
|
DataTable dt = ICSLOTONWIPInspectionBLL.QueryXunjian(wipDetID, AppConfig.WorkPointCode, AppConfig.AppConnectString);
|
|
if (dt.Rows.Count == 0)
|
|
{
|
|
throw new Exception("已报工 不可巡检 .");
|
|
}
|
|
string TransNO = dt.Rows[0]["TransNO"].ToString();
|
|
string endtime = dt.Rows[0]["EndDateTime"].ToString();
|
|
if (!string.IsNullOrEmpty(TransNO) && string.IsNullOrEmpty(endtime))
|
|
{
|
|
throw new Exception("上次巡检结果未出 , 请先处理! 巡检单 : " + TransNO);
|
|
}
|
|
string reg = "^[1-9]+[0-9]*$";
|
|
if (!System.Text.RegularExpressions.Regex.IsMatch(CurrentQTY, reg))
|
|
{
|
|
throw new Exception("数量错误! 必须为正整数");
|
|
}
|
|
DataTable dtBaseOP = ICSWorkReportBLL.GetBaseOPCode(OPCODE, AppConfig.WorkPointCode, AppConfig.AppConnectString);
|
|
if (dtBaseOP.Rows.Count == 0)
|
|
{
|
|
throw new Exception("工序不存在!" + OPCODE);
|
|
}
|
|
CostCenter = dtBaseOP.Rows[0]["CostCenter"].ToString();
|
|
if (string.IsNullOrEmpty(CostCenter))
|
|
{
|
|
throw new Exception("基础工序:" + OPCODE.Substring(0, 3) + ",车间类型未绑定");
|
|
}
|
|
DataTable dtSJ_Lot = ICSWorkReportBLL.Shoujian("跟踪单", LOTNO, null, ROUTECODE, OPCODE, EQPCODE, AppConfig.WorkPointCode);
|
|
int noCheck = dtSJ_Lot.Select("Status='开始' or Status=''").Count();
|
|
if (noCheck > 0)
|
|
{
|
|
throw new Exception("首件 检验结果未出 ,不可巡检, 请先处理 首件送检");
|
|
}
|
|
DataTable dtSJ_MO = ICSWorkReportBLL.Shoujian("工单", MOCODE, MOSEQ, ROUTECODE, OPCODE, EQPCODE, AppConfig.WorkPointCode);
|
|
DataRow[] drsShoujian = dtSJ_MO.Select("CheckMode='量产首件' OR CheckMode='样品首件'");
|
|
if (drsShoujian.Count() == 0)
|
|
{
|
|
if (CostCenter == "CNC")
|
|
{
|
|
throw new Exception("CNC车间,没有调机[量产首件/样品首件] 送检记录 ,不可巡检");
|
|
}
|
|
throw new Exception("没有[量产首件/样品首件]送检记录, 请通知操作员送检 量产首件/样品首件 ,不可巡检");
|
|
}
|
|
else
|
|
{
|
|
if (drsShoujian.Where(a => a.Field<string>("Status") == "开始" || a.Field<string>("Status") == "").Count() > 0)
|
|
{
|
|
throw new Exception("量产首件/样品首件 检验结果未出 ,不可巡检");
|
|
}
|
|
//送检时间排序最新一个 单子, 此单有任意一行不合格就算不合格
|
|
string lastTransNo = drsShoujian[0]["TransNO"].ToString();
|
|
var drs_lastTransNo = drsShoujian.Where(a => a.Field<string>("TransNO") == lastTransNo);
|
|
foreach (DataRow item in drs_lastTransNo)
|
|
{
|
|
string lastResSj = drsShoujian[0]["Status"].ToString();
|
|
if (lastResSj != "正常" && lastResSj != "放行")
|
|
{
|
|
throw new Exception("最后一次 [量产首件/样品首件] " + lastTransNo + ", 不合格, 不可巡检");
|
|
}
|
|
}
|
|
}
|
|
|
|
//2.Create
|
|
ICSLOTONWIPInspection info = new ICSLOTONWIPInspection();
|
|
info.ID = AppConfig.GetGuid();
|
|
info.DetailID = wipDetID;
|
|
info.CheckMode = "巡检";
|
|
info.UserCode = AppConfig.UserCode;
|
|
info.Quantity = CurrentQTY;
|
|
info.WorkPoint = AppConfig.WorkPointCode;
|
|
info.MTIME = DateTime.Now;
|
|
info.MUSER = AppConfig.UserCode;
|
|
info.MUSERName = AppConfig.UserName;
|
|
info.IsCalc = true;
|
|
info.EATTRIBUTE1 = "巡检";
|
|
ICSLOTONWIPInspectionBLL.Add(info, AppConfig.AppConnectString);
|
|
return info.ID;
|
|
}
|
|
|
|
private void grvDetail_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
|
|
{
|
|
//try
|
|
//{
|
|
// int hand = e.RowHandle;
|
|
// if (hand < 0)
|
|
// return;
|
|
// if (Convert.ToBoolean(grvDetail.GetRowCellValue(hand, colTop)))
|
|
// {
|
|
// e.Appearance.BackColor = Color.Yellow;// 改变行背景颜色
|
|
// }
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
|
|
//}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|