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.
3211 lines
151 KiB
3211 lines
151 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.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 Newtonsoft.Json;
|
|
using System.Net;
|
|
using System.Configuration;
|
|
using ICSSoft.Entity.PU_AppVouch;
|
|
using ICSSoft.Frame.Data.Entity.WWModel;
|
|
using ICSSoft.Frame.Data.DAL;
|
|
using System.Reflection;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.Data.Filtering;
|
|
using System.Linq;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSMO2UserSendNew : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
private string sqltxt = "";
|
|
private string sqlconn = "";
|
|
String guid = AppConfig.GetGuid();
|
|
private DataTable dataUser = null;
|
|
private DataTable data = null;
|
|
private DataTable dtSend = null;
|
|
private DataTable dtLotno = null;
|
|
private bool isQueryCloseUp = false;
|
|
private bool isQueryCloseUpEQP = false;
|
|
//WorkPointBLL workBll = new WorkPointBLL();
|
|
static string APIURL = System.Configuration.ConfigurationSettings.AppSettings["APIURL"].ToString();
|
|
//static string APIURL = "http://localhost:51182/api/";
|
|
static string DataCollectWW = APIURL + "APICreateInventory_PU_AppVouch";
|
|
//static string DataCollectWW = "http://localhost:51182/api/" + "APICreateInventory_PU_AppVouch";
|
|
|
|
string PoKey = ConfigurationManager.AppSettings["PoKey"];
|
|
string DjIp = ConfigurationManager.AppSettings["WorkHourIp"];
|
|
string EntId = ConfigurationManager.AppSettings["WorkHourEntId"];
|
|
string CompanyId = ConfigurationManager.AppSettings["WorkHourCompanyId"];
|
|
string VendorView = ConfigurationManager.AppSettings["VendorView"];
|
|
string PoDocNo= ConfigurationManager.AppSettings["PoDocNo"];
|
|
string DjAddress= ConfigurationManager.AppSettings["WorkHourIpAddress"];
|
|
|
|
#region 构造函数
|
|
public FormICSMO2UserSendNew(Dictionary<string, string> sendMes)
|
|
{
|
|
InitializeComponent();
|
|
dateTimePicker1.Checked = false;
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
splitContainer1.Enabled = true;
|
|
SearchMO(sendMes);
|
|
//SearchItemLotInfo(MOID);
|
|
}
|
|
|
|
public FormICSMO2UserSendNew()
|
|
{
|
|
|
|
InitializeComponent();
|
|
dateTimePicker1.Checked = false;
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
|
|
}
|
|
#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(btnExit);
|
|
ControlList.Add(BtnCreatePR);
|
|
ControlList.Add(BtnWWCancel);
|
|
ControlList.Add(BtnWWSave);
|
|
//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)
|
|
{
|
|
List<string> lotNO = new List<string>();
|
|
if (gridView1.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
if (gridView1.FocusedColumn == colisSelect)
|
|
{
|
|
if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colisSelect).ToString() == "")
|
|
{
|
|
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, colisSelect, "Y");
|
|
|
|
//txtMOCODE.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, moCode).ToString();
|
|
//this.txtLotNo.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colLOTNO).ToString();
|
|
//this.txtMOSEQ.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colMOSEQ).ToString();
|
|
//this.txtITEMCODE.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, itemCode).ToString();
|
|
}
|
|
else
|
|
{
|
|
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, colisSelect, "");
|
|
//txtMOCODE.Text ="";
|
|
//this.txtLotNo.Text ="";
|
|
//this.txtMOSEQ.Text = "";
|
|
//this.txtITEMCODE.Text = "";
|
|
}
|
|
BoundGridLookUpData();
|
|
BoundEQPData();
|
|
}
|
|
|
|
}
|
|
|
|
public void LoadGrd()
|
|
{
|
|
string sql = "";
|
|
DataTable dt = null;
|
|
// sql = @" SELECT top 1
|
|
// '' as Stime,
|
|
// '' 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 SendPlanDate
|
|
// 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}'
|
|
// ORDER BY c.OPSEQ"; ;
|
|
// sql = string.Format(sql, txtMOCODE.Text);
|
|
// dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
// if (dt.Rows.Count != 0)
|
|
// {
|
|
// if (dt.Rows[0]["OPCODE"].ToString() == "")
|
|
// {
|
|
// sql = @" SELECT top 1
|
|
// '' as Stime,
|
|
// '' 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";
|
|
// sql = string.Format(sql, txtMOCODE.Text);
|
|
// dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
|
|
// }
|
|
DataTable table = new DataTable();
|
|
table.Columns.Add(new DataColumn("USERName"));
|
|
table.Columns.Add(new DataColumn("USERCODE"));
|
|
table.Columns.Add(new DataColumn("EQPCode"));
|
|
table.Columns.Add(new DataColumn("EQPName"));
|
|
table.Columns.Add(new DataColumn("SendPlanDate"));
|
|
table.Columns.Add(new DataColumn("Stime"));
|
|
DataRow row = table.NewRow();
|
|
row["USERName"] = "";
|
|
row["USERCODE"] = "";
|
|
row["EQPCode"] = "";
|
|
row["EQPName"] = "";
|
|
row["SendPlanDate"] = DateTime.Now.ToString("yyyy/MM/dd");
|
|
row["Stime"] = "";
|
|
table.Rows.Add(row);
|
|
dt = table;
|
|
grdDetail.DataSource = dt;
|
|
BoundEQPData();
|
|
BoundGridLookUpData();
|
|
|
|
|
|
}
|
|
#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)
|
|
{
|
|
LoadOp();
|
|
}
|
|
#endregion
|
|
|
|
#region 数据源
|
|
private void SearchMO(Dictionary<string, string> sendMes)
|
|
{
|
|
try
|
|
{
|
|
txtMOCODE.Text = sendMes["moCode"];
|
|
txtMoLotCode.Text = sendMes["MoLotCode"];
|
|
txtITEMCODE.Text = sendMes["itemCode"];
|
|
txtMOSEQ.Text = sendMes["MOSEQ"];
|
|
|
|
string sql = string.Format("select INVNAME,INVSTD from ICSINVENTORY where INVCODE='{0}'", sendMes["itemCode"]);
|
|
SqlDataReader reader = DBHelper.ExecuteReader(AppConfig.AppConnectString, CommandType.Text, sql);
|
|
while (reader.Read())
|
|
{
|
|
txtItemName.Text = reader["INVNAME"].ToString();
|
|
textItemStd.Text = reader["INVSTD"].ToString();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void SearchItemLotInfo(string MOID)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select LOTNO,LOTQTY
|
|
from ICSMO2Lot
|
|
where MOID = '{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
|
|
|
|
#region 保存
|
|
private void btnSave_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;
|
|
}
|
|
|
|
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
if (gridView1.GetRowCellValue(i, pgstatus).ToString() != "未派工")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("批号:" + gridView1.GetRowCellValue(i, colLOTNO).ToString() + ",工序:" + gridView1.GetRowCellValue(i, opCode).ToString() + ",已经派工,请勿重复操作!");
|
|
return;
|
|
}
|
|
|
|
|
|
#region 20210728已经开工的工序不能再操作
|
|
string sqlCheck = @"SELECT COUNT(*) FROM ICSLOTONWIP WHERE LOTNO='" + gridView1.GetRowCellValue(i, colLOTNO).ToString() + "' AND OPCODE='" + gridView1.GetRowCellValue(i, opCode).ToString() + "'";
|
|
DataTable DTCheck = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlCheck).Tables[0];
|
|
if (DTCheck != null && DTCheck.Rows.Count > 0)
|
|
{
|
|
int a = Int32.Parse(DTCheck.Rows[0][0].ToString());
|
|
if (a > 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("批号:" + gridView1.GetRowCellValue(i, colLOTNO).ToString() + ",工序:" + gridView1.GetRowCellValue(i, opCode).ToString() + ",已经开工,不能保存!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
FormICSMO2UserUIModel MO2UserInfo = new FormICSMO2UserUIModel();
|
|
MO2UserInfo.ID = "";
|
|
MO2UserInfo.MOCODE = gridView1.GetRowCellValue(i, moCode).ToString();
|
|
MO2UserInfo.LOTNO = gridView1.GetRowCellValue(i, colLOTNO).ToString();
|
|
//MO2UserInfo.SEGCODE = txtDepart.Text.ToString();
|
|
|
|
//if (!string.IsNullOrWhiteSpace(txtMOSEQ.Text.ToString()))
|
|
//{
|
|
// MO2UserInfo.MOSEQ = Int32.Parse(txtMOSEQ.Text.ToString());
|
|
//}
|
|
//else
|
|
//{
|
|
// MO2UserInfo.MOSEQ = Int32.Parse(gridView1.GetRowCellValue(i, colMOSEQ).ToString());
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(gridView1.GetRowCellValue(i, colMOSEQ).ToString()))
|
|
MO2UserInfo.MOSEQ = Int32.Parse(gridView1.GetRowCellValue(i, colMOSEQ).ToString());
|
|
|
|
MO2UserInfo.StartPlanDate=Convert.ToDateTime(gridView1.GetRowCellValue(i, gridColumn11).ToString());//开工日期9.3
|
|
MO2UserInfo.EndPlanDate= Convert.ToDateTime(gridView1.GetRowCellValue(i, gridColumn12).ToString());//完工日期9.3
|
|
|
|
MO2UserInfo.RouteCode = gridView1.GetRowCellValue(i, routeCode).ToString();
|
|
MO2UserInfo.OPCODE = gridView1.GetRowCellValue(i, opCode).ToString();
|
|
|
|
MO2UserInfo.USERCODE = grvDetail.GetRowCellValue(0, colUSERCODE).ToString();
|
|
MO2UserInfo.USERName = grvDetail.GetRowCellValue(0, colUSERName).ToString();
|
|
MO2UserInfo.EQPCode = grvDetail.GetRowCellValue(0, colEQPCode).ToString();
|
|
MO2UserInfo.EQPName = grvDetail.GetRowCellValue(0, colEQPName).ToString();
|
|
|
|
MO2UserInfo.MUSER = AppConfig.UserCode;
|
|
MO2UserInfo.MUSERName = AppConfig.UserName;
|
|
MO2UserInfo.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
MO2UserInfo.WorkPoint = AppConfig.WorkPointCode;
|
|
MO2UserInfo.EATTRIBUTE1 = "0";
|
|
MO2UserInfo.PlanDate = int.Parse(AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd"));
|
|
MO2UserInfo.SEGCODE =Convert.ToBoolean(gridView1.GetRowCellValue(i, ISAGV))==true?"1":"0";
|
|
if (string.IsNullOrEmpty(grvDetail.GetRowCellValue(0, colPlanDate).ToString()) == false)
|
|
{
|
|
MO2UserInfo.SendPlanDate = Convert.ToDateTime(grvDetail.GetRowCellValue(0, colPlanDate).ToString());
|
|
}
|
|
|
|
MO2UserInfoList.Add(MO2UserInfo);
|
|
if (string.IsNullOrEmpty(MO2UserInfo.USERCODE) || string.IsNullOrEmpty(MO2UserInfo.EQPCode))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请分配员工和设备后再保存!");
|
|
return;
|
|
}
|
|
//if (string.IsNullOrEmpty(MO2UserInfo.EQPCode) || string.IsNullOrEmpty(MO2UserInfo.EQPName))
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("设备代码、设备名称 均不能为空!");
|
|
// return;
|
|
//}
|
|
}
|
|
|
|
}
|
|
try
|
|
{
|
|
ICSMO2UserBLL.Add(MO2UserInfoList, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox(0, "保存成功");
|
|
simpleSearch_Click(null, null);
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
|
|
btnFalsh_Click(null, null);
|
|
|
|
}
|
|
#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)
|
|
{
|
|
try
|
|
{
|
|
FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
|
|
foe.ShowDialog();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
//FormOutExcel foe = new FormOutExcel();
|
|
//if (foe.ShowDialog() == DialogResult.OK)
|
|
//{
|
|
// try
|
|
// {
|
|
// string outtype = foe._OutType;
|
|
// string exceltype = foe._ExcelType;
|
|
// string filename = foe._FileName;
|
|
// string url = foe._Url;
|
|
// string sheetname = foe._SheetName;
|
|
// if (outtype.ToLower() == "excel")
|
|
// {
|
|
// DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
|
|
// op.SheetName = sheetname;
|
|
// grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
|
|
// }
|
|
// else
|
|
// {
|
|
// grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
|
|
// }
|
|
// MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
// }
|
|
|
|
//}
|
|
}
|
|
#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 code = "";
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
code = gridView1.GetRowCellValue(i, opCode).ToString();
|
|
break;
|
|
}
|
|
}
|
|
if (code == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请先选择工序!");
|
|
return;
|
|
}
|
|
|
|
//根据批次信息里的工序编码,获得派工信息的人员代码,人员名称
|
|
string sql = "select USERCODE as [人员代码],USERName as [人员名称] from dbo.ICSOP2User with(nolock) WHERE OPCODE='{0}'";
|
|
|
|
sql = string.Format(sql, code);
|
|
//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
|
|
|
|
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;
|
|
|
|
// }
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
#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 USERCODE = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE).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 condition = "";
|
|
string cc="";
|
|
List<string> opcode = new List<string>();
|
|
List<string> itemcode = new List<string>();
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
if (opcode.Exists(a => a == gridView1.GetRowCellValue(i, opCode).ToString()) == false)
|
|
{
|
|
opcode.Add(gridView1.GetRowCellValue(i, opCode).ToString());
|
|
itemcode.Add(gridView1.GetRowCellValue(i, itemCode).ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < opcode.Count; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
condition += string.Format(" and (opcode='{0}' and itemcode='{1}' )", opcode[i], itemcode[i]);
|
|
}
|
|
else
|
|
{
|
|
condition += string.Format(" or (opcode='{0}' and itemcode='{1} ') ", opcode[i], itemcode[i]);
|
|
|
|
}
|
|
}
|
|
|
|
// string sql = @"
|
|
// if exists(SELECT * FROM tempdb..sysobjects where id=object_id('tempDB..#tempa'))
|
|
// DROP TABLE #tempa
|
|
// IF EXISTS (SELECT * FROM tempdb..sysobjects where id=object_id('tempDB..#TempStime'))
|
|
// drop table #TempStime
|
|
// select * into #tempa from
|
|
// (select EQPCode as [设备代码],EQPName as [设备名称],Type as [设备类型] from dbo.ICSEquipment with(nolock)
|
|
// where type in (select eqptypecode from ICSEQPSTP WHERE 1=1 {0} GROUP BY eqptypecode HAVING COUNT(*)>={1} ))A
|
|
// SELECT * INTO #TempStime from(
|
|
//select icsmo.itemcode,icsmo2user.lotno,icsmo2user.OPCODE,g.routecode,(ICSEQPSTPEMODEL.stime*ICSMO2Lot.LOTQTY)/60 AS STIME,icsmo2user.EQPCode,ICSMO2Lot.LOTQTY AS 数量
|
|
//from icsmo2user
|
|
// LEFT join icsmo on icsmo.MOCODE=ICSMO2User.MOCODE
|
|
// LEFT JOIN ICSMO2Lot ON ICSMO2Lot.LOTNO=ICSMO2User.LOTNO
|
|
// LEFT join ICSROUTE2OP g on icsmo2user.RouteCode = g.RouteCode and g.opcode=icsmo2user.OPCODE
|
|
// LEFT join ICSEQPSTPEMODEL on ICSEQPSTPEMODEL.ITEMCODE=icsmo.ITEMCODE and ICSEQPSTPEMODEL.eqpcode=g.MainResources and icsmo2user.OPCODE=ICSEQPSTPEMODEL.opcode
|
|
// where not EXISTS (select 1 from ICSLOTONWIP ww where ww.lotno =ICSMO2User.lotno and isnull(ww.EndTime,'')!='' AND WW.OPCODE=icsmo2user.OPCODE)
|
|
//)a
|
|
// select #tempa.设备类型,#tempa.设备名称,#tempa.设备代码,isnull(a.工时,0) as 工时 from #tempa left join (select sum(stime) AS 工时,EQPCode from #TempStime GROUP BY EQPCode)A on #tempa.设备代码=A.EQPCode
|
|
//";
|
|
//0911注释
|
|
string sql = @" select EQPCode as [设备代码],EQPName as [设备名称],Type as [设备类型] from dbo.ICSEquipment with(nolock) ";
|
|
|
|
// string USERCODEs = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE).ToString();
|
|
// string sql = @"select a.EQPCode as [设备代码],a.EQPName as [设备名称],Type as [设备类型] from dbo.ICSEquipment a with(nolock)
|
|
// left join ICSSkillMatrix b on b.equipmentType=a.EQPCode
|
|
// where b.WorkNo='" + USERCODEs + "'";
|
|
|
|
sql = string.Format(sql, condition , opcode.Count());
|
|
|
|
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.AutoComplete = true;
|
|
repositoryItemGridLookUpEdit2.NullText = "";//空时的值
|
|
//repositoryItemGridLookUpEdit2.DropDownRows = 10;//下拉框行数
|
|
repositoryItemGridLookUpEdit2.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
repositoryItemGridLookUpEdit2.ValidateOnEnterKey = true;//回车确认
|
|
//repositoryItemGridLookUpEdit2.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoFilter;//自动过滤掉不需要显示的数据,可以根据需要变化
|
|
repositoryItemGridLookUpEdit2.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;//要使用户可以输入,这里须设为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 condition = "";
|
|
List<string> opcode = new List<string>();
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
if (opcode.Exists(a => a == gridView1.GetRowCellValue(i, opCode).ToString()) == false)
|
|
{
|
|
opcode.Add(gridView1.GetRowCellValue(i, opCode).ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
for (int i = 0; i < opcode.Count; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
condition += string.Format(" and opcode='{0}'", opcode[i]);
|
|
}
|
|
else
|
|
{
|
|
condition += string.Format(" or opcode='{0}'", opcode[i]);
|
|
}
|
|
}
|
|
|
|
// string sql = @"select ICSOP2User.USERCODE as [人员代码],USERName as [人员名称],工时 from dbo.ICSOP2User
|
|
// left join (select sum(加工工时) AS 工时, usercode from (select username,usercode,eqpname,opname,plandate,BeginDate,EndDate,icsmo2user.lotno,
|
|
//case
|
|
//when BeginDate is not null then '开工中'
|
|
//else '未开工'
|
|
//end 状态,isnull(p.stime,0) as 标准工时,ICSMO2Lot.lotqty as 数量, convert(decimal(10,2),isnull(p.stime,0)*ICSMO2Lot.lotqty/60) as 加工工时
|
|
//from icsmo2user
|
|
//left join ICSOP on ICSOP.OPCODE=ICSMO2User.OPCODE
|
|
//left join icsmo on icsmo2user.mocode=icsmo.MOCODE
|
|
//LEFT join ICSLOTONWIP on ICSLOTONWIP.OPCODE=ICSMO2User.opcode and ICSLOTONWIP.lotno=icsmo2user.lotno AND ICSLOTONWIP.action='good'
|
|
//left join ICSROUTE2OP g on icsmo2user.RouteCode = g.RouteCode and icsmo2user.OPCODE=g.OPCODE
|
|
//left join ICSMO2Lot on ICSMO2Lot.LOTNO=ICSMO2User.LOTNO
|
|
//left join ICSEQPSTPEMODEL p on p.ITEMCODE=ICSMO.ITEMCODE and p.OPCODE=ICSMO2User.OPCODE and p.EQPCODE=g.MainResources
|
|
// where not EXISTS (select 1 from ICSLOTONWIP ww where ww.lotno =ICSMO2User.lotno and isnull(ww.EndTime,'')!='' and ww.opcode=ICSMO2User.opcode))A
|
|
// GROUP BY USERCODE)a on a.usercode=ICSOP2User.usercode
|
|
//
|
|
// where 1=1 ";
|
|
|
|
string sql = @"select ICSOP2User.USERCODE as [人员代码],USERName as [人员名称],工时 from dbo.ICSOP2User
|
|
left join (select sum(加工工时) AS 工时, usercode from (select username,usercode,eqpname,opname,
|
|
icsmo2user.StartPlanDate plandate,
|
|
icsmo2user.EndPlanDate EndDate,icsmo2user.lotno,
|
|
case
|
|
when StartPlanDate is not null then '开工中'
|
|
else '未开工'
|
|
end 状态,
|
|
--isnull(p.stime,0) as 标准工时,
|
|
0 as 标准工时,
|
|
ICSITEMLot.lotqty as 数量,
|
|
--convert(decimal(10,2),isnull(p.stime,0)*ICSITEMLot.lotqty/60) as 加工工时
|
|
0 as 加工工时
|
|
from icsmo2user
|
|
left join ICSOP on ICSOP.OPCODE=ICSMO2User.OPCODE
|
|
left join icsmo on icsmo2user.mocode=icsmo.MOCODE
|
|
LEFT join ICSLOTONWIP on ICSLOTONWIP.OPCODE=icsmo2user.opcode and ICSLOTONWIP.lotno=icsmo2user.lotno AND ICSLOTONWIP.action='good'
|
|
left join ICSROUTE2OP g on icsmo2user.RouteCode = g.RouteCode and icsmo2user.OPCODE=g.OPCODE
|
|
left join ICSITEMLot on ICSITEMLot.LOTNO=ICSMO2User.LOTNO
|
|
--left join ICSEQPSTPEMODEL p on p.ITEMCODE=ICSMO.ITEMCODE and p.OPCODE=ICSMO2User.OPCODE and p.EQPCODE=g.MainResources
|
|
where not EXISTS (select 1 from ICSLOTONWIP ww where ww.lotno =ICSMO2User.lotno and isnull(ww.EndTime,'')!='' and ww.opcode=ICSMO2User.opcode))A
|
|
GROUP BY USERCODE)a on a.usercode=ICSOP2User.usercode
|
|
|
|
where 1=1 ";
|
|
sql = string.Format(sql + condition + "group by ICSOP2User.usercode,username,工时 having count(*)>={0}", opcode.Count);
|
|
|
|
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;
|
|
|
|
|
|
GridView gridView = edit.Properties.View as GridView;
|
|
//FieldInfo fi = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
////List<BinaryOperator> listBinary = new List<BinaryOperator>();
|
|
//for (int i = 0; i < gridView1.RowCount; i++) {
|
|
// if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y") {
|
|
// listBinary.Add(new BinaryOperator("工序代码", gridView1.GetRowCellValue(i, opCode).ToString(), BinaryOperatorType.Equal));
|
|
// }
|
|
//}
|
|
//BinaryOperator op2 = new BinaryOperator("人员代码", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
|
|
//listBinary.Add(op2);
|
|
//List<CriteriaOperator> condition = new List<CriteriaOperator>();
|
|
//for (int i = 0; i < listBinary.Count; i++) {
|
|
// condition.Add(listBinary[i]);
|
|
//}
|
|
//CriteriaOperator [] conditionArray = condition.ToArray();
|
|
//string filterCondition = new GroupOperator(GroupOperatorType.And, conditionArray).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
|
|
{
|
|
#region 0911
|
|
TextEdit txt = sender as TextEdit;
|
|
string value = txt.EditValue.ToString();
|
|
// string USERCODEs = grvDetail.GetRowCellValue(0, colUSERCODE).ToString();
|
|
string sql = @"select a.EQPCode as [设备代码],a.EQPName as [设备名称],Type as [设备类型] from dbo.ICSEquipment a with(nolock)
|
|
left join ICSSkillMatrix b on b.equipmentType=a.EQPCode
|
|
where b.WorkNo='" + value + "' order by EQPCode ";
|
|
//where b.WorkNo='" + USERCODEs + "'
|
|
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.AutoComplete = true;
|
|
repositoryItemGridLookUpEdit2.NullText = "";//空时的值
|
|
//repositoryItemGridLookUpEdit2.DropDownRows = 10;//下拉框行数
|
|
repositoryItemGridLookUpEdit2.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
repositoryItemGridLookUpEdit2.ValidateOnEnterKey = true;//回车确认
|
|
//repositoryItemGridLookUpEdit2.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoFilter;//自动过滤掉不需要显示的数据,可以根据需要变化
|
|
repositoryItemGridLookUpEdit2.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;//要使用户可以输入,这里须设为Standard
|
|
repositoryItemGridLookUpEdit2.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
repositoryItemGridLookUpEdit2.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
|
|
if (data.Rows.Count > 0)
|
|
{
|
|
grvDetail.SetRowCellValue(0, colEQPCode, data.Rows[0]["设备代码"]);
|
|
grvDetail.SetRowCellValue(0, colEQPName, data.Rows[0]["设备名称"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
#endregion 0911
|
|
|
|
string code = "";
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
//0911注释的
|
|
//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 USERCODE = RowView.Row["人员代码"].ToString();
|
|
string USERNAME = RowView.Row["人员名称"].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
|
|
{
|
|
string code = "";
|
|
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 USERCODE = RowView["人员代码"].ToString();
|
|
string USERNAME = RowView["人员名称"].ToString();
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
code = gridView1.GetRowCellValue(i, opCode).ToString();
|
|
}
|
|
}
|
|
|
|
//grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE, USERCODE);
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colUSERName, USERNAME);
|
|
|
|
isQueryCloseUp = true;
|
|
getPerson(USERCODE);
|
|
}
|
|
|
|
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 (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();
|
|
|
|
|
|
string eqpcode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colEQPCode).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)
|
|
{
|
|
List<string> lotno = new List<string>();
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
lotno.Add(gridView1.GetRowCellValue(i, colLOTNO).ToString());
|
|
}
|
|
|
|
}
|
|
if (lotno.Count <= 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择需要打印的产品跟踪码!!!");
|
|
return;
|
|
}
|
|
FormICSProductTrackingList form = new FormICSProductTrackingList(lotno);
|
|
form.Show();
|
|
}
|
|
|
|
//取消派工
|
|
private void txtcancelSend_Click(object sender, EventArgs e)
|
|
{
|
|
List<string> lotno = new List<string>();
|
|
List<string> opcode = new List<string>();
|
|
List<FormICSMO2UserUIModel> MO2UserInfoList = new List<FormICSMO2UserUIModel>();
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
//if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y" && gridView1.GetRowCellValue(i, isSend).ToString() == "是")
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y" && gridView1.GetRowCellValue(i, isSend).ToString() == "True")
|
|
{
|
|
lotno.Add(gridView1.GetRowCellValue(i, colLOTNO).ToString());
|
|
opcode.Add(gridView1.GetRowCellValue(i, opCode).ToString());
|
|
}
|
|
}
|
|
if (lotno.Count < 1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("未选择产品追踪码或选中项还未派单!!!");
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
ICSMO2UserBLL.cancelSend(lotno, opcode, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox(0, "取消成功");
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
simpleSearch_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 op2 = new BinaryOperator("设备代码", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
|
|
//string filterCondition = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] { 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 GetStime(string eqpcode)
|
|
{
|
|
SqlParameter[] param = new SqlParameter[] {
|
|
new SqlParameter("EQPCode",eqpcode),
|
|
new SqlParameter("sumStime",SqlDbType.NVarChar,20)
|
|
|
|
|
|
};
|
|
param[1].Direction = ParameterDirection.Output;
|
|
DBHelper.ExecuteReader(AppConfig.AppConnectString, CommandType.StoredProcedure, "PC_Stime", param);
|
|
|
|
if (param[1].Value == null)
|
|
{
|
|
|
|
grvDetail.SetRowCellValue(0, wTime, "");
|
|
}
|
|
else
|
|
{
|
|
|
|
grvDetail.SetRowCellValue(0, wTime, param[1].Value.ToString());
|
|
}
|
|
|
|
|
|
}
|
|
private void getPerson(string userCode)
|
|
{
|
|
string sql = string.Format(@"
|
|
select username,eqpname,opname,
|
|
--plandate,BeginDate,EndDate,
|
|
icsmo2user.StartPlanDate plandate,
|
|
--BeginDate,
|
|
icsmo2user.EndPlanDate EndDate,
|
|
icsmo2user.lotno,
|
|
case
|
|
when StartPlanDate is not null then '开工中'
|
|
else '未开工'
|
|
end 状态,
|
|
--isnull(p.stime,0) as 标准工时,
|
|
ICSITEMLot.lotqty as 数量,
|
|
--convert(decimal(10,2),isnull(p.stime,0)*ICSMO2Lot.lotqty/60) as 加工工时
|
|
0 AS 加工工时
|
|
from icsmo2user
|
|
left join ICSOP on ICSOP.OPCODE=ICSMO2User.OPCODE
|
|
left join icsmo on icsmo2user.mocode=icsmo.MOCODE
|
|
LEFT join ICSLOTONWIP on ICSLOTONWIP.OPCODE=ICSMO2User.opcode and ICSLOTONWIP.lotno=icsmo2user.lotno AND ICSLOTONWIP.action='good'
|
|
left join ICSROUTE2OP g on icsmo2user.RouteCode = g.RouteCode and icsmo2user.OPCODE=g.OPCODE
|
|
left join ICSITEMLot on ICSITEMLot.LOTNO=ICSMO2User.LOTNO
|
|
--left join ICSEQPSTPEMODEL p on p.ITEMCODE=ICSMO.ITEMCODE and p.OPCODE=ICSMO2User.OPCODE and p.EQPCODE=g.MainResources
|
|
where not EXISTS (select 1 from ICSLOTONWIP ww where ww.lotno =ICSMO2User.lotno and isnull(ww.EndTime,'')!='' and ww.opcode=ICSMO2User.opcode)
|
|
and usercode='{0}' ", userCode);
|
|
DataTable personSend = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
int allstime = 0;
|
|
|
|
gridControl2.DataSource = personSend;
|
|
}
|
|
private void repositoryItemGridLookUpEdit2_QueryCloseUp(object sender, CancelEventArgs e)
|
|
{
|
|
|
|
try
|
|
{
|
|
isQueryCloseUpEQP = true;
|
|
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();
|
|
if (string.IsNullOrWhiteSpace(CODE) == false)
|
|
{
|
|
|
|
//grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPCode, EQPCODE);
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colEQPName, EQPNAME);
|
|
|
|
GetStime(RowView["设备代码"].ToString());
|
|
}
|
|
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;
|
|
}
|
|
|
|
private void groupControl2_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void simpleSearch_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// string sql = string.Format(@"select '' as isSelect,
|
|
// A.ProjectCode as 项目号, E.ROUTECODE as routeCode, A.MOCODE as 工单号, A.ITEMCODE as 料号, B.LOTNO as 产品跟踪单号,
|
|
// C.ItemName AS 料品名称, c.ItemStd as 料品图纸,f.OPcode as 工序编码, f.OPdesc as 工序, e.OPSEQ as 工序次序,
|
|
//A.modept as 生产部门, p.STIME as 工时, MOPLANSTARTDATE as 预计开工时间, MOPLANENDDATE AS 预计完工时间,b.lotqty as 数量,
|
|
//case
|
|
// when icsmo2user.OPCODE is null then '否'
|
|
// else '是'
|
|
// end as 是否已派工
|
|
//FROM ICSMO A
|
|
//INNER join ICSMO2Lot B ON B.MOCODE = A.MOCODE
|
|
//left join Base_Inventory c on c.ItemCode = A.ITEMCODE
|
|
//LEFT JOIN ICSMO2ROUTE d on d.MOCODE = a.MOCODE
|
|
//left join icsroute2op e on e.ROUTECODE = d.ROUTECODE
|
|
//left join ICSOP f on f.opcode = e.OPCODE
|
|
//left join ICSEQPSTPEMODEL p on p.ItemCode = a.ItemCode and p.OPCODE = f.opcode and p.EQPCODE = e.MainResources and p.ISREF = '是'
|
|
//left join icsmo2user on icsmo2user.lotno=b.LOTNO and icsmo2user.OPCODE=f.opcode
|
|
//left join ICSITEMROUTE2OP h on h.ITEMCODE=a.ITEMCODE and h.ROUTECODE=d.ROUTECODE and h.OPCODE=f.OPCODE
|
|
//where H.IDMERGERULE!=1
|
|
// ");
|
|
|
|
// string sql = string.Format(@"SELECT DISTINCT
|
|
// '' AS isSelect,
|
|
// --A.ProjectCode AS 项目号,
|
|
// E.ROUTECODE AS routeCode,
|
|
// A.MOCODE AS 工单号,a.MOSEQ 工单行号,
|
|
// A.ITEMCODE AS 料号,
|
|
// B.LOTNO AS 产品跟踪单号,
|
|
// C.INVNAME AS 料品名称,
|
|
// --c.INVShelfLife as 料品图纸,
|
|
// f.OPcode AS 工序编码,
|
|
// f.OPdesc AS 工序,
|
|
// e.OPSEQ AS 工序次序,
|
|
// A.MDeptCode AS 生产部门,
|
|
// '' as pictureSee,
|
|
// --p.STIME AS 工时,
|
|
// 0 AS 工时,
|
|
// --0908修改
|
|
// A.MOPLANSTARTDATE AS 预计开工时间,
|
|
// A.MOPLANENDDATE AS 预计完工时间,
|
|
|
|
// cast(b.lotqty as int) AS 数量,
|
|
// --b.lotqty AS 数量,
|
|
|
|
// --CAST(CASE WHEN icsmo2user.OPCODE IS NULL or icsmo2user.EATTRIBUTE1!='1' THEN '0' ELSE '1' END AS BIT) AS 是否已派工,
|
|
// CAST(CASE WHEN (icsmo2user.OPCODE IS NOT NULL or icsmo2user.EATTRIBUTE1='1' ) THEN '1' ELSE '0' END AS BIT) AS 是否已派工,
|
|
|
|
// CAST(CASE WHEN icsmo2user.EATTRIBUTE1 ='1' THEN '1' ELSE '0' END AS BIT) AS 已委外,
|
|
// case
|
|
// when i.ACTIONRESULT = 'COLLECT_BEGIN' then '开工未完工'
|
|
// when icsmo2user.OPCODE is null then '未派工'
|
|
// when i.ACTIONRESULT IS NULL THEN '未开工'
|
|
// when i.ACTIONRESULT = 'COLLECT_END' and g.Result is null then '完工未检验'
|
|
// when i.ACTIONRESULT = 'COLLECT_END' and g.Result = '合格' then '检验合格'
|
|
// wheN i.ACTIONRESULT = 'COLLECT_END' and g.Result = '不合格' then '检验不合格'
|
|
// end as status
|
|
|
|
// FROM
|
|
// ICSMO A
|
|
// INNER JOIN ICSITEMLot B ON B.TransNO = A.MOCODE AND a.MOSEQ=b.TransLine-- B.MCODE = A.MOCODE -- ICSMO2Lot
|
|
// -- left join Base_Inventory c on c.ItemCode = A.ITEMCODE
|
|
// LEFT JOIN ICSINVENTORY c ON c.INVCODE = A.ITEMCODE
|
|
// LEFT JOIN ICSMO2ROUTE d ON d.MOCODE = a.MOCODE
|
|
// LEFT JOIN icsroute2op e ON e.ROUTECODE = d.ROUTECODE
|
|
// LEFT JOIN ICSOP f ON f.opcode = e.OPCODE
|
|
// -- LEFT JOIN ICSEQPSTPEMODEL p ON p.ItemCode = a.ItemCode
|
|
// -- AND p.OPCODE = f.opcode
|
|
// -- AND p.EQPCODE = e.MainResources
|
|
// -- AND p.ISREF = '是'
|
|
// LEFT JOIN icsmo2user ON icsmo2user.lotno = b.LOTNO
|
|
// AND icsmo2user.OPCODE = f.opcode
|
|
// LEFT JOIN ICSITEMROUTE2OP h ON h.ITEMCODE = a.ITEMCODE
|
|
// AND h.ROUTECODE = d.ROUTECODE
|
|
// AND h.OPCODE = f.OPCODE
|
|
// left join ICSLOTONWIP i on i.lotno=b.lotno and i.opcode=f.OPcode
|
|
// left join ICSLOTONWIPCheck g on g.ONWIPID=i.id
|
|
|
|
// WHERE
|
|
// H.IDMERGERULE != 1
|
|
//");
|
|
|
|
string erpconstr = GetERPConn();
|
|
string sql = string.Format(@"select * from (
|
|
SELECT DISTINCT
|
|
'' AS isSelect,
|
|
A.OrderNo AS 项目号,
|
|
E.ROUTECODE AS routeCode,
|
|
A.MOCODE AS 工单号,a.MOSEQ 工单行号,
|
|
A.ITEMCODE AS 料号,
|
|
a.MOVER,
|
|
B.LOTNO AS 产品跟踪单号,
|
|
C.INVNAME AS 料品名称,
|
|
--c.INVShelfLife as 料品图纸,
|
|
f.OPcode AS 工序编码,
|
|
f.OPdesc AS 工序,
|
|
e.OPSEQ AS 工序次序,
|
|
A.MDeptCode AS 生产部门,
|
|
'' as pictureSee,
|
|
--p.STIME AS 工时,
|
|
0 AS 工时,
|
|
--0908修改
|
|
A.MOPLANSTARTDATE AS 预计开工时间,
|
|
A.MOPLANENDDATE AS 预计完工时间,
|
|
CAST(case when ISNULL(icsmo2user.SEGCODE,'1')='' THEN '0' ELSE ISNULL(icsmo2user.SEGCODE,'0') END AS Bit) AS ISAGV,
|
|
cast(b.lotqty as int) AS 数量,
|
|
--b.lotqty AS 数量,
|
|
|
|
--CAST(CASE WHEN icsmo2user.OPCODE IS NULL or icsmo2user.EATTRIBUTE1!='1' THEN '0' ELSE '1' END AS BIT) AS 是否已派工,
|
|
CAST(CASE WHEN (icsmo2user.OPCODE IS NOT NULL or icsmo2user.EATTRIBUTE1='1' ) THEN '1' ELSE '0' END AS BIT) AS 是否已派工,
|
|
|
|
CAST(CASE WHEN icsmo2user.EATTRIBUTE1 ='1' THEN '1' ELSE '0' END AS BIT) AS 已委外,
|
|
case
|
|
when i.ACTIONRESULT = 'COLLECT_BEGIN' then '开工未完工'
|
|
when icsmo2user.OPCODE is null then '未派工'
|
|
when i.ACTIONRESULT IS NULL THEN '未开工'
|
|
when i.ACTIONRESULT = 'COLLECT_END' and g.Result is null and ncr.ID is not null then '自检不合格'
|
|
when i.ACTIONRESULT = 'COLLECT_END' and g.Result is null and ncr.ID is null then '完工未检验'
|
|
when i.ACTIONRESULT = 'COLLECT_END' and g.Result = '合格' then '检验合格'
|
|
wheN i.ACTIONRESULT = 'COLLECT_END' and g.Result = '不合格' then '检验不合格'
|
|
end as status,
|
|
icsmo2user.prlineid as prline,
|
|
po.pocode
|
|
FROM
|
|
ICSMO A
|
|
INNER JOIN ICSITEMLot B ON B.TransNO = A.MOCODE AND a.MOSEQ=b.TransLine-- B.MCODE = A.MOCODE -- ICSMO2Lot
|
|
-- left join Base_Inventory c on c.ItemCode = A.ITEMCODE
|
|
LEFT JOIN ICSINVENTORY c ON c.INVCODE = A.ITEMCODE
|
|
inner JOIN ICSITEMROUTE2OPLot e ON e.LotNo = b.LotNO
|
|
LEFT JOIN ICSOP f ON f.opcode = e.OPCODE
|
|
-- LEFT JOIN ICSEQPSTPEMODEL p ON p.ItemCode = a.ItemCode
|
|
-- AND p.OPCODE = f.opcode
|
|
-- AND p.EQPCODE = e.MainResources
|
|
-- AND p.ISREF = '是'
|
|
LEFT JOIN icsmo2user ON icsmo2user.lotno = b.LOTNO
|
|
AND icsmo2user.OPCODE = f.opcode
|
|
left join ICSLOTONWIP i on i.lotno=b.lotno and i.opcode=f.OPcode
|
|
left join ICSLOTONWIPCheck g on g.ONWIPID=i.id
|
|
left join ICSPO_PoMain po on po.free1=icsmo2user.prlineid
|
|
left join ICSNCRDoc ncr on ncr.LOTNO=i.LotNO and ncr.OPCode=i.OPCODE and ncr.ErrorType='自检'
|
|
--left join {0}.dbo.PU_AppVouchs u on u.autoid=icsmo2user.prlineid
|
|
-- left join {0}.dbo.PU_AppVouch v on v.id=u.id
|
|
where a.mobiosver='审核'
|
|
)a
|
|
where 1=1 ", erpconstr);
|
|
|
|
string sqlwhere = "";
|
|
if (txtMoLotCode.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" and A.MOVER like '%{0}%'", txtMoLotCode.Text);
|
|
}
|
|
if (txtMOCODE.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" and A.工单号 like '%{0}%'", txtMOCODE.Text);
|
|
}
|
|
if (txtLotNo.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" AND A.产品跟踪单号 like '%{0}%'", txtLotNo.Text);
|
|
}
|
|
if (txtITEMCODE.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" AND A.料号 LIKE '%{0}%'", txtITEMCODE.Text);
|
|
|
|
}
|
|
if (txtItemName.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" and A.料品名称 LIKE '%{0}%'", txtItemName.Text);
|
|
}
|
|
if (txtDepart.Text != "")
|
|
{
|
|
sqlwhere += string.Format("and A.生产部门 like '%{0}%'", txtDepart.Text);
|
|
}
|
|
if (txtOpDesc.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" and A.工序编码 like '%{0}%' ", txtOpDesc.Text);
|
|
}
|
|
if (txtOrderNo.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" and A.项目号 like '%{0}%' ", txtOrderNo.Text);
|
|
}
|
|
//if (textItemStd.Text != "")
|
|
//{
|
|
// sqlwhere += string.Format(" and c.INVSTD like '%{0}%'", textItemStd.Text);
|
|
//}
|
|
//if (dateTimePicker1.Checked)
|
|
//{
|
|
// sqlwhere += string.Format(" AND Convert(varchar(12),icsmo2user.MTIME,23) between '{0}' AND '{1}'", dateTimePicker1.Value.ToString("YYYY-MM-DD"), dateTimePicker2.Value.ToString("YYYY-MM-DD"));
|
|
//}
|
|
|
|
|
|
sql += sqlwhere + "order by a.工序次序";
|
|
DataTable lotMessage = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
dtLotno = lotMessage;
|
|
gridControl1.DataSource = lotMessage;
|
|
gridView1.BestFitColumns();
|
|
LoadGrd();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void gridControl1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
#region 已派工
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataView dv = dtLotno.DefaultView;
|
|
//dv.RowFilter = "是否已派工='是'";
|
|
dv.RowFilter = "是否已派工='True' and 已委外='False'";
|
|
|
|
gridControl1.DataSource = dv;
|
|
gridView1.BestFitColumns();
|
|
}
|
|
catch (Exception EX)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请先查询数据!");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataView dv = dtLotno.DefaultView;
|
|
//dv.RowFilter = "是否已派工='否'";
|
|
dv.RowFilter = "是否已派工='False'";
|
|
|
|
gridControl1.DataSource = dv;
|
|
gridView1.BestFitColumns();
|
|
}
|
|
catch (Exception EX)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请先查询数据!");
|
|
}
|
|
|
|
}
|
|
|
|
private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
|
{
|
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
|
|
}
|
|
}
|
|
|
|
private void gridView2_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
|
{
|
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
|
|
}
|
|
}
|
|
|
|
private void repositoryItemButtonEdit4_Click(object sender, EventArgs e)
|
|
{
|
|
Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
dic.Add("routeCode", gridView1.GetRowCellValue(gridView1.FocusedRowHandle, routeCode).ToString());
|
|
dic.Add("OPNAME", gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colopname).ToString());
|
|
dic.Add("ITEMCODE", gridView1.GetRowCellValue(gridView1.FocusedRowHandle, itemCode).ToString());
|
|
dic.Add("opseq", gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colopSeq).ToString());
|
|
dic.Add("Pic", gridView1.GetRowCellValue(gridView1.FocusedRowHandle, colpic).ToString());
|
|
FormICSPicture pic = new FormICSPicture(dic);
|
|
pic.ShowDialog();
|
|
}
|
|
|
|
private void repositoryItemButtonEdit4_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string url = @"http://172.16.12.155:8999/api/GetPLMToken";
|
|
//string url = @"http://localhost:51182/api/GetPLMToken";
|
|
FormICSProductionReport.SearchPart Bills = new FormICSProductionReport.SearchPart();
|
|
//Bills.ItemCode = "20100003035";
|
|
//Bills.ItemCode = "20100000670";
|
|
//Bills.ItemCode = "20800001904";
|
|
|
|
Bills.ItemCode = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, itemCode).ToString();
|
|
Bills.size = 100;
|
|
Bills.extra = "DWGSW";
|
|
string JsonData = JsonConvert.SerializeObject(Bills);
|
|
|
|
//try
|
|
//{
|
|
// //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
|
|
// Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
|
|
//}
|
|
#region MyRegion
|
|
ICSSoft.Frame.APP.FormICSProductionReport.BaseModel rtn = PLMMap(url, JsonData);
|
|
if (rtn.code == "200")
|
|
{
|
|
|
|
#region MyRegion
|
|
|
|
|
|
string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]");
|
|
if (string.IsNullOrWhiteSpace(connectionString))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("没有获取到FTP链接,请在数据源中先配置FTP");
|
|
return;
|
|
}
|
|
|
|
string[] ftps = connectionString.Split(';');
|
|
string ftpServerIP = ftps[0].Split('=')[1];
|
|
//string ftpRemotePath = ftps[1].Split('=')[1];
|
|
string ftpRemotePath = "";
|
|
|
|
string ftpUserID = ftps[2].Split('=')[1];
|
|
string ftpPassword = ftps[3].Split('=')[1];
|
|
|
|
FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
|
|
//FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
|
|
|
|
//string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
|
|
|
|
string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
|
|
|
|
|
|
if (!Directory.Exists(filePath))
|
|
{
|
|
Directory.CreateDirectory(filePath);
|
|
}
|
|
string fileName = Bills.ItemCode + ".pdf";
|
|
ftpWeb.Download(filePath + "\\", fileName);
|
|
|
|
string filePathName = filePath + "\\" + fileName;
|
|
//string fileName = logAdress + Bills.ItemCode + ".pdf";
|
|
|
|
|
|
string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
|
|
|
|
//if (!string.IsNullOrEmpty(fileName))
|
|
if (!string.IsNullOrEmpty(filePathName))
|
|
{
|
|
FileDrawing.LoadPDF(filePathName);
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg);
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
public static ICSSoft.Frame.APP.FormICSProductionReport.BaseModel PLMMap(string URL, string JsonData)
|
|
{
|
|
try
|
|
{
|
|
//调用接口获取返回信息
|
|
//string ContentType = "application/json;charset=UTF-8;";
|
|
string ContentType = "application/json";
|
|
|
|
WebRequest request = WebRequest.Create(URL);
|
|
request.Method = "POST";
|
|
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(JsonData);
|
|
request.ContentType = ContentType;
|
|
request.ContentLength = bytes.Length;
|
|
//using (Stream postStream = request.GetRequestStream())
|
|
//{
|
|
// postStream.Write(bytes, 0, bytes.Length);
|
|
//}
|
|
using (Stream postStream = request.GetRequestStream())
|
|
{
|
|
postStream.Write(bytes, 0, bytes.Length);
|
|
}
|
|
request.Credentials = CredentialCache.DefaultCredentials;
|
|
string str = string.Empty;
|
|
WebResponse response = null;
|
|
try
|
|
{
|
|
response = request.GetResponse();
|
|
}
|
|
catch (WebException ex)
|
|
{
|
|
if (ex.Status == WebExceptionStatus.ProtocolError)
|
|
response = (WebResponse)ex.Response;
|
|
}
|
|
if (response != null)
|
|
{
|
|
using (StreamReader st = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
|
|
{
|
|
str = System.Web.HttpUtility.UrlDecode(st.ReadToEnd());
|
|
}
|
|
}
|
|
|
|
//将返回的string类型转换成model
|
|
ICSSoft.Frame.APP.FormICSProductionReport.BaseModel obj = (ICSSoft.Frame.APP.FormICSProductionReport.BaseModel)Newtonsoft.Json.JsonConvert.DeserializeObject(str, typeof(ICSSoft.Frame.APP.FormICSProductionReport.BaseModel));
|
|
//string obj = (string)Newtonsoft.Json.JsonConvert.DeserializeObject(str, typeof(string));
|
|
|
|
return obj;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("调用MES接口错误:" + ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 清空
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void buttonclear_Click(object sender, EventArgs e)
|
|
{
|
|
foreach (Control a in groupControl2.Controls)
|
|
{
|
|
if (a is TextEdit && a is LookUpEdit == false)
|
|
{
|
|
TextEdit edit = a as TextEdit;
|
|
edit.Text = "";
|
|
}
|
|
else if (a is LookUpEdit)
|
|
{
|
|
LookUpEdit edit = a as LookUpEdit;
|
|
edit.EditValue = null;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
private void txtDepart_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
FormDataRefer refer = new FormDataRefer();
|
|
//string sql = "select modept as 部门名称 from icsmo group by modept having len(modept)>0";
|
|
string sql = "select MDeptCode as 部门名称 from icsmo group by MDeptCode having len(MDeptCode)>0";
|
|
DataTable source = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
refer.FormTitle = "生产部门";
|
|
refer.FormWidth = 500;
|
|
refer.FormHeight = 500;
|
|
refer.RowIndexWidth = 35;
|
|
refer.MSelectFlag = false;
|
|
refer.DataSource = source;
|
|
if (refer.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable table = refer.ReturnData;
|
|
foreach (DataRow a in table.Rows)
|
|
{
|
|
txtDepart.Text = a["部门名称"].ToString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public void LoadOp()
|
|
{
|
|
//string sql = "select a.OPCODE as 工序代码,a.OPDESC as 工序名称 from ICSOP a";
|
|
|
|
//DataTable source = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
//txtOpDesc.Properties.ValueMember = "工序代码";
|
|
//txtOpDesc.Properties.DisplayMember = "工序代码";
|
|
//txtOpDesc.Properties.DataSource = source;
|
|
//txtOpDesc.Properties.NullText = "";
|
|
//txtOpDesc.Properties.ValidateOnEnterKey = true;//回车确认
|
|
//txtOpDesc.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
//txtOpDesc.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//txtOpDesc.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
|
|
}
|
|
|
|
#region 委外保存
|
|
private void BtnWWSave_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;
|
|
}
|
|
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
if (gridView1.GetRowCellValue(i, pgstatus).ToString() != "未派工")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("批号:" + gridView1.GetRowCellValue(i, colLOTNO).ToString() + ",工序:" + gridView1.GetRowCellValue(i, opCode).ToString() + ",已经派工,请勿重复操作!");
|
|
return;
|
|
}
|
|
|
|
#region 20210728已经开工的工序不能再操作
|
|
string sqlCheck = @"SELECT COUNT(*) FROM ICSLOTONWIP WHERE LOTNO='" + gridView1.GetRowCellValue(i, colLOTNO).ToString() + "' AND OPCODE='" + gridView1.GetRowCellValue(i, opCode).ToString() + "'";
|
|
DataTable DTCheck = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlCheck).Tables[0];
|
|
if (DTCheck != null && DTCheck.Rows.Count > 0)
|
|
{
|
|
int a = Int32.Parse(DTCheck.Rows[0][0].ToString());
|
|
if (a > 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("批号:" + gridView1.GetRowCellValue(i, colLOTNO).ToString() + ",工序:" + gridView1.GetRowCellValue(i, opCode).ToString() + ",已经开工,不能保存!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
FormICSMO2UserUIModel MO2UserInfo = new FormICSMO2UserUIModel();
|
|
MO2UserInfo.ID = "";
|
|
MO2UserInfo.MOCODE = gridView1.GetRowCellValue(i, moCode).ToString();
|
|
MO2UserInfo.LOTNO = gridView1.GetRowCellValue(i, colLOTNO).ToString();
|
|
//MO2UserInfo.SEGCODE = txtDepart.Text.ToString();
|
|
//if (!string.IsNullOrWhiteSpace(txtMOSEQ.Text.ToString()))
|
|
//{
|
|
// MO2UserInfo.MOSEQ = Int32.Parse(txtMOSEQ.Text.ToString());
|
|
//}
|
|
//else
|
|
//{
|
|
// MO2UserInfo.MOSEQ = Int32.Parse(gridView1.GetRowCellValue(i, colMOSEQ).ToString());
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(gridView1.GetRowCellValue(i, colMOSEQ).ToString()))
|
|
MO2UserInfo.MOSEQ = Int32.Parse(gridView1.GetRowCellValue(i, colMOSEQ).ToString());
|
|
|
|
MO2UserInfo.RouteCode = gridView1.GetRowCellValue(i, routeCode).ToString();
|
|
MO2UserInfo.OPCODE = gridView1.GetRowCellValue(i, opCode).ToString();
|
|
MO2UserInfo.USERCODE = grvDetail.GetRowCellValue(0, colUSERCODE).ToString();
|
|
MO2UserInfo.USERName = grvDetail.GetRowCellValue(0, colUSERName).ToString();
|
|
MO2UserInfo.EQPCode = grvDetail.GetRowCellValue(0, colEQPCode).ToString();
|
|
MO2UserInfo.EQPName = grvDetail.GetRowCellValue(0, colEQPName).ToString();
|
|
MO2UserInfo.MUSER = AppConfig.UserCode;
|
|
MO2UserInfo.MUSERName = AppConfig.UserName;
|
|
MO2UserInfo.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
MO2UserInfo.WorkPoint = AppConfig.WorkPointCode;
|
|
MO2UserInfo.EATTRIBUTE1 = "1";
|
|
MO2UserInfo.PlanDate = int.Parse(AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd"));
|
|
MO2UserInfo.SEGCODE= Convert.ToBoolean(gridView1.GetRowCellValue(i, ISAGV)) == true ? "1" : "0";
|
|
if (string.IsNullOrEmpty(grvDetail.GetRowCellValue(0, colPlanDate).ToString()) == false)
|
|
{
|
|
MO2UserInfo.SendPlanDate = Convert.ToDateTime(grvDetail.GetRowCellValue(0, colPlanDate).ToString());
|
|
}
|
|
|
|
MO2UserInfoList.Add(MO2UserInfo);
|
|
//if (string.IsNullOrEmpty(MO2UserInfo.USERCODE) || string.IsNullOrEmpty(MO2UserInfo.EQPCode))
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("请分配员工和设备后再保存!");
|
|
// return;
|
|
//}
|
|
}
|
|
}
|
|
try
|
|
{
|
|
ICSMO2UserBLL.Add(MO2UserInfoList, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox(0, "委外保存成功");
|
|
simpleSearch_Click(null, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
|
|
btnFalsh_Click(null, null);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 委外撤销 0917+同时取消派工 如果已产生鼎捷采购单则同时删除单据
|
|
private void BtnWWCancel_Click(object sender, EventArgs e)
|
|
{
|
|
string lotno = "";
|
|
List<string> lotnoList = new List<string>();
|
|
List<FormICSMO2UserUIModel> MO2UserInfoList = new List<FormICSMO2UserUIModel>();
|
|
|
|
List<string> lotnos = new List<string>();
|
|
List<string> opcode = new List<string>();
|
|
// List<FormICSMO2UserUIModel> MO2UserInfoLists = new List<FormICSMO2UserUIModel>();
|
|
List<DDMaster> dmasters = new List<DDMaster>();
|
|
List<string> pos = new List<string>();
|
|
|
|
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("委外撤销会删除鼎捷委外采购单,确认吗") != DialogResult.OK)
|
|
return;
|
|
|
|
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 (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y" && gridView1.GetRowCellValue(i, isSend).ToString() == "True")
|
|
{
|
|
lotnos.Add(gridView1.GetRowCellValue(i, colLOTNO).ToString());
|
|
opcode.Add(gridView1.GetRowCellValue(i, opCode).ToString());
|
|
|
|
var po = gridView1.GetRowCellValue(i, prline).ToString();
|
|
if (!String.IsNullOrEmpty(po)&&po.Contains("-"))
|
|
{
|
|
if (!pos.Contains(po.Substring(0,po.LastIndexOf("-"))))
|
|
{
|
|
DDMaster dmaster = new DDMaster();
|
|
dmaster.dflag = "Y";
|
|
dmaster.pmdldocno = po.Substring(0, po.LastIndexOf("-"));
|
|
dmasters.Add(dmaster);
|
|
pos.Add(po.Substring(0, po.LastIndexOf("-")));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
if (lotnoList.Count < 1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择需要委外撤销的数据!!!");
|
|
return;
|
|
}
|
|
|
|
if (lotnos.Count < 1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("未选择产品追踪码或选中项还未派单!!!");
|
|
return;
|
|
}
|
|
|
|
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
#region OLD
|
|
////if (!string.IsNullOrEmpty(gridView1.GetRowCellValue(i, prline).ToString())) {
|
|
//// ICSBaseSimpleCode.AppshowMessageBox("追踪单号:"+ gridView1.GetRowCellValue(i, colLOTNO).ToString()+",工序:"+ gridView1.GetRowCellValue(i, opCode).ToString()+"已产生委外请购单,无法撤销!");
|
|
//// return;
|
|
////}
|
|
|
|
//FormICSMO2UserUIModel MO2UserInfo = new FormICSMO2UserUIModel();
|
|
//MO2UserInfo.ID = "";
|
|
//MO2UserInfo.MOCODE = gridView1.GetRowCellValue(i, moCode).ToString();
|
|
//MO2UserInfo.LOTNO = gridView1.GetRowCellValue(i, colLOTNO).ToString();
|
|
//MO2UserInfo.SEGCODE = txtDepart.Text.ToString();
|
|
////if (!string.IsNullOrWhiteSpace(txtMOSEQ.Text.ToString()))
|
|
////{
|
|
//// MO2UserInfo.MOSEQ = Int32.Parse(txtMOSEQ.Text.ToString());
|
|
////}
|
|
////else
|
|
////{
|
|
//// MO2UserInfo.MOSEQ = 0;
|
|
////}
|
|
//if (!string.IsNullOrWhiteSpace(gridView1.GetRowCellValue(i, colMOSEQ).ToString()))
|
|
// MO2UserInfo.MOSEQ = Int32.Parse(gridView1.GetRowCellValue(i, colMOSEQ).ToString());
|
|
|
|
//MO2UserInfo.RouteCode = gridView1.GetRowCellValue(i, routeCode).ToString();
|
|
//MO2UserInfo.OPCODE = gridView1.GetRowCellValue(i, opCode).ToString();
|
|
//MO2UserInfo.USERCODE = grvDetail.GetRowCellValue(0, colUSERCODE).ToString();
|
|
//MO2UserInfo.USERName = grvDetail.GetRowCellValue(0, colUSERName).ToString();
|
|
//MO2UserInfo.EQPCode = grvDetail.GetRowCellValue(0, colEQPCode).ToString();
|
|
//MO2UserInfo.EQPName = grvDetail.GetRowCellValue(0, colEQPName).ToString();
|
|
//MO2UserInfo.MUSER = AppConfig.UserCode;
|
|
//MO2UserInfo.MUSERName = AppConfig.UserName;
|
|
//MO2UserInfo.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
//MO2UserInfo.WorkPoint = AppConfig.WorkPointCode;
|
|
//MO2UserInfo.EATTRIBUTE1 = "0";
|
|
//MO2UserInfo.PlanDate = int.Parse(AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd"));
|
|
//if (string.IsNullOrEmpty(grvDetail.GetRowCellValue(0, colPlanDate).ToString()) == false)
|
|
//{
|
|
// MO2UserInfo.SendPlanDate = Convert.ToDateTime(grvDetail.GetRowCellValue(0, colPlanDate).ToString());
|
|
//}
|
|
////判断该单据是否已生成u8请购单
|
|
|
|
|
|
//MO2UserInfoList.Add(MO2UserInfo);
|
|
#endregion
|
|
}
|
|
}
|
|
try
|
|
{
|
|
//ICSMO2UserBLL.Add(MO2UserInfoList, AppConfig.AppConnectString);
|
|
//ICSBaseSimpleCode.AppshowMessageBox(0, "委外撤销成功");
|
|
|
|
DOutSourceDto dto = new DOutSourceDto();
|
|
dto.key = PoKey;
|
|
dto.type = "sync";
|
|
|
|
|
|
DHost host = new DHost();
|
|
host.prod = "APP";
|
|
host.lang = "zh_CN";
|
|
host.timestamp = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
|
host.acct = "tiptop";
|
|
host.ip = WebHelper.GetIp();//ip地址
|
|
|
|
|
|
DService service = new DService();
|
|
service.prod = "T100";
|
|
service.name = "CPurchaseOrderCreate";
|
|
service.ip = "172.16.11.152";
|
|
service.id = "topprd";
|
|
|
|
|
|
Datakey datakey = new Datakey();
|
|
datakey.CompanyId = CompanyId;
|
|
datakey.EntId = EntId;
|
|
|
|
DPayload pay = new DPayload();
|
|
|
|
DStd_data std = new DStd_data();
|
|
|
|
DDParameter param = new DDParameter();
|
|
param.master = dmasters;
|
|
|
|
std.parameter = param;
|
|
|
|
pay.std_data = std;
|
|
|
|
dto.datakey = datakey;
|
|
dto.host = host;
|
|
dto.service = service;
|
|
dto.payload = pay;
|
|
|
|
DReturn rtn = WebHelper.HttpPost<DReturn>(DjAddress, JsonConvert.SerializeObject(dto));
|
|
var errormes = "";
|
|
if (rtn.payload.std_data.execution.code != "0")
|
|
{
|
|
errormes = string.Join("\r\n", rtn.payload.std_data.parameter.fail_return.Select(a => a.error_msg).ToList());
|
|
|
|
}
|
|
ICSMO2UserDAL.WriteLogFile("Params:" + JsonConvert.SerializeObject(dto) + "\r\n" + "returns:" + JsonConvert.SerializeObject(rtn), "鼎捷委外采购单");
|
|
if (!string.IsNullOrEmpty(errormes))
|
|
throw new Exception(errormes);
|
|
|
|
ICSMO2UserBLL.cancelSendWW(lotnos, opcode, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox(0, "委外撤销成功");
|
|
//ICSBaseSimpleCode.AppshowMessageBox(0, "取消成功");
|
|
|
|
simpleSearch_Click(null, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
|
|
btnFalsh_Click(null, null);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 创建ERP PR
|
|
private void BtnCreatePR_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定产生委外请购单吗?") != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
int count = 0;
|
|
for(int i = 0;i< gridView1.RowCount; i++){
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y") {
|
|
count++;
|
|
}
|
|
}
|
|
if (count <= 0) {
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
|
|
return;
|
|
}
|
|
FormICSVenDorChoose v = new FormICSVenDorChoose();
|
|
if (v.ShowDialog() != DialogResult.OK)
|
|
return;
|
|
|
|
|
|
string Vencode = v.Vencode;
|
|
string VenNAME = v.VenName;
|
|
|
|
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在创建...请稍等...");
|
|
try
|
|
{
|
|
_wait.Show();
|
|
|
|
|
|
|
|
#region 老
|
|
//从配置中获取
|
|
// 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>();
|
|
// List<string> de = new List<string>();
|
|
// PU_AppVouch contextWW = new PU_AppVouch();
|
|
// contextWW.UserCode = AppConfig.UserCode;
|
|
// contextWW.UserName = AppConfig.UserName;
|
|
// contextWW.TargetAccount = ConfigurationManager.AppSettings["TargetAccountU8"];
|
|
// string sqladdress = "select '['+DBIPADDRESS+']'+'.'+DBNAME as address from Sys_DataBase where dbsourcename='ERP'";
|
|
// string ipaddress = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqladdress).Tables[0].Rows[0]["address"].ToString();
|
|
// for (int i = 0; i < gridView1.RowCount; i++) {
|
|
// if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y") {
|
|
// string lotNO = gridView1.GetRowCellValue(i, colLOTNO).ToString();
|
|
// string MOCode = gridView1.GetRowCellValue(i, moCode).ToString();
|
|
// string MOSEQ = gridView1.GetRowCellValue(i, colMOSEQ).ToString();
|
|
// string MCODE = gridView1.GetRowCellValue(i, itemCode).ToString();
|
|
// string opcode = gridView1.GetRowCellValue(i, opCode).ToString();
|
|
|
|
// string sql = @"SELECT DISTINCT PRLineID from ICSMO2User WHERE MOCODE='" + MOCode + "' AND LOTNO='" + lotNO + "' AND EATTRIBUTE1=1 and opcode='" + opcode + "' and prlineid is not null ";
|
|
// DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
// if (dt.Rows.Count > 0) {
|
|
// _wait.Close();
|
|
// ICSBaseSimpleCode.AppshowMessageBox("追踪单:" + lotNO + " 工序:" + opcode + "已产生委外请购单!");
|
|
// return;
|
|
// }
|
|
// sql = @"SELECT * FROM ICSMO2USER WHERE MOCODE='"+ MOCode + "' and lotno='"+lotNO+ "' and EATTRIBUTE1=1 and opcode='" + opcode + "'";
|
|
// dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
// if (dt.Rows.Count<=0)
|
|
// {
|
|
// _wait.Close();
|
|
// ICSBaseSimpleCode.AppshowMessageBox("追踪单:" + lotNO + " 工序:" + opcode + "不是委外工序或未派工无法生成委外请购单!");
|
|
// return;
|
|
// }
|
|
// //查询工单部门
|
|
// string sqldepart = @"SELECT MDeptCode,b.closetime
|
|
// FROM "+ ipaddress+ @".dbo.mom_order a
|
|
// INNER JOIN " + ipaddress + @".dbo.mom_orderdetail b ON a.MoId = b.MoId
|
|
// WHERE a.MoCode = '" + MOCode + "' and b.SortSeq='" + MOSEQ + "'";
|
|
|
|
// DataTable depart = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqldepart).Tables[0];
|
|
// if (depart.Rows.Count > 0)
|
|
// {
|
|
// if (!de.Contains(depart.Rows[0]["MDeptCode"].ToString())) {
|
|
// de.Add(depart.Rows[0]["MDeptCode"].ToString());
|
|
// }
|
|
// if (!String.IsNullOrEmpty(depart.Rows[0]["closetime"].ToString()))
|
|
// {
|
|
// ICSBaseSimpleCode.AppshowMessageBox("工单号:" + MOCode + ",工单行:" + MOSEQ + "已关闭!");
|
|
// _wait.Close();
|
|
// return;
|
|
// }
|
|
// }
|
|
// if (de.Count == 0) {
|
|
// ICSBaseSimpleCode.AppshowMessageBox("获取工单部门失败!");
|
|
// return;
|
|
// }
|
|
// if (de.Count > 1) {
|
|
// ICSBaseSimpleCode.AppshowMessageBox("请选择相同部门的条码!");
|
|
// return;
|
|
// }
|
|
|
|
// contextWW.cDepCode = depart.Rows[0]["MDeptCode"].ToString();
|
|
// #region
|
|
// string sqlQty = @"
|
|
//SELECT A.MOCODE, B.MCODE AS MCODE,dd.INVNAME, A.OPCODE, D.OPDESC AS PRLineID, SUM (B.LOTQTY) AS PRQty,a.lotno,a.MOSEQ,
|
|
//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 dd ON b.MCODE =dd.INVCODE
|
|
//WHERE A.MOCODE = '" + MOCode + "' AND B.MCODE = '" + MCODE + "' AND A.MOSEQ = '" + MOSEQ + @"' AND A.EATTRIBUTE1 = 1 and a.lotno='" + lotNO + @"' and a.opcode='" + opcode + @"'
|
|
//AND (A.PRLineID IS NULL OR A.PRLineID = '') GROUP BY A.MOCODE, dd.INVNAME, A.OPCODE, B.MCODE, D.OPDESC,a.lotno,a.MOSEQ ";//UPDATE BY SUMMER 2020.06.17
|
|
// #endregion
|
|
// DataTable dtQty = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlQty).Tables[0];
|
|
|
|
// if (dtQty != null && dtQty.Rows.Count > 0)
|
|
// {
|
|
// foreach (DataRow _dr in dtQty.Rows)
|
|
// {
|
|
// PU_AppVouchs contextsWW = new PU_AppVouchs();
|
|
// contextsWW.cInvCCode = _cInvCCode;//物料大类
|
|
// contextsWW.cInvCode = _dr["MCODE"].ToString();//料号
|
|
// contextsWW.cInvName = _dr["INVNAME"].ToString();//料号名称
|
|
|
|
// contextsWW.OPCode = _dr["OPCODE"].ToString();//工序
|
|
// contextsWW.iQuantity = Decimal.Parse(_dr["PRQty"].ToString());
|
|
// contextsWW.iNum = Convert.ToInt32(MOSEQ);// 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 = lotNO;//产品产品跟踪单号
|
|
// contextsWWList.Add(contextsWW);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// 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")
|
|
// {
|
|
// _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("未获取到请购单数据!");
|
|
// }
|
|
|
|
// //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 lotno = '" +item.LotNo+ "' AND EATTRIBUTE1 = 1 and moseq='"+item.iNum+"'";//AND LOTNO = '" + item.LotNo + "' "; //update by summer 2020.07.13
|
|
// UpdateSql = string.Format(UpdateSql);
|
|
// DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, UpdateSql);
|
|
// }
|
|
#endregion
|
|
|
|
List<DMaster> masters = new List<DMaster>();
|
|
|
|
DMaster master = new DMaster();
|
|
master.source_no = AppConfig.GetGuid();
|
|
master.pmdl001 = "0";
|
|
master.pmdldocno = PoDocNo;
|
|
master.pmdl002 = AppConfig.UserCode;
|
|
master.pmdl003 = "10000";
|
|
master.pmdl004 = Vencode;//供应商编号
|
|
master.pmdl005 = "2";
|
|
master.pmdl007 = "4";
|
|
master.pmdl008 = "";
|
|
master.pmdl009 = "";
|
|
master.pmdl010 = "";
|
|
master.pmdl011 = "";
|
|
master.pmdl012 = "";
|
|
master.pmdl013 = "";
|
|
master.pmdl015 = "";
|
|
master.pmdl016 = "";
|
|
master.pmdl017 = "";
|
|
master.pmdl033 = "";
|
|
master.pmdl040 = "0";
|
|
master.pmdl041 = "0";
|
|
master.pmdl042 = "0";
|
|
master.pmdl054 = "";
|
|
|
|
master.detail = new List<DDetail>();
|
|
masters.Add(master);
|
|
|
|
count =1;
|
|
Dictionary<string, string> opcodes = new Dictionary<string, string>();
|
|
for (int i = 0; i < gridView1.RowCount; i++)
|
|
{
|
|
|
|
|
|
if (gridView1.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
string lotNO = gridView1.GetRowCellValue(i, colLOTNO).ToString();
|
|
string MOCode = gridView1.GetRowCellValue(i, moCode).ToString();
|
|
string MOSEQ = gridView1.GetRowCellValue(i, colMOSEQ).ToString();
|
|
string MCODE = gridView1.GetRowCellValue(i, itemCode).ToString();
|
|
string opcode = gridView1.GetRowCellValue(i, opCode).ToString();
|
|
string opseq= gridView1.GetRowCellValue(i, colopSeq).ToString();
|
|
string lotqty= gridView1.GetRowCellValue(i, gridColumn8).ToString();
|
|
|
|
|
|
|
|
string sql = @"SELECT DISTINCT PRLineID from ICSMO2User WHERE MOCODE='" + MOCode + "' AND LOTNO='" + lotNO + "' AND EATTRIBUTE1=1 and opcode='" + opcode + "' and prlineid is not null ";
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("追踪单:" + lotNO + " 工序:" + opcode + "已产生委外请购单!");
|
|
return;
|
|
}
|
|
sql = @"SELECT * FROM ICSMO2USER WHERE MOCODE='" + MOCode + "' and lotno='" + lotNO + "' and EATTRIBUTE1=1 and opcode='" + opcode + "'";
|
|
dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if (dt.Rows.Count <= 0)
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("追踪单:" + lotNO + " 工序:" + opcode + "不是委外工序或未派工无法生成委外请购单!");
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
DDetail detail = new DDetail();
|
|
detail.pmdn001 = MCODE; ;
|
|
detail.pmdn004 = opcode.Substring(0,opcode.LastIndexOf('-'));
|
|
detail.pmdn005 = opseq;
|
|
detail.pmdn006 = "";
|
|
detail.pmdn007 = lotqty;
|
|
detail.pmdn010 = "";
|
|
detail.pmdn011 = lotqty;
|
|
detail.pmdn012 = DateTime.Now.ToString("yyyy-MM-dd");
|
|
detail.pmdn015 = "0";
|
|
detail.pmdn016 = "";
|
|
detail.pmdn017 = "";
|
|
detail.pmdp003 = MOCode;
|
|
detail.pmdp004 = "0";
|
|
detail.pmdp005 = "0";
|
|
detail.pmdp006 = "0";
|
|
detail.pmdn050 = lotNO;
|
|
if(AppConfig.GetDataBaseNameByConnectString(AppConfig.AppConnectString)== "ICSMES_GT_DJ")
|
|
detail.pmdn028 = "HG01";
|
|
else
|
|
detail.pmdn028 = "HH01";
|
|
|
|
detail.source_seq = count.ToString();
|
|
detail.pmdnseq = count.ToString();
|
|
|
|
opcodes.Add(lotNO+ detail.pmdn004 + detail.pmdn005, opcode);
|
|
|
|
//var masterIn = masters.Where(a => a.pmdl008 == MOCode).FirstOrDefault();
|
|
|
|
//if (masterIn == null)
|
|
//{
|
|
// masterIn = master;
|
|
// masters.Add(masterIn);
|
|
//}
|
|
|
|
//if (masterIn.detail == null)
|
|
//{
|
|
// detail.pmdnseq = "1";
|
|
// detail.source_seq = "1";
|
|
// masterIn.detail = new List<DDetail>();
|
|
//}
|
|
//else
|
|
//{
|
|
// detail.pmdnseq = (masterIn.detail.Max(a => Convert.ToDecimal(a.pmdnseq)) + 1).ToString();
|
|
// detail.source_seq = detail.pmdnseq;
|
|
//}
|
|
|
|
//masterIn.detail.Add(detail);
|
|
master.detail.Add(detail);
|
|
count++;
|
|
}
|
|
}
|
|
if (masters.Count <= 0)
|
|
throw new Exception("请选择要委外的数据!");
|
|
|
|
|
|
OutSourceDto dto = new OutSourceDto();
|
|
dto.key = PoKey;
|
|
dto.type = "sync";
|
|
|
|
|
|
DHost host = new DHost();
|
|
host.prod = "APP";
|
|
host.lang = "zh_CN";
|
|
host.timestamp = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
|
host.acct = "tiptop";
|
|
host.ip = WebHelper.GetIp();//ip地址
|
|
|
|
|
|
DService service = new DService();
|
|
service.prod = "T100";
|
|
service.name = "CPurchaseOrderCreate";
|
|
service.ip = "172.16.11.152";
|
|
service.id = "topprd";
|
|
|
|
|
|
Datakey datakey = new Datakey();
|
|
datakey.CompanyId = CompanyId;
|
|
datakey.EntId = EntId;
|
|
|
|
Payload pay = new Payload();
|
|
|
|
Std_data std = new Std_data();
|
|
|
|
DParameter param = new DParameter();
|
|
param.master = masters;
|
|
|
|
std.parameter = param;
|
|
|
|
pay.std_data = std;
|
|
|
|
dto.datakey = datakey;
|
|
dto.host = host;
|
|
dto.service = service;
|
|
dto.payload = pay;
|
|
|
|
|
|
DReturn rtn = WebHelper.HttpPost<DReturn>(DjAddress, JsonConvert.SerializeObject(dto));
|
|
var errormes = "";
|
|
if (rtn.payload.std_data.execution.code != "0")
|
|
{
|
|
errormes = string.Join("\r\n", rtn.payload.std_data.parameter.fail_return.Select(a => a.error_msg).ToList());
|
|
|
|
}
|
|
ICSMO2UserDAL.WriteLogFile("Params:"+ JsonConvert.SerializeObject(dto)+"\r\n"+"returns:"+ JsonConvert.SerializeObject(rtn), "鼎捷委外采购单");
|
|
if (!string.IsNullOrEmpty(errormes))
|
|
throw new Exception(errormes);
|
|
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (var sucess in rtn.payload.std_data.parameter.success_return)
|
|
{
|
|
|
|
|
|
var poCode = sucess.success_msg;//采购单号
|
|
var sourceno = sucess.source_no;//对应的mes单号 唯一需要加上传入的行号
|
|
|
|
|
|
List<ICSPO_PoMain> pos = new List<ICSPO_PoMain>();
|
|
dto.payload.std_data.parameter.master.Where(a => a.source_no == sourceno).ToList().ForEach(a =>
|
|
{
|
|
|
|
a.detail.ForEach(b =>
|
|
{
|
|
ICSPO_PoMain po = new ICSPO_PoMain();
|
|
po.POCode = poCode;
|
|
po.PORow = b.pmdnseq;
|
|
var ops = opcodes.Where(c => c.Key == b.pmdn050 + b.pmdn004 + b.pmdn005).FirstOrDefault();
|
|
|
|
po.InvCode = b.pmdn001 + "_" + (ops.Value==null?(b.pmdn004+"-"+b.pmdn005):ops.Value);
|
|
po.PODate = DateTime.Now;
|
|
po.VenCode =Vencode;
|
|
po.VenName = VenNAME;
|
|
po.POType = "采购";
|
|
po.ProjectType = "工序委外采购";
|
|
po.Price = "0";
|
|
po.Status = '1';
|
|
po.CreatePerson = AppConfig.UserCode;
|
|
po.Quantity =Convert.ToDecimal(b.pmdn007);
|
|
po.ISUrgent = "";
|
|
po.ServerModel = "BS";
|
|
po.Free1 =po.POCode+"-"+po.PORow;
|
|
po.Free5 = a.source_no + "-" + b.source_seq;
|
|
po.WorkPoint = AppConfig.WorkPointCode;
|
|
po.MUSERName = AppConfig.UserName;
|
|
po.MTIME = DateTime.Now;
|
|
|
|
var newPo = db.ICSPO_PoMain.Where(c => c.POCode ==po.POCode && c.PORow == po.PORow).FirstOrDefault();
|
|
|
|
if (newPo != null)
|
|
{
|
|
throw new Exception("采购单号:" + po.POCode + ",行号:" + po.PORow + "已存在!");
|
|
}
|
|
newPo = po;
|
|
|
|
db.ICSPO_PoMain.InsertOnSubmit(newPo);
|
|
db.SubmitChanges();
|
|
|
|
var op = opcodes.Where(c => c.Key == b.pmdn050 + b.pmdn004 + b.pmdn005).FirstOrDefault();
|
|
|
|
var mo2=db.ICSMO2User.Where(mo2user => mo2user.LOTNO == b.pmdn050 && mo2user.OPCODE == op.Value).FirstOrDefault();
|
|
|
|
if (mo2 == null)
|
|
throw new Exception("获取派工记录失败!");
|
|
|
|
mo2.PRLineID= po.POCode + "-" + po.PORow;
|
|
|
|
var inv = db.ICSINVENTORY.Where(i => i.INVCODE == po.InvCode).FirstOrDefault();
|
|
if (inv == null)
|
|
{
|
|
var oldInv = db.ICSINVENTORY.Where(i => i.INVCODE == b.pmdn001).FirstOrDefault();
|
|
if (oldInv == null)
|
|
throw new Exception("获取物料信息:"+b.pmdn001+"失败!");
|
|
|
|
inv = JsonConvert.DeserializeObject<ICSINVENTORY>(JsonConvert.SerializeObject(oldInv));
|
|
inv.ID = AppConfig.GetGuid();
|
|
inv.INVCODE = po.InvCode;
|
|
inv.MUSER = AppConfig.UserCode;
|
|
inv.MUSERName = AppConfig.UserName;
|
|
inv.MTIME = DateTime.Now;
|
|
|
|
db.ICSINVENTORY.InsertOnSubmit(inv);
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("产生委外采购单成功!");
|
|
simpleSearch_Click(null, null);
|
|
}
|
|
catch (Exception _ex)
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox(_ex.Message);
|
|
|
|
}
|
|
}
|
|
}
|
|
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());
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void txtOpDesc_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
//var o = txtOpDesc.Properties.GetRowByKeyValue(txtOpDesc.EditValue);
|
|
//var o = txtOpDesc.Properties.GetRowByKeyValue(txtOpDesc.EditValue);
|
|
|
|
//if (o is DataRowView)
|
|
//{
|
|
// DataRowView RowView = o as DataRowView;
|
|
// if (RowView != null && RowView.DataView.Count > 0)
|
|
// {
|
|
// txtOpDesc.Text = RowView.Row["工序编码"].ToString();
|
|
// //txtOpName.Text = RowView.Row["工序名称"].ToString();
|
|
// }
|
|
//}
|
|
}
|
|
|
|
private void BtnWW_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataView dv = dtLotno.DefaultView;
|
|
//dv.RowFilter = "是否已派工='是'";
|
|
dv.RowFilter = "已委外='True'";
|
|
gridControl1.DataSource = dv;
|
|
gridView1.BestFitColumns();
|
|
}
|
|
catch (Exception EX)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请先查询数据!");
|
|
}
|
|
}
|
|
|
|
|
|
//键盘回车键按下
|
|
private void txtLotNo_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar == 13)
|
|
{
|
|
try
|
|
{
|
|
string erpconstr = GetERPConn();
|
|
string sql = string.Format(@"select * from (
|
|
SELECT DISTINCT
|
|
'' AS isSelect,
|
|
--A.ProjectCode AS 项目号,
|
|
E.ROUTECODE AS routeCode,
|
|
A.MOCODE AS 工单号,a.MOSEQ 工单行号,
|
|
A.ITEMCODE AS 料号,
|
|
a.MOVER,
|
|
B.LOTNO AS 产品跟踪单号,
|
|
C.INVNAME AS 料品名称,
|
|
--c.INVShelfLife as 料品图纸,
|
|
f.OPcode AS 工序编码,
|
|
f.OPdesc AS 工序,
|
|
e.OPSEQ AS 工序次序,
|
|
A.MDeptCode AS 生产部门,
|
|
'' as pictureSee,
|
|
--p.STIME AS 工时,
|
|
0 AS 工时,
|
|
--0908修改
|
|
A.MOPLANSTARTDATE AS 预计开工时间,
|
|
A.MOPLANENDDATE AS 预计完工时间,
|
|
CAST(case when ISNULL(icsmo2user.SEGCODE,'1')='' THEN '0' ELSE ISNULL(icsmo2user.SEGCODE,'0') END AS Bit) AS ISAGV,
|
|
cast(b.lotqty as int) AS 数量,
|
|
--b.lotqty AS 数量,
|
|
|
|
--CAST(CASE WHEN icsmo2user.OPCODE IS NULL or icsmo2user.EATTRIBUTE1!='1' THEN '0' ELSE '1' END AS BIT) AS 是否已派工,
|
|
CAST(CASE WHEN (icsmo2user.OPCODE IS NOT NULL or icsmo2user.EATTRIBUTE1='1' ) THEN '1' ELSE '0' END AS BIT) AS 是否已派工,
|
|
|
|
CAST(CASE WHEN icsmo2user.EATTRIBUTE1 ='1' THEN '1' ELSE '0' END AS BIT) AS 已委外,
|
|
case
|
|
when i.ACTIONRESULT = 'COLLECT_BEGIN' then '开工未完工'
|
|
when icsmo2user.OPCODE is null then '未派工'
|
|
when i.ACTIONRESULT IS NULL THEN '未开工'
|
|
when i.ACTIONRESULT = 'COLLECT_END' and g.Result is null and ncr.ID is not null then '自检不合格'
|
|
when i.ACTIONRESULT = 'COLLECT_END' and g.Result is null and ncr.ID is null then '完工未检验'
|
|
when i.ACTIONRESULT = 'COLLECT_END' and g.Result = '合格' then '检验合格'
|
|
wheN i.ACTIONRESULT = 'COLLECT_END' and g.Result = '不合格' then '检验不合格'
|
|
end as status,
|
|
icsmo2user.PrlineID as prline,
|
|
po.pocode
|
|
FROM
|
|
ICSMO A
|
|
INNER JOIN ICSITEMLot B ON B.TransNO = A.MOCODE AND a.MOSEQ=b.TransLine-- B.MCODE = A.MOCODE -- ICSMO2Lot
|
|
-- left join Base_Inventory c on c.ItemCode = A.ITEMCODE
|
|
LEFT JOIN ICSINVENTORY c ON c.INVCODE = A.ITEMCODE
|
|
inner JOIN ICSITEMROUTE2OPLot e ON e.LotNo = b.LotNO
|
|
LEFT JOIN ICSOP f ON f.opcode = e.OPCODE
|
|
-- LEFT JOIN ICSEQPSTPEMODEL p ON p.ItemCode = a.ItemCode
|
|
-- AND p.OPCODE = f.opcode
|
|
-- AND p.EQPCODE = e.MainResources
|
|
-- AND p.ISREF = '是'
|
|
LEFT JOIN icsmo2user ON icsmo2user.lotno = b.LOTNO
|
|
AND icsmo2user.OPCODE = f.opcode
|
|
left join ICSLOTONWIP i on i.lotno=b.lotno and i.opcode=f.OPcode
|
|
left join ICSLOTONWIPCheck g on g.ONWIPID=i.id
|
|
left join ICSPO_PoMain po on po.free1=icsmo2user.prlineid
|
|
--left join {0}.dbo.PU_AppVouchs u on u.autoid=icsmo2user.prlineid
|
|
--left join {0}.dbo.PU_AppVouch v on v.id=u.id
|
|
left join ICSNCRDoc ncr on ncr.LOTNO=i.LotNO and ncr.OPCode=i.OPCODE and ncr.ErrorType='自检'
|
|
)a
|
|
where 1=1 ", erpconstr);
|
|
|
|
string sqlwhere = "";
|
|
if (txtMoLotCode.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" and A.MOVER like '%{0}%'", txtMoLotCode.Text);
|
|
}
|
|
if (txtMOCODE.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" and A.工单号 like '%{0}%'", txtMOCODE.Text);
|
|
}
|
|
if (txtLotNo.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" AND A.产品跟踪单号 like '%{0}%'", txtLotNo.Text);
|
|
}
|
|
if (txtITEMCODE.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" AND A.料号 LIKE '%{0}%'", txtITEMCODE.Text);
|
|
|
|
}
|
|
if (txtItemName.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" and A.料品名称 LIKE '%{0}%'", txtItemName.Text);
|
|
}
|
|
if (txtDepart.Text != "")
|
|
{
|
|
sqlwhere += string.Format("and A.生产部门 like '%{0}%'", txtDepart.Text);
|
|
}
|
|
if (txtOpDesc.Text != "")
|
|
{
|
|
sqlwhere += string.Format(" and A.工序编码 like '%{0}%' ", txtOpDesc.Text);
|
|
}
|
|
//if (textItemStd.Text != "")
|
|
//{
|
|
// sqlwhere += string.Format(" and c.INVSTD like '%{0}%'", textItemStd.Text);
|
|
//}
|
|
//if (dateTimePicker1.Checked)
|
|
//{
|
|
// sqlwhere += string.Format(" AND Convert(varchar(12),icsmo2user.MTIME,23) between '{0}' AND '{1}'", dateTimePicker1.Value.ToString("YYYY-MM-DD"), dateTimePicker2.Value.ToString("YYYY-MM-DD"));
|
|
//}
|
|
|
|
|
|
sql += sqlwhere + "order by a.工序次序";
|
|
DataTable lotMessage = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
dtLotno = lotMessage;
|
|
gridControl1.DataSource = lotMessage;
|
|
gridView1.BestFitColumns();
|
|
LoadGrd();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
private void groupControl4_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
// repositoryItemGridLookUpEdit1
|
|
private void repositoryItemButtonEdit1_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
|
|
string USERCODEs = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colUSERCODE).ToString();
|
|
string sql = @"select a.EQPCode as [设备代码],a.EQPName as [设备名称],Type as [设备类型] from dbo.ICSEquipment a with(nolock)
|
|
left join ICSSkillMatrix b on b.equipmentType=a.EQPCode
|
|
where b.WorkNo='" + USERCODEs + "'";
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void txtOpDesc_EditValueChanged_1(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private string GetERPConn() {
|
|
string sql = "select dbipaddress,dbname from Sys_DataBase where dbsourcename='ERP'";
|
|
DataTable table = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
string dbip = table.Rows[0]["dbipaddress"].ToString();
|
|
string dbname= table.Rows[0]["dbname"].ToString();
|
|
string constr="["+dbip+"].["+dbname+"]";
|
|
return constr;
|
|
}
|
|
|
|
private void grdDetail_DataSourceChanged(object sender, EventArgs e)
|
|
{
|
|
grvDetail.BestFitColumns();
|
|
}
|
|
|
|
|
|
private void InsertPo(List<ICSPO_PoMain> poS, FramDataContext db)
|
|
{
|
|
try
|
|
{
|
|
poS.ForEach(a => {
|
|
var po = db.ICSPO_PoMain.Where(b => b.POCode == a.POCode && b.PORow == a.PORow).FirstOrDefault();
|
|
|
|
if (po != null)
|
|
{
|
|
throw new Exception("采购单号:"+po.POCode+",行号:"+po.PORow+"已存在!");
|
|
}
|
|
|
|
db.ICSPO_PoMain.InsertOnSubmit(a);
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|