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.
2167 lines
103 KiB
2167 lines
103 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using ICSSoft.Frame.User.BLL;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using System.Data.SqlClient;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Base.Lable.PrintTool;
|
|
using ICSSoft.Frame.Data.DAL;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Reflection;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.Data.Filtering;
|
|
using DevExpress.XtraEditors.Repository;
|
|
using System.Net;
|
|
using System.IO;
|
|
using ICSSoft.Entity.PU_AppVouch;
|
|
using System.Configuration;
|
|
using Newtonsoft.Json;
|
|
using ICSSoft.Frame.Data.Entity.WWModel;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSMO2UserSend : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
static string APIURL = System.Configuration.ConfigurationSettings.AppSettings["APIURL"].ToString();
|
|
static string DataCollectWW = APIURL + "APICreateInventory_PU_AppVouch";
|
|
private string sqltxt = "";
|
|
private string sqlconn = "";
|
|
String guid = AppConfig.GetGuid();
|
|
private DataTable dataUser = null;
|
|
private DataTable data = null;
|
|
private DataTable dtSend = null;
|
|
private DataTable _dtSend = null;
|
|
private bool isQueryCloseUp = false;
|
|
private bool isQueryCloseUpEQP = false;
|
|
//WorkPointBLL workBll = new WorkPointBLL();
|
|
|
|
#region 构造函数
|
|
public FormICSMO2UserSend(string MOID)
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
txtPlanDate.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString();
|
|
SearchMO(MOID);
|
|
//SearchItemLotInfo(MOID);
|
|
}
|
|
#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 SystemOptition
|
|
/// <summary>
|
|
/// 操作权限
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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(btnSave);
|
|
ControlList.Add(btnSelect);
|
|
ControlList.Add(btnCanSelect);
|
|
ControlList.Add(txtcancelSend);
|
|
ControlList.Add(btnPrint);
|
|
ControlList.Add(btnOutPut);
|
|
ControlList.Add(btnFalsh);
|
|
ControlList.Add(btnSavePRWW);
|
|
ControlList.Add(btnExit);
|
|
//ControlList.Add(btnDelLable);
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// 数据权限
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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 string tempTableName = "";
|
|
//private void btnFilter_Click(object sender, EventArgs e)
|
|
//{
|
|
// FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
|
|
// filter.OldTempTableName = tempTableName;
|
|
// if (filter.ShowDialog() == DialogResult.OK)
|
|
// {
|
|
// DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
|
|
// try
|
|
// {
|
|
// _wait.Show();
|
|
// tempTableName = filter.NewTempTableName;
|
|
// sqltxt = filter.SqlText;
|
|
// sqlconn = filter.FilterConnectString;
|
|
// dataSource = filter.FilterData.Tables[0];
|
|
// grdDetail.DataSource = dataSource;
|
|
// grvDetail.BestFitColumns();
|
|
// rptPage.RecordNum = dataSource.Rows.Count;
|
|
// rptPage.PageSize = 500;
|
|
// rptPage.PageIndex = 1;
|
|
// rptPage.ReLoad();
|
|
// _wait.Close();
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
// _wait.Close();
|
|
// }
|
|
// }
|
|
//}
|
|
//#endregion
|
|
|
|
#region 全选
|
|
private void btnSelect_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
gridView1.SetRowCellValue(i, colisSelect, "Y");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 全消
|
|
private void btnCanSelect_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
gridView1.SetRowCellValue(i, colisSelect, "");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 刷新
|
|
private void btnFalsh_Click(object sender, EventArgs e)
|
|
{
|
|
FormICSFACTORY_Load(null, null);
|
|
}
|
|
#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 gridView1_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (gridView1.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
if (gridView1.FocusedColumn == colisSelect)
|
|
{
|
|
if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colisSelect).ToString() == "")
|
|
{
|
|
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, colisSelect, "Y");
|
|
}
|
|
else
|
|
{
|
|
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, colisSelect, "");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
//#region 绑定数据源
|
|
//private void btnConfig_Click(object sender, EventArgs e)//绑定数据源
|
|
//{
|
|
// if (AppConfig.UserCode.ToLower() != "demo")
|
|
// {
|
|
// //ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
|
|
// return;
|
|
// }
|
|
// FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
|
|
// fdata.ShowDialog();
|
|
//}
|
|
//#endregion
|
|
|
|
#region 加载
|
|
private void FormICSFACTORY_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
List<string> LotNo2 = new List<string>();
|
|
string sql = @"SELECT '' AS [isSelect], LOTNO AS LOTNO, EATTRIBUTE7 AS VenderLotNO, EATTRIBUTE6 AS LotNo2
|
|
FROM ICSITEMLot WHERE TransNO = '{0}' AND TransLine = '{1}' ORDER BY LOTNO ";
|
|
sql = string.Format(sql, txtMOCODE.Text, txtMOSEQ.Text);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
#region add by summer 2020.06.17
|
|
if (dt.Rows.Count > 0 && dt != null)
|
|
{
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
if (dr["LotNo2"].ToString() != "")
|
|
{
|
|
if (LotNo2.Contains(dr["LotNo2"].ToString()))
|
|
{
|
|
throw new Exception("扫描批次栏位存在重复值,重复值:" + dr["LotNo2"].ToString());
|
|
}
|
|
else
|
|
{
|
|
LotNo2.Add(dr["LotNo2"].ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
gridControl1.DataSource = dt;
|
|
gridView1.BestFitColumns();
|
|
BindCustomDrawRowIndicator(gridView1);
|
|
|
|
string sql2 = "";
|
|
#region
|
|
// sql2 = @" SELECT
|
|
// '' AS [isSelect],
|
|
// '' AS ID,
|
|
// c.OPCODE AS OPCODE,
|
|
// c.OPSEQ AS OPSEQ,
|
|
// d.OPDESC AS OPDESC,
|
|
// '' AS USERCODE,
|
|
// '' AS USERName,
|
|
// '' AS EQPCode,
|
|
// '' AS EQPName,
|
|
// '' AS MUSERName,
|
|
// '' AS MTIME,--e.EQPTypeCode AS EQPType,
|
|
// getdate() AS StartPlanDate, getdate() AS EndPlanDate
|
|
// FROM
|
|
// ICSMO a
|
|
// LEFT JOIN ICSMO2ROUTE b ON a.MOCODE=b.MOCODE
|
|
// LEFT JOIN ICSITEMROUTE2OP c ON b.ROUTECODE=c.ROUTECODE and a.ITEMCODE=c.ITEMCODE
|
|
// LEFT JOIN ICSOP d ON c.OPID = d.ID
|
|
// --LEFT JOIN ICSEQPSTP e ON c.ITEMCODE=e.ITEMCODE AND c.OPCODE=e.OPCODE AND e.ISREF='是'
|
|
// WHERE
|
|
// a.MOCODE = '{0}' AND a.MOSEQ='{1}'
|
|
// ORDER BY c.OPSEQ";
|
|
#endregion
|
|
//20190716ZM 是否委外
|
|
sql2 = @" SELECT
|
|
'' AS [isSelect],
|
|
'' AS ID,
|
|
c.OPCODE AS OPCODE,
|
|
c.OPSEQ AS OPSEQ,
|
|
d.OPDESC AS OPDESC,
|
|
'' AS USERCODE,
|
|
'' AS USERName,
|
|
'' AS EQPCode,
|
|
'' AS EQPName,
|
|
'' AS MUSERName,
|
|
'' AS MTIME,--e.EQPTypeCode AS EQPType,
|
|
CAST(ISNULL(b.EATTRIBUTE1, 0) AS BIT) as EATTRIBUTE1,
|
|
getdate() AS StartPlanDate, getdate() AS EndPlanDate
|
|
FROM
|
|
ICSMO a
|
|
LEFT JOIN ICSMO2ROUTE b ON a.MOCODE=b.MOCODE
|
|
LEFT JOIN ICSITEMROUTE2OP c ON b.ROUTECODE=c.ROUTECODE and a.ITEMCODE=c.ITEMCODE
|
|
LEFT JOIN ICSOP d ON c.OPID = d.ID
|
|
--LEFT JOIN ICSEQPSTP e ON c.ITEMCODE=e.ITEMCODE AND c.OPCODE=e.OPCODE AND e.ISREF='是'
|
|
WHERE
|
|
a.MOCODE = '{0}' AND a.MOSEQ='{1}'
|
|
ORDER BY c.OPSEQ";
|
|
sql2 = string.Format(sql2, txtMOCODE.Text, txtMOSEQ.Text);
|
|
dtSend = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql2).Tables[0];
|
|
#region
|
|
// if (dtSend.Rows.Count != 0)
|
|
// {
|
|
// if (dtSend.Rows[0]["OPCODE"].ToString() == "")
|
|
// {
|
|
// sql2 = @" SELECT
|
|
// '' AS [isSelect],
|
|
// '' AS ID,
|
|
// c.OPCODE AS OPCODE,
|
|
// c.OPSEQ AS OPSEQ,
|
|
// d.OPDESC AS OPDESC,
|
|
// '' AS USERCODE,
|
|
// '' AS USERName,
|
|
// '' AS EQPCode,
|
|
// '' AS EQPName,
|
|
// '' AS MUSERName,
|
|
// '' AS MTIME,f.EQPTypeCode AS EQPType,
|
|
// getdate() AS SendPlanDate
|
|
// FROM
|
|
// ICSMO a
|
|
// LEFT JOIN ICSMO2ROUTE b ON a.MOCODE=b.MOCODE
|
|
// LEFT JOIN Base_Inventory e ON a.ITEMCODE=e.ItemCode
|
|
// LEFT JOIN ICSMODELROUTE2OP c ON b.ROUTECODE=c.ROUTECODE and e.ItemMainCategoryCode=c.MODELCODE
|
|
// LEFT JOIN ICSOP d ON c.OPID = d.ID
|
|
// LEFT JOIN ICSEQPSTP f ON e.ITEMCODE=f.ITEMCODE AND c.OPCODE=f.OPCODE
|
|
// AND f.ISREF='是'
|
|
// WHERE
|
|
// a.MOCODE = '{0}'
|
|
// ORDER BY c.OPSEQ";
|
|
// sql2 = string.Format(sql2, txtMOCODE.Text);
|
|
// dtSend = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql2).Tables[0];
|
|
// }
|
|
// }
|
|
#endregion
|
|
//20190731ZM
|
|
grdDetail.DataSource = null;// dtSend;
|
|
grvDetail.BestFitColumns();
|
|
//BoundData();
|
|
BoundEQPData();
|
|
BoundGridLookUpData();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据源
|
|
private void SearchMO(string MOID)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"
|
|
SELECT A.MOCODE AS MOCODE, A.MOSEQ AS MOSEQ, '' AS SEGCODE,
|
|
A.MOVER AS ProjectCode, A.MOPLANQTY AS MOPLANQTY, A.MOPLANSTARTDATE AS MOPLANSTARTDATE,
|
|
A.MOPLANENDDATE AS MOPLANENDDATE, B.ROUTECODE AS RouteCode,
|
|
A.ITEMCODE AS ITEMCODE, C.INVNAME AS ItemName FROM ICSMO A
|
|
LEFT JOIN ICSMO2ROUTE B ON A.ID = B.MOID --LEFT JOIN ICSMO2ROUTE B ON A.MOCODE = B.MOCODE --BY SUMMER 2020.06.17
|
|
LEFT JOIN ICSINVENTORY c ON a.ITEMCODE = c.INVCODE
|
|
GROUP BY A.ID, A.MOCODE, A.MOSEQ, A.MOVER, A.MOPLANQTY, A.MOPLANSTARTDATE,
|
|
A.MOPLANENDDATE, B.ROUTECODE, A.ITEMCODE, C.INVNAME
|
|
HAVING A.ID = '{0}' ";
|
|
sql = string.Format(sql, MOID);
|
|
SqlDataReader rd = DBHelper.ExecuteReader(AppConfig.AppConnectString, CommandType.Text, sql);
|
|
|
|
while (rd.Read())
|
|
{
|
|
txtMOSEQ.Text = rd["MOSEQ"].ToString();
|
|
txtMOCODE.Tag = rd["MOCODE"].ToString();
|
|
txtProjectCode.Tag = rd["SEGCODE"].ToString();
|
|
txtMOCODE.Text = rd["MOCODE"].ToString();
|
|
txtProjectCode.Text = rd["ProjectCode"].ToString();
|
|
txtMOPLANQTY.Text = rd["MOPLANQTY"].ToString();
|
|
txtMOPLANSTARTDATE.Text = rd["MOPLANSTARTDATE"].ToString();
|
|
txtMOPLANENDDATE.Text = rd["MOPLANENDDATE"].ToString();
|
|
txtRouteCode.Text = rd["RouteCode"].ToString();
|
|
txtITEMCODE.Text = rd["ITEMCODE"].ToString();
|
|
txtItemName.Text = rd["ItemName"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void SearchItemLotInfo(string MOID)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select LOTNO,LOTQTY
|
|
from ICSITEMLot a
|
|
INNER JOIN ICSMO b ON a.TransNO=b.MOCODE AND a.TransLine=b.MOSEQ
|
|
where b.ID = '{0}' order by LOTNO";
|
|
sql = string.Format(sql, MOID);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
|
|
//txtLOTNO.DisplayMember = "LOTNO"; //显示名称
|
|
//txtLOTNO.ValueMember = "LOTQTY"; //value 值
|
|
//txtLOTNO.DataSource = data.DefaultView;
|
|
|
|
//if (txtLOTNO.Items.Count > 0)
|
|
//{
|
|
// txtLOTNO.SelectedIndex = 0;
|
|
//}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
//20190807ZM
|
|
RepositoryItem _disabledItem;
|
|
private void grvDetail_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
|
|
{
|
|
//ONWIP
|
|
//if (e.Column == OPSEQ || e.Column == OPCODE)
|
|
if (e.Column == colEATTRIBUTE1)
|
|
{
|
|
if (_disabledItem == null)
|
|
{
|
|
_disabledItem = (RepositoryItem)e.RepositoryItem.Clone();
|
|
_disabledItem.ReadOnly = true;
|
|
_disabledItem.Enabled = false;
|
|
}
|
|
//满足条件,设置成只读
|
|
if (Convert.ToBoolean(grvDetail.GetRowCellValue(e.RowHandle, colONWIP)))
|
|
{
|
|
e.RepositoryItem = _disabledItem;
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 保存
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
/*20190722ZM
|
|
* 1、全选批量派工保存时,以一第一条批次信息为准,当有的批次关联的工序和第一条有差异时,提示出来
|
|
* 2、只要考虑左侧的其中一个批次和右侧加载出的数据是否一致
|
|
*/
|
|
string lotno = "";
|
|
List<string> lotnoList = new List<string>();
|
|
List<FormICSMO2UserUIModel> MO2UserInfoList = new List<FormICSMO2UserUIModel>();
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
lotno = gridView1.GetRowCellValue(i, colLOTNO).ToString();
|
|
lotnoList.Add(lotno);
|
|
}
|
|
}
|
|
if (lotnoList.Count < 1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择需要下发的产品跟踪单号!!!");
|
|
return;
|
|
}
|
|
List<string> strList = new List<string>();
|
|
List<string> _strList = new List<string>();
|
|
//20190722ZM
|
|
if (lotnoList.Count > 0)
|
|
{
|
|
//string str0 = string.Empty;
|
|
bool isEqually = false;
|
|
string _str = string.Empty;
|
|
foreach (var item in lotnoList)
|
|
{
|
|
string str = string.Empty;
|
|
str = GetStrByLotNo(item);
|
|
strList.Add(str);
|
|
}
|
|
if (strList != null && strList.Count > 0)
|
|
{
|
|
for (int i = 0; i < strList.Count; i++)
|
|
{
|
|
if (strList[0].CompareTo(strList[i]) == 0)
|
|
{
|
|
isEqually = true;
|
|
}
|
|
else
|
|
{
|
|
isEqually = false;
|
|
_str += lotnoList[i].ToString() + " ";
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(_str))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(_str + "批次关联工序不一致,不能批量保存!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
//colEATTRIBUTE1委外
|
|
if (lotnoList.Count > 0)
|
|
{
|
|
bool isEqually = false;
|
|
string _str_ = string.Empty;
|
|
foreach (var item in lotnoList)
|
|
{
|
|
string str = string.Empty;
|
|
str = GetStrWWByLotNo(item);
|
|
_strList.Add(str);
|
|
}
|
|
if (_strList != null && _strList.Count > 0)
|
|
{
|
|
for (int i = 0; i < _strList.Count; i++)
|
|
{
|
|
if (_strList[0].CompareTo(_strList[i]) == 0)
|
|
{
|
|
isEqually = true;
|
|
}
|
|
else
|
|
{
|
|
isEqually = false;
|
|
_str_ += lotnoList[i].ToString() + " ";
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(_str_))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(_str_ + "批次关联是否委外不一致,不能批量保存!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
//只要考虑左侧的其中一个批次和右侧加载出的数据是否一致20190722ZM
|
|
|
|
string strrr = string.Empty;
|
|
strrr = GetStrByLotNo(lotnoList[0].ToString());
|
|
string _strrr = string.Empty;
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
string _OPCODE = string.Empty;
|
|
string _OPSEQ = string.Empty;
|
|
_OPCODE = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
|
|
_OPSEQ = grvDetail.GetRowCellValue(i, colOPSEQ).ToString();
|
|
_strrr += _OPCODE + _OPSEQ;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(strrr))
|
|
{
|
|
if (strrr.CompareTo(_strrr) != 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("批次关联工序和右侧列表工序不一致,不能保存!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
for (int j = 0; j < lotnoList.Count; j++)
|
|
{
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
FormICSMO2UserUIModel MO2UserInfo = new FormICSMO2UserUIModel();
|
|
MO2UserInfo.ID = grvDetail.GetRowCellValue(i, colID).ToString();
|
|
MO2UserInfo.MOCODE = txtMOCODE.Text.ToString();
|
|
//MO2UserInfo.MOSEQ = Convert.ToInt32(txtMOCODE.Tag.ToString());
|
|
MO2UserInfo.MOSEQ = Convert.ToInt32(txtMOSEQ.Text.ToString());
|
|
|
|
MO2UserInfo.LOTNO = lotnoList[j];
|
|
MO2UserInfo.SEGCODE = txtProjectCode.Tag.ToString();
|
|
MO2UserInfo.RouteCode = txtRouteCode.Text.ToString();
|
|
MO2UserInfo.OPCODE = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
|
|
MO2UserInfo.USERCODE = grvDetail.GetRowCellValue(i, colUSERCODE).ToString();
|
|
MO2UserInfo.USERName = grvDetail.GetRowCellValue(i, colUSERName).ToString();
|
|
MO2UserInfo.EQPCode = grvDetail.GetRowCellValue(i, colEQPCode).ToString();
|
|
MO2UserInfo.EQPName = grvDetail.GetRowCellValue(i, colEQPName).ToString();
|
|
MO2UserInfo.MUSER = AppConfig.UserCode;
|
|
MO2UserInfo.MUSERName = AppConfig.UserName;
|
|
MO2UserInfo.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
MO2UserInfo.WorkPoint = AppConfig.WorkPointCode;
|
|
|
|
string colPRLine_ = grvDetail.GetRowCellValue(i, colPRLine).ToString();
|
|
if (!string.IsNullOrWhiteSpace(colPRLine_))
|
|
{
|
|
if (colPRLine_ == "False" || colPRLine_ == "0")
|
|
{
|
|
MO2UserInfo.PRLineID = null;
|
|
}
|
|
else
|
|
{
|
|
string sql = @"select TOP 50 PRLineID,* from ICSMO2User where MOCODE='" + MO2UserInfo.MOCODE + "' AND LOTNO='" + lotnoList[j] + "' AND OPCODE='" + MO2UserInfo.OPCODE + "'";
|
|
DataTable dtPRLine = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if (dtPRLine != null && dtPRLine.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow item in dtPRLine.Rows)
|
|
{
|
|
MO2UserInfo.PRLineID = item["PRLineID"].ToString();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
if (grvDetail.GetRowCellValue(i, colEATTRIBUTE1).ToString() == "True")
|
|
{
|
|
MO2UserInfo.EATTRIBUTE1 = "1";
|
|
//2020.06.23 summer
|
|
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colStartPlanDate).ToString()))
|
|
{
|
|
MO2UserInfo.StartPlanDate = Convert.ToDateTime(grvDetail.GetRowCellValue(i, colStartPlanDate).ToString());
|
|
}
|
|
else
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("预计开工日期不能为空");
|
|
return;
|
|
}
|
|
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colEndPlanDate).ToString()))
|
|
{
|
|
MO2UserInfo.EndPlanDate = Convert.ToDateTime(grvDetail.GetRowCellValue(i, colEndPlanDate).ToString());
|
|
}
|
|
else
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("预下机日期不能为空");
|
|
return;
|
|
}
|
|
if (DateTime.Compare(Convert.ToDateTime(grvDetail.GetRowCellValue(i, colStartPlanDate).ToString()).Date, Convert.ToDateTime(grvDetail.GetRowCellValue(i, colEndPlanDate).ToString()).Date) > 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("下机时间不能早于开工时间");
|
|
return;
|
|
}
|
|
//if (DateTime.Compare(Convert.ToDateTime(grvDetail.GetRowCellValue(i, colStartPlanDate).ToString()).Date, DateTime.Now.Date) < 0)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("预开工时间不能早于当前时间");
|
|
// return;
|
|
//}
|
|
|
|
}
|
|
else
|
|
{
|
|
MO2UserInfo.EATTRIBUTE1 = "0";
|
|
//2020.06.23 summer
|
|
if (!string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(i, colStartPlanDate).ToString()))
|
|
MO2UserInfo.StartPlanDate = Convert.ToDateTime(grvDetail.GetRowCellValue(i, colStartPlanDate).ToString());
|
|
if (!string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(i, colEndPlanDate).ToString()))
|
|
MO2UserInfo.EndPlanDate = Convert.ToDateTime(grvDetail.GetRowCellValue(i, colEndPlanDate).ToString());
|
|
MO2UserInfo.PRLineID = null;
|
|
}
|
|
#region 2020.06.23 summer
|
|
//MO2UserInfo.EATTRIBUTE1 = grvDetail.GetRowCellValue(i, colEATTRIBUTE1).ToString();//20190717ZM
|
|
//if (!string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(i, colStartPlanDate).ToString()))
|
|
// MO2UserInfo.StartPlanDate = Convert.ToDateTime(grvDetail.GetRowCellValue(i, colStartPlanDate).ToString());
|
|
//if (!string.IsNullOrWhiteSpace(grvDetail.GetRowCellValue(i, colEndPlanDate).ToString()))
|
|
// MO2UserInfo.EndPlanDate = Convert.ToDateTime(grvDetail.GetRowCellValue(i, colEndPlanDate).ToString());
|
|
#endregion
|
|
MO2UserInfoList.Add(MO2UserInfo);
|
|
#region
|
|
//if (string.IsNullOrEmpty(MO2UserInfo.EQPCode) || string.IsNullOrEmpty(MO2UserInfo.EQPName))
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("设备编号、设备名称 均不能为空!");
|
|
// return;
|
|
//}
|
|
#endregion
|
|
}
|
|
}
|
|
try
|
|
{
|
|
ICSMO2UserBLL.Add(MO2UserInfoList, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox(0, "保存成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
btnFalsh_Click(null, null);
|
|
}
|
|
#endregion
|
|
|
|
#region 20190722ZM
|
|
public static string GetStrByLotNo(string lotNo)
|
|
{
|
|
string str = string.Empty;
|
|
DataTable _dtSend = null;
|
|
string _sql = @"SELECT DISTINCT
|
|
d.OPCODE AS OPCODE,
|
|
d.OPSEQ AS OPSEQ
|
|
FROM
|
|
ICSMO a
|
|
LEFT JOIN ICSMO2ROUTE b ON a.ID = b.MOID
|
|
LEFT JOIN ICSITEMLot c ON a.MOCODE = c.TransNO
|
|
AND a.MOSEQ = c.TransLine
|
|
LEFT JOIN ICSITEMROUTE2OPLot d ON b.ROUTECODE = d.ROUTECODE
|
|
AND c.LotNO = d.LotNo
|
|
AND a.ITEMCODE = d.ITEMCODE
|
|
WHERE
|
|
c.LOTNO = '" + lotNo + "' ORDER BY d.OPSEQ ";
|
|
_sql = string.Format(_sql);
|
|
_dtSend = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _sql).Tables[0];
|
|
if (_dtSend != null && _dtSend.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow item in _dtSend.Rows)
|
|
{
|
|
str += item["OPCODE"].ToString() + item["OPSEQ"].ToString();
|
|
}
|
|
}
|
|
return str;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region MyRegion
|
|
public static string GetStrWWByLotNo(string lotNo)
|
|
{
|
|
string str = string.Empty;
|
|
DataTable _dtSend = null;
|
|
string _sql = @" SELECT DISTINCT
|
|
CAST (
|
|
ISNULL(f.EATTRIBUTE1, 0) AS BIT
|
|
) AS EATTRIBUTE1,
|
|
d.OPCODE AS OPCODE
|
|
FROM
|
|
ICSMO a
|
|
LEFT JOIN ICSMO2ROUTE b ON a.ID = b.MOID
|
|
LEFT JOIN ICSITEMLot c ON a.MOCODE = c.TransNO
|
|
AND a.MOSEQ = c.TransLine
|
|
LEFT JOIN ICSITEMROUTE2OPLot d ON b.ROUTECODE = d.ROUTECODE AND c.LotNO=d.LotNo
|
|
AND a.ITEMCODE = d.ITEMCODE
|
|
LEFT JOIN ICSOP e ON d.OPCODE = e.OPCODE
|
|
LEFT JOIN ICSMO2User f ON e.OPCODE = f.OPCODE
|
|
AND c.LOTNO = f.LOTNO
|
|
WHERE
|
|
c.LOTNO = '"+lotNo+"' ORDER BY d.OPCODE ";
|
|
_sql = string.Format(_sql);
|
|
_dtSend = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _sql).Tables[0];
|
|
if (_dtSend != null && _dtSend.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow item in _dtSend.Rows)
|
|
{
|
|
str += item["EATTRIBUTE1"].ToString() + item["OPCODE"].ToString();
|
|
}
|
|
}
|
|
return str;
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 删除
|
|
private void btnDel_Click(object sender, EventArgs e)
|
|
{
|
|
//SimpleButton btntemp = (SimpleButton)sender;
|
|
//if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
// return;
|
|
//}
|
|
|
|
List<string> IDList = new List<string>();
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
IDList.Add(grvDetail.GetRowCellValue(i, colID).ToString());
|
|
}
|
|
}
|
|
if (IDList.Count == 0 || IDList == null)
|
|
{
|
|
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
|
|
return;
|
|
|
|
}
|
|
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除吗?删除后无法恢复,确定吗?") != DialogResult.OK)
|
|
{
|
|
btnCanSelect_Click(sender, e);
|
|
return;
|
|
}
|
|
ICSMO2UserBLL.deleteInfo(IDList, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox("删除成功");
|
|
|
|
btnFalsh_Click(null, null);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 导出
|
|
private void btnOutPut_Click(object sender, EventArgs e)
|
|
{
|
|
FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
|
|
foe.ShowDialog();
|
|
}
|
|
#endregion
|
|
|
|
// #region 批号改变
|
|
// private void txtLOTNO_SelectedIndexChanged(object sender, EventArgs e)
|
|
// {
|
|
// txtLOTQTY.Text = txtLOTNO.SelectedValue.ToString();
|
|
// try
|
|
// {
|
|
// string sql = @" SELECT
|
|
// '' AS [isSelect],
|
|
// e.ID AS ID,
|
|
// b.OPCODE AS OPCODE,
|
|
// b.OPSEQ AS OPSEQ,
|
|
// d.OPDESC AS OPDESC,
|
|
// e.USERCODE AS USERCODE,
|
|
// e.USERName AS USERName,
|
|
// e.EQPCode AS EQPCode,
|
|
// e.EQPName AS EQPName,
|
|
// e.MUSERName AS MUSERName,
|
|
// e.MTIME AS MTIME
|
|
// FROM
|
|
// ICSMO a
|
|
// RIGHT JOIN ICSITEMROUTE2OP b ON a.ITEMCODE = b.ITEMCODE
|
|
// LEFT JOIN ICSMO2Lot c ON a.MOCODE = c.MOCODE
|
|
// LEFT JOIN ICSOP d ON b.OPID = d.ID
|
|
// LEFT JOIN ICSMO2User e ON b.OPCODE = e.OPCODE
|
|
// AND c.LOTNO = e.LOTNO
|
|
// WHERE
|
|
// c.LOTNO = '{0}'
|
|
// ORDER BY b.OPSEQ";
|
|
// sql = string.Format(sql, txtLOTNO.Text);
|
|
// DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
// grdDetail.DataSource = dt;
|
|
|
|
// sqltxt = sql;
|
|
// sqlconn = AppConfig.AppConnectString;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
// }
|
|
// }
|
|
// #endregion
|
|
|
|
#region 下发人员按钮
|
|
private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
string OPCODE = "";
|
|
//if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "Y")
|
|
//{
|
|
OPCODE = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colOPCODE).ToString();
|
|
//}
|
|
//else
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("请选择当前数据后再进行编辑!!!");
|
|
// return;
|
|
//}
|
|
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = "select USERCODE as [人员代码],USERName as [人员名称] from dbo.ICSOP2User with(nolock) WHERE OPCODE='{0}'";
|
|
|
|
sql = string.Format(sql, OPCODE);
|
|
//object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
|
|
//if (obj == null)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
|
|
|
|
//}
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
FormDataRefer reForm = new FormDataRefer();
|
|
reForm.FormTitle = "人员信息";
|
|
DataTable menuData = data;
|
|
reForm.DataSource = menuData;
|
|
reForm.MSelectFlag = false;
|
|
reForm.RowIndexWidth = 35;
|
|
//reForm.HideCols.Add("设备ID");
|
|
reForm.FormWidth = 500;
|
|
reForm.FormHeight = 500;
|
|
//reForm.FilterKey = btn.Text;
|
|
//grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, dr["人员代码"].ToString());
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, dr["人员名称"].ToString());
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 设备编号按钮
|
|
private void repositoryItemButtonEdit2_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
//if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() != "Y")
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("请选择当前数据后再进行编辑!!!");
|
|
// return;
|
|
//}
|
|
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = "select EQPCode as [设备编号],EQPName as [设备名称] from dbo.ICSEquipment with(nolock)";
|
|
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
FormDataRefer reForm = new FormDataRefer();
|
|
reForm.FormTitle = "设备信息";
|
|
DataTable menuData = data;
|
|
reForm.DataSource = menuData;
|
|
reForm.MSelectFlag = false;
|
|
reForm.RowIndexWidth = 35;
|
|
//reForm.HideCols.Add("设备ID");
|
|
reForm.FormWidth = 500;
|
|
reForm.FormHeight = 500;
|
|
//reForm.FilterKey = btn.Text;
|
|
//grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPCode, dr["设备编号"].ToString());
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPName, dr["设备名称"].ToString());
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 详情按钮
|
|
private void repositoryItemButtonEdit3_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
string lotNO = "";
|
|
|
|
lotNO = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colLOTNO).ToString();
|
|
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
|
|
string sql = "";
|
|
DataTable dt = null;
|
|
sql = @" SELECT DISTINCT
|
|
'' AS [isSelect],
|
|
f.ID AS ID,
|
|
d.OPCODE AS OPCODE,
|
|
d.OPSEQ AS OPSEQ,
|
|
e.OPDESC AS OPDESC,
|
|
f.USERCODE AS USERCODE,
|
|
f.USERName AS USERName,
|
|
f.EQPCode AS EQPCode,
|
|
f.EQPName AS EQPName,
|
|
f.MUSERName AS MUSERName,
|
|
CAST (
|
|
ISNULL(f.EATTRIBUTE1, 0) AS BIT
|
|
) AS EATTRIBUTE1,
|
|
f.MTIME AS MTIME,
|
|
--g.EQPTypeCode AS EQPType,
|
|
f.StartPlanDate,
|
|
f.EndPlanDate,
|
|
CAST(CASE WHEN M.LotNO IS NULL THEN '0' ELSE '1' END AS BIT) AS ONWIP,
|
|
CAST(CASE WHEN (f.PRLineID IS NULL OR f.PRLineID='') THEN '0' ELSE '1' END AS BIT) AS PRLine
|
|
FROM
|
|
ICSMO a
|
|
LEFT JOIN ICSMO2ROUTE b ON a.ID = b.MOID
|
|
LEFT JOIN ICSITEMLot c ON a.MOCODE = c.TransNO
|
|
AND a.MOSEQ = c.TransLine -- LEFT JOIN ICSITEMROUTE2OP d ON b.ROUTECODE=d.ROUTECODE and a.ITEMCODE=d.ITEMCODE
|
|
LEFT JOIN ICSITEMROUTE2OPLot d ON b.ROUTECODE = d.ROUTECODE AND c.LotNO=d.LotNo
|
|
AND a.ITEMCODE = d.ITEMCODE
|
|
LEFT JOIN ICSOP e ON d.OPCODE = e.OPCODE
|
|
LEFT JOIN ICSMO2User f ON e.OPCODE = f.OPCODE
|
|
AND c.LOTNO = f.LOTNO
|
|
LEFT JOIN ICSEquipment k ON f.EQPCode = k.EQPCode
|
|
LEFT JOIN (SELECT LotNO,OPCODE FROM ICSLOTONWIP GROUP BY LotNO,OPCODE) M ON D.LotNO=M.LotNO AND D.OPCODE=M.OPCODE
|
|
WHERE
|
|
c.LOTNO = '{0}'
|
|
ORDER BY
|
|
d.OPSEQ ";
|
|
sql = string.Format(sql, lotNO);
|
|
dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
#region
|
|
// if (dt.Rows.Count != 0)
|
|
// {
|
|
// if (dt.Rows[0]["OPCODE"].ToString() == "")
|
|
// {
|
|
// sql = @" SELECT
|
|
// '' AS [isSelect],
|
|
// f.ID AS ID,
|
|
// d.OPCODE AS OPCODE,
|
|
// d.OPSEQ AS OPSEQ,
|
|
// e.OPDESC AS OPDESC,
|
|
// f.USERCODE AS USERCODE,
|
|
// f.USERName AS USERName,
|
|
// f.EQPCode AS EQPCode,
|
|
// f.EQPName AS EQPName,
|
|
// f.MUSERName AS MUSERName,
|
|
// f.MTIME AS MTIME,h.EQPTypeCode AS EQPType,
|
|
// f.SendPlanDate as SendPlanDate
|
|
// FROM
|
|
// ICSMO a
|
|
// LEFT JOIN ICSMO2ROUTE b ON a.MOCODE = b.MOCODE
|
|
// LEFT JOIN ICSMO2Lot c ON a.MOCODE = c.MOCODE
|
|
// LEFT JOIN Base_Inventory g ON a.ITEMCODE = g.ItemCode
|
|
// LEFT JOIN ICSMODELROUTE2OP d ON b.ROUTECODE=d.ROUTECODE and g.ItemMainCategoryCode=d.MODELCODE
|
|
//
|
|
// LEFT JOIN ICSOP e ON d.OPCODE = e.OPCODE
|
|
// LEFT JOIN ICSMO2User f ON e.OPCODE = f.OPCODE AND c.LOTNO = f.LOTNO
|
|
// LEFT JOIN ICSEquipment k on f.EQPCode = k.EQPCode
|
|
// LEFT JOIN ICSEQPSTP h ON g.ITEMCODE=h.ITEMCODE AND d.OPCODE=h.OPCODE And k.EType = h.EQPTypeCode
|
|
// WHERE
|
|
// c.LOTNO = '{0}'
|
|
// ORDER BY d.OPSEQ";
|
|
// sql = string.Format(sql, lotNO);
|
|
// dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
// }
|
|
// }
|
|
#endregion
|
|
grdDetail.DataSource = dt;
|
|
grvDetail.BestFitColumns();
|
|
}
|
|
#endregion
|
|
private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
|
|
{
|
|
List<string> lotList = new List<string>();
|
|
string sql = @" SELECT LOTNO FROM ICSMO2User WHERE MOCODE='{0}' ";
|
|
|
|
sql = string.Format(sql, txtMOCODE.Text);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dr1 in dt.Rows)
|
|
{
|
|
lotList.Add(dr1["LOTNO"].ToString());
|
|
}
|
|
}
|
|
int hand = e.RowHandle;
|
|
if (hand < 0)
|
|
return;
|
|
DataRow dr = this.gridView1.GetDataRow(hand);
|
|
if (dr == null)
|
|
return;
|
|
if (gridView1.GetRowCellValue(e.RowHandle, colLOTNO).ToString() != "")
|
|
{
|
|
if (lotList.Contains(gridView1.GetRowCellValue(e.RowHandle, colLOTNO).ToString()))
|
|
{
|
|
//e.Appearance.BackColor = Color.Blue;
|
|
e.Appearance.BackColor = Color.CornflowerBlue;
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 打开的子窗体
|
|
//private void BoundData()
|
|
//{
|
|
// try
|
|
// {
|
|
// string OPCODEs = "";
|
|
// for (int i = 0; i < grvDetail.DataRowCount; i++)
|
|
// {
|
|
// string OPCODE = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
|
|
// if (!string.IsNullOrEmpty(OPCODE))
|
|
// {
|
|
// OPCODEs += "'"+ OPCODE + "', ";
|
|
// }
|
|
// }
|
|
|
|
// string sql = "select OPCODE AS [工序代码], USERCODE as [人员代码],USERName as [人员名称] from dbo.ICSOP2User with(nolock)";
|
|
// if (!string.IsNullOrEmpty(OPCODEs))
|
|
// {
|
|
// OPCODEs = OPCODEs.Substring(0, OPCODEs.LastIndexOf(","));
|
|
// sql += " WHERE OPCODE IN (" + OPCODEs + ") ";
|
|
// }
|
|
// sql += " ORDER BY OPCODE,USERCODE";
|
|
// sql = string.Format(sql);
|
|
|
|
// dataUser = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
|
|
// if (dataUser != null)
|
|
// {
|
|
// int rows = dataUser.Rows.Count;
|
|
|
|
// //DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit repositoryItemLookUpEdit = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit();
|
|
|
|
// #region LookUpEdit
|
|
// repositoryItemLookUpEdit1.ValueMember = "人员代码";
|
|
// repositoryItemLookUpEdit1.DisplayMember = "人员代码";
|
|
// repositoryItemLookUpEdit1.DataSource = dataUser;
|
|
|
|
// repositoryItemLookUpEdit1.NullText = "";//空时的值
|
|
// repositoryItemLookUpEdit1.DropDownRows = 10;//下拉框行数
|
|
// repositoryItemLookUpEdit1.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
// repositoryItemLookUpEdit1.ValidateOnEnterKey = true;//回车确认
|
|
// repositoryItemLookUpEdit1.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoFilter;//自动过滤掉不需要显示的数据,可以根据需要变化
|
|
// repositoryItemLookUpEdit1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
// repositoryItemLookUpEdit1.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
|
|
// //自适应宽度
|
|
// repositoryItemLookUpEdit1.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
|
|
// //填充列
|
|
// repositoryItemLookUpEdit1.PopulateColumns();
|
|
|
|
// //控制选择项的总宽度
|
|
// repositoryItemLookUpEdit1.PopupWidth = 300;
|
|
// //设置列属性
|
|
// //repositoryItemLookUpEdit1.Columns["工序代码"].Visible = false;
|
|
|
|
// //列格式设置
|
|
// repositoryItemLookUpEdit1.Columns[0].FormatString = "000000";
|
|
|
|
// ////实现用户自由输入
|
|
// repositoryItemLookUpEdit1.ProcessNewValue += LookUpEdit1_ProcessNewValue;
|
|
|
|
// #endregion
|
|
// }
|
|
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
// }
|
|
//}
|
|
|
|
private void repositoryItemButtonEdit1_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
//ButtonEdit btn = (ButtonEdit)sender;
|
|
|
|
//string OPCODE = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colOPCODE).ToString();
|
|
//string UserCode = btn.Text.Trim();// grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString();
|
|
|
|
//string sql = "select USERCODE as [人员代码],USERName as [人员名称] from dbo.ICSOP2User with(nolock) WHERE OPCODE='{0}' AND USERCODE LIKE '%{1}%'";
|
|
//sql = string.Format(sql, OPCODE, UserCode);
|
|
|
|
//DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
|
|
//FormDataView reForm = new FormDataView(this);
|
|
//reForm.FormTitle = "人员信息";
|
|
//DataTable menuData = data;
|
|
//reForm.DataSource = menuData;
|
|
//reForm.MSelectFlag = false;
|
|
//reForm.RowIndexWidth = 35;
|
|
//reForm.FormWidth = 200;
|
|
//reForm.FormHeight = 200;
|
|
//Point p = Control.MousePosition;
|
|
//Control control = this.GetChildAtPoint(btn.Location); //检索位置指定位置的子控件
|
|
//Point clientPoint = control.PointToClient(System.Windows.Forms.Control.MousePosition); //将屏幕坐标点的位置计算称工作区域的位置
|
|
//Point screenPoint = control.PointToScreen(clientPoint); //将工作区域的位置计算吃呢个屏幕坐标的位置
|
|
//reForm.Location = pointToScreen(btn); //control.PointToClient(btn.Location);// System.Windows.Forms.Cursor.Position;
|
|
////reForm.Show();
|
|
////弹出图纸对话框
|
|
//ShowChildrenForm();
|
|
//reForm.HideCols.Add("选择");
|
|
//reForm.Show(this);
|
|
////if (reForm.ShowDialog() == DialogResult.OK)
|
|
////{
|
|
//// DataTable retData = reForm.ReturnData;
|
|
//// foreach (DataRow dr in retData.Rows)
|
|
//// {
|
|
//// grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, dr["人员代码"].ToString());
|
|
//// grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, dr["人员名称"].ToString());
|
|
//// }
|
|
////}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 实现用户自由输入
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
//private void LookUpEdit1_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e)
|
|
//{
|
|
// //DataRow Row;
|
|
// ////RepositoryItemLookUpEdit Edit = ((LookUpEdit)sender).Properties;
|
|
// //if (e.DisplayValue == null || this.repositoryItemLookUpEdit1.NullText.Equals(e.DisplayValue) || string.Empty.Equals(e.DisplayValue))
|
|
// // return;
|
|
// //Row = dataUser.NewRow();
|
|
// //Row["人员代码"] = e.DisplayValue;
|
|
// //dataUser.Rows.Add(Row);
|
|
// //e.Handled = true;
|
|
// if (!this.DesignMode)
|
|
// {
|
|
// DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit Edit = ((LookUpEdit)sender).Properties;
|
|
// string displayName = Edit.DisplayMember;
|
|
// string valueName = Edit.ValueMember;
|
|
// string display = e.DisplayValue.ToString();
|
|
|
|
// DataTable dtTemp = this.repositoryItemLookUpEdit1.DataSource as DataTable;
|
|
// if (dtTemp != null)
|
|
// {
|
|
// string OPCODE = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colOPCODE).ToString();
|
|
// DataRow[] selectedRows = dtTemp.Select(string.Format("{0}='{1}' AND {2}='{3}'", displayName, display.Replace("'", "‘"), "工序代码", OPCODE));
|
|
// if (selectedRows == null || selectedRows.Length == 0)
|
|
// {
|
|
// DataRow row = dtTemp.NewRow();
|
|
// row[displayName] = display;
|
|
// row[valueName] = display;
|
|
// dtTemp.Rows.Add(row);
|
|
// dtTemp.AcceptChanges();
|
|
// }
|
|
// }
|
|
|
|
// e.Handled = true;
|
|
// }
|
|
//}
|
|
|
|
//public void SetRowCellValue(DataTable retData)
|
|
//{
|
|
// foreach (DataRow dr in retData.Rows)
|
|
// {
|
|
// grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, dr["人员代码"].ToString());
|
|
// grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, dr["人员名称"].ToString());
|
|
// }
|
|
// //ShowChildrenForm();
|
|
//}
|
|
|
|
Point point = new Point(0, 0);
|
|
/// <summary>
|
|
/// 获取控件在屏幕中的位置
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
/// <returns></returns>
|
|
private Point pointToScreen(Control control)
|
|
{
|
|
point.Offset(control.Location);
|
|
var parent = control.Parent;
|
|
if (parent is Form)
|
|
{
|
|
return point;
|
|
}
|
|
else
|
|
{
|
|
pointToScreen(parent);
|
|
}
|
|
point.Offset(0, 10);
|
|
return point;
|
|
}
|
|
|
|
#region 判断是否有打开的子窗体
|
|
public void ShowChildrenForm()
|
|
{
|
|
//foreach (Form f1 in this.OwnedForms)
|
|
//{
|
|
// if (f1 is FormDataView)
|
|
// f1.Close();
|
|
//}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
private void BoundEQPData()
|
|
{
|
|
try
|
|
{
|
|
string sql = "select EQPCode as [设备编号],EQPName as [设备名称],Type as [设备类型] from dbo.ICSEquipment with(nolock) ORDER BY EQPCode";
|
|
|
|
sql = string.Format(sql);
|
|
|
|
data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
|
|
if (data != null)
|
|
{
|
|
int rows = data.Rows.Count;
|
|
|
|
repositoryItemGridLookUpEdit2.ValueMember = "设备编号";
|
|
repositoryItemGridLookUpEdit2.DisplayMember = "设备编号";
|
|
repositoryItemGridLookUpEdit2.DataSource = data;
|
|
|
|
repositoryItemGridLookUpEdit2.NullText = "";//空时的值
|
|
//repositoryItemGridLookUpEdit2.DropDownRows = 10;//下拉框行数
|
|
repositoryItemGridLookUpEdit2.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
repositoryItemGridLookUpEdit2.ValidateOnEnterKey = true;//回车确认
|
|
//repositoryItemGridLookUpEdit2.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoFilter;//自动过滤掉不需要显示的数据,可以根据需要变化
|
|
repositoryItemGridLookUpEdit2.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
repositoryItemGridLookUpEdit2.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
|
|
//自适应宽度
|
|
repositoryItemGridLookUpEdit2.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void BoundGridLookUpData()
|
|
{
|
|
try
|
|
{
|
|
string OPCODEs = "";
|
|
for (int i = 0; i < grvDetail.DataRowCount; i++)
|
|
{
|
|
string OPCODE = grvDetail.GetRowCellValue(i, colOPCODE).ToString();
|
|
if (!string.IsNullOrEmpty(OPCODE))
|
|
{
|
|
OPCODEs += "'" + OPCODE + "', ";
|
|
}
|
|
}
|
|
|
|
string sql = "select USERCODE as [人员代码],USERName as [人员名称] from Sys_User with(nolock)";
|
|
//string sql = "select OPCODE AS [工序代码], USERCODE as [人员代码],USERName as [人员名称] from dbo.ICSOP2User with(nolock)";
|
|
//if (!string.IsNullOrEmpty(OPCODEs))
|
|
//{
|
|
// OPCODEs = OPCODEs.Substring(0, OPCODEs.LastIndexOf(","));
|
|
// sql += " WHERE OPCODE IN (" + OPCODEs + ") ";
|
|
//}
|
|
//sql += " ORDER BY OPCODE,USERCODE";
|
|
//sql = string.Format(sql);
|
|
|
|
dataUser = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
|
|
if (dataUser != null)
|
|
{
|
|
int rows = dataUser.Rows.Count;
|
|
|
|
#region LookUpEdit
|
|
repositoryItemGridLookUpEdit1.ValueMember = "人员代码";
|
|
repositoryItemGridLookUpEdit1.DisplayMember = "人员代码";
|
|
repositoryItemGridLookUpEdit1.DataSource = dataUser;
|
|
|
|
repositoryItemGridLookUpEdit1.NullText = "";//空时的值
|
|
//repositoryItemGridLookUpEdit1.DropDownRows = 10;//下拉框行数
|
|
repositoryItemGridLookUpEdit1.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
repositoryItemGridLookUpEdit1.ValidateOnEnterKey = true;//回车确认
|
|
//repositoryItemGridLookUpEdit1.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoFilter;//自动过滤掉不需要显示的数据,可以根据需要变化
|
|
repositoryItemGridLookUpEdit1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
repositoryItemGridLookUpEdit1.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
|
|
//自适应宽度
|
|
repositoryItemGridLookUpEdit1.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定过滤条件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
private void FilterLookup(object sender)
|
|
{
|
|
try
|
|
{
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit == null)
|
|
return;
|
|
|
|
string OPCODE = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colOPCODE).ToString();
|
|
GridView gridView = edit.Properties.View as GridView;
|
|
FieldInfo fi = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
BinaryOperator op1 = new BinaryOperator("工序代码", OPCODE, BinaryOperatorType.Equal);
|
|
BinaryOperator op2 = new BinaryOperator("人员代码", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
|
|
string filterCondition = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] { op1, op2 }).ToString();
|
|
////BinaryOperator op3 = new BinaryOperator("Name", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
|
|
//string filterCondition = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] { op1, op2, op3 }).ToString();
|
|
fi.SetValue(gridView, filterCondition);
|
|
|
|
MethodInfo mi = gridView.GetType().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
mi.Invoke(gridView, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
//每次输入字符都会触发(在自动关联后面的字符串的情况下)
|
|
private void repositoryItemGridLookUpEdit1_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
|
|
{
|
|
BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
FilterLookup(sender);
|
|
}));
|
|
}
|
|
|
|
//对应的工序查询不到信息(输入框未自动关联后面的字符串)
|
|
private void repositoryItemGridLookUpEdit1_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
|
|
{
|
|
BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
FilterLookup(sender);
|
|
}));
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
FilterLookup(sender);
|
|
}));
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit1_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (isQueryCloseUp)
|
|
return;
|
|
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 OPCODE = RowView.Row["工序代码"].ToString();
|
|
//string USERCODE = RowView.Row["人员代码"].ToString();
|
|
string USERNAME = RowView.Row["人员名称"].ToString();
|
|
//if(OPCODE.Equals(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle,colOPCODE).ToString()))
|
|
//{
|
|
// //grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, USERCODE);
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, USERNAME);
|
|
//}
|
|
//else
|
|
//{
|
|
// // grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, "");
|
|
// grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, "");
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
//grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, "");
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit1_QueryCloseUp(object sender, CancelEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit.EditValue != null || edit.EditValue.ToString() != "" || edit.EditValue.ToString() != "nulltext")
|
|
{
|
|
var o = edit.Properties.View.GetDataRow(edit.Properties.View.FocusedRowHandle);
|
|
if (o is DataRow)
|
|
{
|
|
DataRow RowView = o as DataRow;
|
|
string OPCODE = RowView["工序代码"].ToString();
|
|
string USERCODE = RowView["人员代码"].ToString();
|
|
string USERNAME = RowView["人员名称"].ToString();
|
|
if (OPCODE.Equals(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colOPCODE).ToString()))
|
|
{
|
|
//grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, USERCODE);
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, USERNAME);
|
|
isQueryCloseUp = true;
|
|
}
|
|
else
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, "");
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, "");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, "");
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit2_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (isQueryCloseUpEQP)
|
|
return;
|
|
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 CODE = RowView.Row["设备类型"].ToString();
|
|
string EQPCode = RowView.Row["设备编号"].ToString();
|
|
string EQPName = RowView.Row["设备名称"].ToString();
|
|
|
|
//////grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPCode, EQPCode);
|
|
////grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPName, EQPName);
|
|
//////dtSend.Rows[grvDetail.FocusedRowHandle]["EQPCode"] = EQPCode;
|
|
//////dtSend.Rows[grvDetail.FocusedRowHandle]["EQPName"] = EQPName;
|
|
//string eqpcode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colEQPType).ToString();
|
|
//if (string.IsNullOrWhiteSpace(eqpcode) || CODE.Equals(eqpcode))
|
|
//{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPName, EQPName);
|
|
//}
|
|
//else
|
|
//{
|
|
// grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPName, "");
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
//grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPCode, "");
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPName, "");
|
|
//dtSend.Rows[grvDetail.FocusedRowHandle]["EQPName"] = "";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit1_QueryPopUp(object sender, CancelEventArgs e)
|
|
{
|
|
isQueryCloseUp = false;
|
|
}
|
|
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
FormICSProductTrackingList form = new FormICSProductTrackingList(txtMOCODE.Text.Trim(), txtMOSEQ.Text.Trim());
|
|
form.Show();
|
|
}
|
|
|
|
//取消派工
|
|
private void txtcancelSend_Click(object sender, EventArgs e)
|
|
{
|
|
string lotno = "";
|
|
List<string> lotnoList = new List<string>();
|
|
List<FormICSMO2UserUIModel> MO2UserInfoList = new List<FormICSMO2UserUIModel>();
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
lotno = gridView1.GetRowCellValue(i, colLOTNO).ToString();
|
|
lotnoList.Add(lotno);
|
|
}
|
|
|
|
}
|
|
if (lotnoList.Count < 1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择需要取消派工的产品跟踪单号!!!");
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
try
|
|
{
|
|
ICSMO2UserBLL.cancelSend(lotnoList, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox(0, "取消成功");
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
|
|
btnFalsh_Click(null, null);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定过滤条件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
private void FilterLookupEQP(object sender)
|
|
{
|
|
try
|
|
{
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit == null)
|
|
return;
|
|
|
|
string CODE = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colEQPType).ToString();
|
|
GridView gridView = edit.Properties.View as GridView;
|
|
FieldInfo fi = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
BinaryOperator op1 = new BinaryOperator("设备类型", CODE, BinaryOperatorType.Equal);
|
|
BinaryOperator op2 = new BinaryOperator("设备编号", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
|
|
string filterCondition = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] { op1, op2 }).ToString();
|
|
////BinaryOperator op3 = new BinaryOperator("Name", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
|
|
//string filterCondition = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] { op1, op2, op3 }).ToString();
|
|
fi.SetValue(gridView, filterCondition);
|
|
|
|
MethodInfo mi = gridView.GetType().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
mi.Invoke(gridView, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit2_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
FilterLookupEQP(sender);
|
|
}));
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit2_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
|
|
{
|
|
BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
FilterLookupEQP(sender);
|
|
}));
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit2_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
|
|
{
|
|
BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
FilterLookupEQP(sender);
|
|
}));
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit2_QueryCloseUp(object sender, CancelEventArgs e)
|
|
{
|
|
|
|
try
|
|
{
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit.EditValue != null || edit.EditValue.ToString() != "" || edit.EditValue.ToString() != "nulltext")
|
|
{
|
|
var o = edit.Properties.View.GetDataRow(edit.Properties.View.FocusedRowHandle);
|
|
if (o is DataRow)
|
|
{
|
|
DataRow RowView = o as DataRow;
|
|
string CODE = RowView["设备类型"].ToString();
|
|
string EQPCODE = RowView["设备编号"].ToString();
|
|
string EQPNAME = RowView["设备名称"].ToString();
|
|
string eqpcode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colEQPType).ToString();
|
|
if (string.IsNullOrWhiteSpace(eqpcode) || CODE.Equals(eqpcode))
|
|
{
|
|
//grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPCode, EQPCODE);
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPName, EQPNAME);
|
|
isQueryCloseUpEQP = true;
|
|
}
|
|
else
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPCode, "");
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPName, "");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPCode, "");
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPName, "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void repositoryItemGridLookUpEdit2_QueryPopUp(object sender, CancelEventArgs e)
|
|
{
|
|
isQueryCloseUpEQP = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 产生委外请购需求
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnSavePRWW_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定产生委外请购单吗?") != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在创建...请稍等...");
|
|
try
|
|
{
|
|
_wait.Show();
|
|
|
|
//工单工号
|
|
string MOCode = this.txtMOCODE.Text;
|
|
string ItemCode = this.txtITEMCODE.Text;
|
|
string MOSEQ = this.txtMOSEQ.Text;
|
|
//string sql = @"SELECT DISTINCT PRLineID from ICSMO2User WHERE MOCODE='" + MOCode + "' AND EATTRIBUTE1=1";
|
|
string lotNO = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colLOTNO).ToString();
|
|
|
|
string sql = @"SELECT DISTINCT PRLineID from ICSMO2User WHERE MOCODE='" + MOCode + "' AND LOTNO='" + lotNO + "' AND EATTRIBUTE1=1 and (PRLineID='' or PRLineID is null) ";
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dr1 in dt.Rows)
|
|
{
|
|
string PRLineID = dr1["PRLineID"].ToString();
|
|
if (!string.IsNullOrWhiteSpace(PRLineID))
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("该工单已经产生委外请购单,不能重复生成!!!");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
#region
|
|
// string sqlQty = @"SELECT
|
|
// a.MOCODE,
|
|
// b.ItemCode as ItemCode,
|
|
// a.OPCODE,
|
|
// COUNT (b.LOTQTY) AS PRQty
|
|
// FROM
|
|
// ICSMO2User a
|
|
// LEFT JOIN ICSITEMLot b ON a.LOTNO = b.LotNO
|
|
// WHERE
|
|
// a.MOCODE = '" + MOCode + "' AND b.ItemCode='" + ItemCode + "' AND a.MOSEQ='" + MOSEQ + "' AND a.EATTRIBUTE1 = 1 AND (a.PRLineID IS NULL or a.PRLineID='') GROUP BY a.MOCODE,a.OPCODE, b.ItemCode";
|
|
#endregion
|
|
|
|
#region 原SQL 2020.07.13 by summer
|
|
// string sqlQty = @"
|
|
//SELECT A.MOCODE, B.ItemCode AS ItemCode, A.OPCODE, D.OPDESC AS PRLineID, COUNT (B.LOTQTY) AS PRQty,
|
|
//ISNULL(A.StartPlanDate, GETDATE()) StartPlanDate, ISNULL(A.EndPlanDate, GETDATE()) EndPlanDate, A.LOTNO
|
|
//FROM ICSMO2User A LEFT JOIN ICSITEMLot B ON A.LOTNO = B.LotNO LEFT JOIN ICSOP D ON D.OPCODE = A.OPCODE
|
|
//WHERE A.MOCODE = '" + MOCode + "' AND B.ItemCode = '" + ItemCode + "' AND A.MOSEQ = '" + MOSEQ + @"' AND A.EATTRIBUTE1 = 1
|
|
//AND (A.PRLineID IS NULL OR A.PRLineID = '') GROUP BY A.MOCODE, A.OPCODE, B.ItemCode, D.OPDESC, A.StartPlanDate, A.EndPlanDate, A.LOTNO ";//UPDATE BY SUMMER 2020.06.17
|
|
#endregion
|
|
#region 现SQL 2020.07.13 by summer
|
|
string sqlQty = @"
|
|
SELECT A.MOCODE, B.ItemCode AS ItemCode, C.INVNAME, A.OPCODE, D.OPDESC AS PRLineID, COUNT (B.LOTQTY) AS PRQty,
|
|
ISNULL(MIN(A.StartPlanDate), GETDATE()) StartPlanDate, ISNULL(MAX(A.EndPlanDate), GETDATE()) EndPlanDate
|
|
FROM ICSMO2User A LEFT JOIN ICSITEMLot B ON A.LOTNO = B.LotNO LEFT JOIN ICSOP D ON D.OPCODE = A.OPCODE
|
|
LEFT JOIN ICSINVENTORY C ON B.ItemCode = C.INVCODE WHERE A.MOCODE = '" + MOCode + "' AND B.ItemCode = '" + ItemCode + @"'
|
|
AND A.MOSEQ = '" + MOSEQ + @"' AND A.EATTRIBUTE1 = 1 AND (A.PRLineID IS NULL OR A.PRLineID = '')
|
|
GROUP BY A.MOCODE, A.OPCODE, B.ItemCode, C.INVNAME, D.OPDESC ";//UPDATE BY SUMMER 2020.06.17
|
|
#endregion
|
|
DataTable dtQty = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlQty).Tables[0];
|
|
|
|
//ZM从配置中获取
|
|
string _EnumKey = "00010";
|
|
string sqlcInvCCode = @"SELECT DISTINCT EnumText from Sys_EnumValues WHERE EnumKey='" + _EnumKey + "' ";
|
|
|
|
DataTable dtcInvCCode = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlcInvCCode).Tables[0];
|
|
string _cInvCCode = string.Empty;
|
|
if (dtcInvCCode != null && dtcInvCCode.Rows.Count > 0)
|
|
{
|
|
_cInvCCode = dtcInvCCode.Rows[0][0].ToString();
|
|
}
|
|
|
|
List<PU_AppVouchs> contextsWWList = new List<PU_AppVouchs>();
|
|
List<PU_AppVouch> listcontextWW = new List<PU_AppVouch>();
|
|
|
|
if (dtQty != null && dtQty.Rows.Count > 0)
|
|
{
|
|
PU_AppVouch contextWW = new PU_AppVouch();
|
|
contextWW.UserCode = AppConfig.UserCode;
|
|
contextWW.UserName = AppConfig.UserName;
|
|
//contextWW.TargetAccount =AppConfig.GetDataBaseNameByConnectString(AppConfig.GetDataBaseConnectStringByKey("[]"));
|
|
contextWW.TargetAccount = ConfigurationManager.AppSettings["TargetAccountU8"];
|
|
foreach (DataRow _dr in dtQty.Rows)
|
|
{
|
|
PU_AppVouchs contextsWW = new PU_AppVouchs();
|
|
contextsWW.cInvCCode = _cInvCCode;//物料大类
|
|
contextsWW.cInvCode = _dr["ItemCode"].ToString();//料号
|
|
contextsWW.cInvName = _dr["INVNAME"].ToString();//料号名称
|
|
contextsWW.OPCode = _dr["OPCODE"].ToString();//工序
|
|
contextsWW.iQuantity = Decimal.Parse(_dr["PRQty"].ToString());
|
|
contextsWW.iNum = 0;// lotinfo.LOTQTY * Convert.ToDecimal(lotinfo.EATTRIBUTE3);
|
|
//contextsWW.cBatch = lotinfo.VenderLotNO;
|
|
contextsWW.MOCode = _dr["MOCODE"].ToString();//工单号
|
|
contextsWW.PRLine = _dr["PRLineID"].ToString();//工序
|
|
contextsWW.dArriveDate = Convert.ToDateTime(_dr["StartPlanDate"].ToString()).ToShortDateString();
|
|
contextsWW.dRequirDate = Convert.ToDateTime(_dr["EndPlanDate"].ToString()).ToShortDateString();
|
|
//contextsWW.LotNo = _dr["LOTNO"].ToString();//产品产品跟踪单号 2020.7.13 delete by summer
|
|
contextsWW.LotNo = "";//产品产品跟踪单号
|
|
contextsWWList.Add(contextsWW);
|
|
#region
|
|
//FormICSWWModel WWModel = new FormICSWWModel();
|
|
//WWModel.WWPRQty = Decimal.Parse(_dr["PRQty"].ToString());//委外的该工序所有的数量
|
|
////WWModel.ItemCode = _dr["ItemCode"].ToString(); //料号
|
|
////WWModel.OPCODE = _dr["OPCODE"].ToString();//工序
|
|
//WWModel.MCODEOPCODE = _dr["ItemCode"].ToString() + "_" + _dr["OPCODE"].ToString();
|
|
//list.Add(WWModel);
|
|
#endregion
|
|
}
|
|
contextWW.list = contextsWWList;
|
|
listcontextWW.Add(contextWW);
|
|
string WWPR = JsonConvert.SerializeObject(listcontextWW);
|
|
string iresultMO = HttpPost(DataCollectWW, WWPR);
|
|
U8Result INVINResultMO = new U8Result();
|
|
INVINResultMO = JsonConvert.DeserializeObject<U8Result>(iresultMO);
|
|
|
|
StringBuilder str = new StringBuilder();
|
|
str.AppendLine("创建U8委外请购单接口:" + WWPR);
|
|
str.AppendLine("接口返回结果:" + INVINResultMO.code);
|
|
str.AppendLine("接口返回数据:" + INVINResultMO.msg);
|
|
ICSMO2UserDAL.WriteLogFile(str.ToString(), "创建U8委外请购单接口");
|
|
|
|
if (INVINResultMO.code != "200")
|
|
{
|
|
//throw new Exception(INVINResultMO.msg);
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox(INVINResultMO.msg);
|
|
return;
|
|
}
|
|
List<PU_AppVouchs> _list = new List<PU_AppVouchs>();
|
|
if (!string.IsNullOrWhiteSpace(INVINResultMO.msg))
|
|
{
|
|
_list = JsonConvert.DeserializeObject<List<PU_AppVouchs>>(INVINResultMO.msg.ToString());
|
|
}
|
|
else
|
|
{
|
|
_wait.Close();
|
|
throw new Exception("未获取到请购单数据!");
|
|
}
|
|
|
|
#region add by summer 2020.10.22
|
|
string Lots = "";
|
|
string sqlLotNO = @"
|
|
SELECT A.MOCODE, B.ItemCode AS ItemCode, A.OPCODE, D.OPDESC AS PRLineID, COUNT (B.LOTQTY) AS PRQty,
|
|
ISNULL(A.StartPlanDate, GETDATE()) StartPlanDate, ISNULL(A.EndPlanDate, GETDATE()) EndPlanDate, A.LOTNO
|
|
FROM ICSMO2User A LEFT JOIN ICSITEMLot B ON A.LOTNO = B.LotNO LEFT JOIN ICSOP D ON D.OPCODE = A.OPCODE
|
|
WHERE A.MOCODE = '" + MOCode + "' AND B.ItemCode = '" + ItemCode + "' AND A.MOSEQ = '" + MOSEQ + @"' AND A.EATTRIBUTE1 = 1
|
|
AND (A.PRLineID IS NULL OR A.PRLineID = '') GROUP BY A.MOCODE, A.OPCODE, B.ItemCode, D.OPDESC, A.StartPlanDate, A.EndPlanDate, A.LOTNO ";
|
|
DataTable dtLotNO = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlLotNO).Tables[0];
|
|
if (dtLotNO.Rows.Count > 0 && dtLotNO != null)
|
|
{
|
|
foreach (DataRow dr in dtLotNO.Rows)
|
|
{
|
|
if (Lots == "")
|
|
{
|
|
Lots = "'" + dr["LOTNO"].ToString() + "'";
|
|
}
|
|
else
|
|
{
|
|
Lots += ", '" + dr["LOTNO"].ToString() + "'";
|
|
}
|
|
}
|
|
}
|
|
|
|
//U8返回的PR单行ID回写ICSMO2User表中PRLineID
|
|
foreach (var item in _list)
|
|
{
|
|
string UpdateSql = @"UPDATE ICSMO2User SET PRLineID='" + item.PRLine + "' WHERE MOCODE = '" + item.MOCode + "' AND OPCODE = '" + item.OPCode + "' AND MOSEQ = '" + MOSEQ + "' AND EATTRIBUTE1 = 1 AND LOTNO IN (" + Lots + ") ";
|
|
UpdateSql = string.Format(UpdateSql);
|
|
DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, UpdateSql);
|
|
}
|
|
#endregion
|
|
#region delete by summer 2020.10.22
|
|
////U8返回的PR单行ID回写ICSMO2User表中PRLineID
|
|
//foreach (var item in _list)
|
|
//{
|
|
// #region
|
|
// //string _MOCODE = string.Empty;
|
|
// //string _OPCODE = string.Empty;
|
|
// //if (!string.IsNullOrEmpty(item.MCODEOPCODE))
|
|
// //{
|
|
// // string[] sArray = item.MCODEOPCODE.Split('_');
|
|
// // _MOCODE = sArray[0];
|
|
// // _OPCODE = sArray[1];
|
|
// //}
|
|
// #endregion
|
|
// string UpdateSql = @"UPDATE ICSMO2User SET PRLineID='" + item.PRLine + "' WHERE MOCODE = '" + item.MOCode + "' AND OPCODE = '" + item.OPCode + "' AND MOSEQ = '" + MOSEQ + "' AND EATTRIBUTE1 = 1 ";//AND LOTNO = '" + item.LotNo + "' "; //update by summer 2020.07.13
|
|
// UpdateSql = string.Format(UpdateSql);
|
|
// DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, UpdateSql);
|
|
//}
|
|
#endregion
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("产生委外请购单成功!");
|
|
btnFalsh_Click(null, null);
|
|
}
|
|
else
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("没有委外的数据产生委外请购单!");
|
|
}
|
|
}
|
|
catch (Exception _ex)
|
|
{
|
|
_wait.Close();
|
|
throw new Exception(_ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.ToString());
|
|
}
|
|
}
|
|
|
|
public static string HttpPost(string url, string body)
|
|
{
|
|
try
|
|
{
|
|
Encoding encoding = Encoding.UTF8;
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
|
request.Method = "POST";
|
|
request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
|
|
request.ContentType = "application/json; charset=utf-8";
|
|
|
|
byte[] buffer = encoding.GetBytes(body);
|
|
request.ContentLength = buffer.Length;
|
|
request.GetRequestStream().Write(buffer, 0, buffer.Length);
|
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
|
|
{
|
|
return reader.ReadToEnd();
|
|
}
|
|
}
|
|
catch (WebException ex)
|
|
{
|
|
var res = (HttpWebResponse)ex.Response;
|
|
StringBuilder sb = new StringBuilder();
|
|
StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
|
|
sb.Append(sr.ReadToEnd());
|
|
throw new Exception(sb.ToString());
|
|
}
|
|
}
|
|
|
|
#region 解除绑定按钮
|
|
private void repositoryItemButtonEdit4_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string lotNO = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colLOTNO).ToString();
|
|
string sql1 = @"SELECT * FROM ICSLOTONWIP WHERE 1=1 AND LOTNO = '{0}' ";
|
|
sql1 = string.Format(sql1, lotNO);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql1).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("跟踪单有报过工,不能解除!!!");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
string sql = "UPDATE ICSITEMLot SET VenderLotNO = '', EATTRIBUTE7 = '', EATTRIBUTE6 = '' WHERE LotNO = '{0}' ";
|
|
sql = string.Format(sql, lotNO);
|
|
DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.ToString());
|
|
}
|
|
btnFalsh_Click(null, null);
|
|
}
|
|
#endregion
|
|
|
|
//扫描批次回车事件
|
|
private void gridView1_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
////sender as GridOptionsView
|
|
////GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
//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 LotNo2 = RowView.Row["扫描批次"].ToString();
|
|
// grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colLotNo2, LotNo2);
|
|
// }
|
|
// else
|
|
// {
|
|
// grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colLotNo2, "");
|
|
// }
|
|
//}
|
|
if (gridView1.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
if (gridView1.FocusedColumn == colLotNo2)
|
|
{
|
|
if (((DevExpress.XtraGrid.Views.Grid.GridView)(sender)).EditingValue != null)
|
|
{
|
|
string LotNo2 = ((DevExpress.XtraGrid.Views.Grid.GridView)(sender)).EditingValue.ToString();
|
|
//string LotNo2 = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colLotNo2).ToString();
|
|
string LotNo = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colLOTNO).ToString();
|
|
|
|
int LineNo = gridView1.FocusedRowHandle;
|
|
|
|
if (!string.IsNullOrWhiteSpace(LotNo2))
|
|
{
|
|
string sql1 = @"SELECT * FROM ICSWareHouseLotInfoLog WHERE 1=1 AND LotNO = '{0}' AND TransNO = '{1}' AND TransLine = '{2}' ";
|
|
sql1 = string.Format(sql1, LotNo2, txtMOCODE.Text, txtMOSEQ.Text);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql1).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("条码不属于这个工单!!!");
|
|
return;
|
|
}
|
|
|
|
string sql2 = @"SELECT VenderLotNO FROM ICSITEMLot WHERE LotNO='{0}' ";
|
|
sql2 = string.Format(sql2, LotNo2);
|
|
DataTable _dtSend = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql2).Tables[0];
|
|
string _VenderLotNO = string.Empty;
|
|
if (_dtSend != null && _dtSend.Rows.Count > 0)
|
|
{
|
|
_VenderLotNO = _dtSend.Rows[0]["VenderLotNO"].ToString();
|
|
gridView1.SetRowCellValue(LineNo, colVenderLotNO, _VenderLotNO);
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(_VenderLotNO))
|
|
{
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colLotNo2).ToString() == LotNo2 && i != LineNo)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("扫描批次栏位存在重复值!!!");
|
|
return;
|
|
}
|
|
}
|
|
string sql = @"UPDATE ICSITEMLot SET EATTRIBUTE6 = '{0}', EATTRIBUTE7 = '{2}', VenderLotNO = '{2}' WHERE LotNO = '{1}' ";
|
|
sql = string.Format(sql, LotNo2, LotNo, _VenderLotNO);
|
|
DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
|
|
for (int i = 0; i <= LineNo; i++)
|
|
{
|
|
//SendKeys.Send("{Down}");//delete by summer 2020.11.18
|
|
}
|
|
//btnFalsh_Click(null, null);
|
|
}
|
|
else
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("未获取到对应批次!!!");
|
|
return;
|
|
|
|
string sql = @"UPDATE ICSITEMLot SET EATTRIBUTE6='{0}' WHERE LotNO='{1}'";
|
|
sql = string.Format(sql, LotNo2, LotNo);
|
|
DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
|
|
for (int i = 0; i <= LineNo; i++)
|
|
{
|
|
//SendKeys.Send("{Down}");//delete by summer 2020.11.18
|
|
}
|
|
//btnFalsh_Click(null, null);
|
|
//ICSBaseSimpleCode.AppshowMessageBox("未获取到对应零件号!!!");
|
|
//return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("未获取到对应批次!!!");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("警告⚠不要重复回车");
|
|
return;
|
|
}
|
|
}
|
|
//this.CommitEdit(DataGridViewDataErrorContexts.Commit);
|
|
//this.EndEdit();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.ToString());
|
|
}
|
|
}
|
|
|
|
#region 行头自适应
|
|
public static void BindCustomDrawRowIndicator(DevExpress.XtraGrid.Views.Grid.GridView view)
|
|
{
|
|
view.IndicatorWidth = CalcIndicatorDefaultWidth(view);
|
|
view.CustomDrawRowIndicator += (s, e) =>
|
|
{
|
|
if (e.RowHandle >= 0)
|
|
{
|
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
}
|
|
};
|
|
view.TopRowChanged += (s, e) =>
|
|
{
|
|
int width = CalcIndicatorBestWidth(view);
|
|
if ((view.IndicatorWidth - 4 < width || view.IndicatorWidth + 4 > width) && view.IndicatorWidth != width)
|
|
{
|
|
view.IndicatorWidth = width;
|
|
}
|
|
};
|
|
}
|
|
/// <summary>
|
|
/// 计算行头宽度
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <returns></returns>
|
|
private static int CalcIndicatorBestWidth(DevExpress.XtraGrid.Views.Grid.GridView view)
|
|
{
|
|
Graphics graphics = new Control().CreateGraphics();
|
|
SizeF sizeF = new SizeF();
|
|
int count = view.TopRowIndex + ((DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo)view.GetViewInfo()).RowsInfo.Count;
|
|
if (count == 0)
|
|
{
|
|
count = 30;
|
|
}
|
|
sizeF = graphics.MeasureString(count.ToString(), view.Appearance.Row.Font);
|
|
return Convert.ToInt32(sizeF.Width) + 20;
|
|
}
|
|
/// <summary>
|
|
/// 计算默认的宽度
|
|
/// </summary>
|
|
/// <param name="view"></param>
|
|
/// <returns></returns>
|
|
private static int CalcIndicatorDefaultWidth(DevExpress.XtraGrid.Views.Grid.GridView view)
|
|
{
|
|
var grid = view.GridControl;
|
|
Graphics graphics = new Control().CreateGraphics();
|
|
SizeF sizeF = new SizeF();
|
|
int rowHeight = 22;//22是Row的估计高度
|
|
if (view.RowHeight > 0)
|
|
{
|
|
rowHeight = view.RowHeight;
|
|
}
|
|
int count = grid != null ? grid.Height / rowHeight : 30;
|
|
sizeF = graphics.MeasureString(count.ToString(), view.Appearance.Row.Font);
|
|
return Convert.ToInt32(sizeF.Width) + 20;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|