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.
1445 lines
62 KiB
1445 lines
62 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using ICSSoft.Frame.User.BLL;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using System.Data.SqlClient;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Base.Lable.PrintTool;
|
|
using ICSSoft.Frame.Data.DAL;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSProjectReports : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
private string sqltxt = "";
|
|
private string sqlconn = "";
|
|
DataTable dt;
|
|
string opcodes = "";
|
|
string vencode = "";
|
|
string pocode = "";
|
|
Color color ;
|
|
private DataTable dataSource = null;
|
|
#region 构造函数
|
|
public FormICSProjectReports()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
button5.BackColor = Color.FromArgb(254,177,95);
|
|
checkDate.Checked = true;
|
|
txtStartDate.Value = new DateTime(DateTime.Now.Year,DateTime.Now.Month,1);
|
|
txtEndDate.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month,1).AddMonths(1).AddDays(-1);
|
|
Search();
|
|
|
|
}
|
|
#endregion
|
|
|
|
private void Search()
|
|
{
|
|
string sql = @"select * from dbo.ICSLOTONWIP order by MTIME desc";
|
|
sql = string.Format(sql);
|
|
dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
}
|
|
|
|
#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 权限
|
|
|
|
/// <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>();
|
|
|
|
//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 void init()
|
|
{
|
|
txtMOVER.Text = "";
|
|
txtStartDate.Enabled = false;
|
|
txtEndDate.Enabled = false;
|
|
#region 零件号
|
|
List<string> MoverCode = new List<string>();
|
|
MoverCode.Add("");
|
|
MoverCode.Add("等于");
|
|
MoverCode.Add("范围内");
|
|
|
|
cboMOVER.DataSource = MoverCode;
|
|
cboMOVER.SelectedIndex = 0;
|
|
txtMOVERS.Text = "";
|
|
txtMOVERE.Text = "";
|
|
#endregion
|
|
|
|
#region 存货编码
|
|
#region
|
|
// string sql = @"SELECT '' AS [存货编码],'' AS [存货名称]
|
|
// UNION
|
|
// SELECT DISTINCT INVCODE AS [存货编码],INVNAME AS [存货名称] FROM ICSINVENTORY ORDER BY [存货编码]";
|
|
// DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
// gluItemCode.Properties.ValueMember = "存货编码";
|
|
// gluItemCode.Properties.DisplayMember = "存货编码";
|
|
// gluItemCode.Properties.DataSource = dt;
|
|
// gluItemCode.Properties.NullText = "";//空时的值
|
|
// gluItemCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
// gluItemCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
// gluItemCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
// gluItemCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
// //自适应宽度
|
|
// gluItemCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
List<string> ItemCode = new List<string>();
|
|
ItemCode.Add("");
|
|
ItemCode.Add("等于");
|
|
ItemCode.Add("范围内");
|
|
|
|
cboItemCode.DataSource = ItemCode;
|
|
cboItemCode.SelectedIndex = 0;
|
|
txtItemCodeS.Text = "";
|
|
txtItemCodeE.Text = "";
|
|
#endregion
|
|
|
|
#region 途程代码
|
|
string sqlRoute = @"SELECT '' AS [途程代码],'' AS [途程描述]
|
|
UNION
|
|
SELECT DISTINCT ROUTECODE AS [途程代码],ROUTEDESC AS [途程描述] FROM ICSROUTE ORDER BY [途程代码]";
|
|
DataTable dtRoute = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlRoute).Tables[0];
|
|
gluRouteCode.Properties.ValueMember = "途程代码";
|
|
gluRouteCode.Properties.DisplayMember = "途程代码";
|
|
gluRouteCode.Properties.DataSource = dtRoute;
|
|
gluRouteCode.Properties.NullText = "";//空时的值
|
|
gluRouteCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
gluRouteCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
gluRouteCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
gluRouteCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
gluRouteCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
|
|
#region 状态
|
|
List<string> status = new List<string>();
|
|
status.Add("全部");
|
|
status.Add("良品");
|
|
status.Add("不良品");
|
|
//cboStatus.DataSource = status;
|
|
//cboStatus.SelectedIndex = 0;
|
|
#endregion
|
|
|
|
#region 工单号
|
|
List<string> MoCodes = new List<string>();
|
|
MoCodes.Add("");
|
|
MoCodes.Add("等于");
|
|
MoCodes.Add("范围内");
|
|
|
|
cboMoCode.DataSource = MoCodes;
|
|
cboMoCode.SelectedIndex = 0;
|
|
txtMoCodeS.Text = "";
|
|
txtMoCodeE.Text = "";
|
|
#endregion
|
|
|
|
#region 产品跟踪单号
|
|
List<string> LotNOs = new List<string>();
|
|
LotNOs.Add("");
|
|
LotNOs.Add("等于");
|
|
LotNOs.Add("范围内");
|
|
|
|
cboLotNO.DataSource = LotNOs;
|
|
cboLotNO.SelectedIndex = 0;
|
|
txtLotNOS.Text = "";
|
|
txtLotNOE.Text = "";
|
|
#endregion
|
|
|
|
#region 派工生产日期
|
|
//chkMO2UserDate.Checked = false;
|
|
//dtpMO2UserDateS.Value = DateTime.Now.AddDays(-1);
|
|
//dtpMO2UserDateE.Value = DateTime.Now;
|
|
//dtpMO2UserDateS.Enabled = false;
|
|
//dtpMO2UserDateE.Enabled = false;
|
|
#endregion
|
|
|
|
#region 接收任务日期
|
|
//chkLotBeginDate.Checked = false;
|
|
//dtpLotBeginDateS.Value = DateTime.Now.AddDays(-1);
|
|
//dtpLotBeginDateE.Value = DateTime.Now;
|
|
//dtpLotBeginDateS.Enabled = false;
|
|
//dtpLotBeginDateE.Enabled = false;
|
|
#endregion
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 清空查询条件
|
|
private void clear()
|
|
{
|
|
//txtMOVER.Text = "";
|
|
//gluItemCode.EditValue = "";
|
|
//gluItemCode.Text = "";
|
|
//cboStatus.SelectedIndex = 0;
|
|
cboMOVER.SelectedIndex = 0;
|
|
txtMOVERS.Text = "";
|
|
txtMOVERE.Text = "";
|
|
cboItemCode.Text = "";
|
|
txtItemCodeS.Text = "";
|
|
txtItemCodeE.Text = "";
|
|
cboMoCode.SelectedIndex = 0;
|
|
txtMoCodeS.Text = "";
|
|
txtMoCodeE.Text = "";
|
|
cboLotNO.SelectedIndex = 0;
|
|
txtLotNOS.Text = "";
|
|
txtLotNOE.Text = "";
|
|
gluRouteCode.Text = "";
|
|
//chkMO2UserDate.Checked = false;
|
|
//chkLotBeginDate.Checked = false;
|
|
}
|
|
#endregion
|
|
|
|
#region 校验查询条件
|
|
private string check()
|
|
{
|
|
string msg = "";
|
|
|
|
#region 派工生产日期
|
|
//bool CompareMO2UserDate = (DateTime.Compare(Convert.ToDateTime(dtpMO2UserDateS.Text.Trim()), Convert.ToDateTime(dtpMO2UserDateE.Text.Trim())) <= 0) ? true : false;
|
|
//if (!CompareMO2UserDate && chkMO2UserDate.Checked)
|
|
//{
|
|
// msg += "派工生产开始日期应该小于结束日期";
|
|
//}
|
|
#endregion
|
|
|
|
#region 接收任务日期
|
|
//bool CompareLotBeginDate = (DateTime.Compare(Convert.ToDateTime(dtpLotBeginDateS.Text.Trim()), Convert.ToDateTime(dtpLotBeginDateE.Text.Trim())) <= 0) ? true : false;
|
|
//if (!CompareLotBeginDate && chkLotBeginDate.Checked)
|
|
//{
|
|
// msg += "接收任务开始日期应该小于结束日期";
|
|
//}
|
|
#endregion
|
|
|
|
return msg;
|
|
}
|
|
#endregion
|
|
|
|
#region 拼接查询条件
|
|
private string getWhere()
|
|
{
|
|
string where = "1=1";
|
|
#region 零件号
|
|
#region
|
|
//if (!string.IsNullOrWhiteSpace(txtMOVER.Text.Trim()))
|
|
//{
|
|
// where += "AND a.VenderLotNO like'%" + txtMOVER.Text.Trim() + "%'";
|
|
//}
|
|
#endregion
|
|
if (cboMOVER.Text.Trim() == "等于")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtMOVERS.Text.Trim()))
|
|
{
|
|
where += " AND a.VenderLotNO='" + txtMOVERS.Text.Trim() + "'";
|
|
}
|
|
}
|
|
else if (cboMOVER.Text.Trim() == "范围内")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtMOVERS.Text.Trim()))
|
|
{
|
|
where += " AND a.VenderLotNO>='" + txtMOVERS.Text.Trim() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(txtMOVERE.Text.Trim()))
|
|
{
|
|
where += " AND a.VenderLotNO<='" + txtMOVERE.Text.Trim() + "'";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 存货编码
|
|
//if (!string.IsNullOrWhiteSpace(gluItemCode.Text.Trim()))
|
|
//{
|
|
// where += " AND mo.ITEMCODE='" + gluItemCode.Text.Trim() + "'";
|
|
//}
|
|
if (cboItemCode.Text.Trim() == "等于")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtItemCodeS.Text.Trim()))
|
|
{
|
|
where += " AND mo.ITEMCODE='" + txtItemCodeS.Text.Trim() + "'";
|
|
}
|
|
}
|
|
else if (cboItemCode.Text.Trim() == "范围内")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtItemCodeS.Text.Trim()))
|
|
{
|
|
where += " AND mo.ITEMCODE>='" + txtItemCodeS.Text.Trim() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(txtItemCodeE.Text.Trim()))
|
|
{
|
|
where += " AND mo.ITEMCODE<='" + txtItemCodeE.Text.Trim() + "'";
|
|
}
|
|
}
|
|
#endregion
|
|
#region 类别
|
|
if (string.IsNullOrEmpty(txtINVMACHINETYPE.Text)== false) {
|
|
where += " and inv.EATTRIBUTE2 in ("+txtINVMACHINETYPE.Text.Trim()+") ";
|
|
}
|
|
#endregion
|
|
|
|
#region 途程代码
|
|
if (!string.IsNullOrWhiteSpace(gluRouteCode.Text.Trim()))
|
|
{
|
|
where += " AND h.RouteCode='" + gluRouteCode.Text.Trim() + "'";
|
|
}
|
|
#endregion
|
|
|
|
#region 状态
|
|
//if (cboStatus.Text.Trim() == "良品")
|
|
//{
|
|
// where += " AND c.ACTIONRESULT='GOOD'";
|
|
//}
|
|
//else if (cboStatus.Text.Trim() == "不良品")
|
|
//{
|
|
// where += " AND c.ACTIONRESULT='NG'";
|
|
//}
|
|
#endregion
|
|
|
|
#region 工单号
|
|
if (cboMoCode.Text.Trim() == "等于")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtMoCodeS.Text.Trim()))
|
|
{
|
|
where += " AND mo.MOCODE='" + txtMoCodeS.Text.Trim() + "'";
|
|
}
|
|
}
|
|
else if (cboMoCode.Text.Trim() == "范围内")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtMoCodeS.Text.Trim()))
|
|
{
|
|
where += " AND mo.MOCODE>='" + txtMoCodeS.Text.Trim() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(txtMoCodeE.Text.Trim()))
|
|
{
|
|
where += " AND mo.MOCODE<='" + txtMoCodeE.Text.Trim() + "'";
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 项目号
|
|
if (txtOrderNo.Text.Trim() != "")
|
|
{
|
|
where += " and mo.OrderNO like '%"+txtOrderNo.Text+"%'";
|
|
}
|
|
#endregion
|
|
|
|
#region 产品跟踪单号
|
|
if (cboLotNO.Text.Trim() == "等于")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtLotNOS.Text.Trim()))
|
|
{
|
|
where += " AND a.LOTNO='" + txtLotNOS.Text.Trim() + "'";
|
|
}
|
|
}
|
|
else if (cboLotNO.Text.Trim() == "范围内")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtLotNOS.Text.Trim()))
|
|
{
|
|
where += " AND a.LOTNO>='" + txtLotNOS.Text.Trim() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(txtLotNOE.Text.Trim()))
|
|
{
|
|
where += " AND a.LOTNO<='" + txtLotNOE.Text.Trim() + "'";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 派工生产日期
|
|
//if (chkMO2UserDate.Checked)
|
|
//{
|
|
// where += " AND b.PlanDate>='" + int.Parse(Convert.ToDateTime(dtpMO2UserDateS.Text.Trim()).ToString("yyyyMMdd")) +
|
|
// "' AND b.PlanDate<='" + int.Parse(Convert.ToDateTime(dtpMO2UserDateE.Text.Trim()).ToString("yyyyMMdd")) + "'";
|
|
//}
|
|
#endregion
|
|
|
|
#region 接收任务日期
|
|
//if (chkLotBeginDate.Checked)
|
|
//{
|
|
// where += " AND c.BeginDate>='" + int.Parse(Convert.ToDateTime(dtpLotBeginDateS.Text.Trim()).ToString("yyyyMMdd")) +
|
|
// "' AND c.BeginDate<='" + int.Parse(Convert.ToDateTime(dtpLotBeginDateE.Text.Trim()).ToString("yyyyMMdd")) + "'";
|
|
//}
|
|
#endregion
|
|
|
|
#region 未完工
|
|
if (this.cbxISCOM.Checked)
|
|
{
|
|
where += " AND isnull(dbo.GetMOCOMQTY(a.MOCODE),0) != a.MOPlanQty ";
|
|
}
|
|
#endregion
|
|
|
|
#region 预计完工时间
|
|
if(checkDate.Checked)
|
|
{
|
|
where += " and mo.MOPLANENDDATE BETWEEN " + "'" + Convert.ToDateTime(txtStartDate.Text).ToString("yyyy-MM-dd") + "'" + " AND " + "'" + Convert.ToDateTime(txtEndDate.Text).ToString("yyyy-MM-dd") + "'";
|
|
}
|
|
#endregion
|
|
|
|
#region 工单下发时间
|
|
if (checkBox1.Checked) {
|
|
where += " AND mo.SendDATE>='"+dateTimePicker1.Value+ "' AND mo.SendDATE<='" + dateTimePicker2.Value + "'";
|
|
}
|
|
#endregion
|
|
|
|
#region 未入库
|
|
if (checkAll.Checked)//全部
|
|
{
|
|
where += " AND 1=1 ";
|
|
}
|
|
else if(checkProcessing.Checked)//在制
|
|
{
|
|
where += " AND i.LotNo is null ";
|
|
}
|
|
else if (checkStockIn.Checked)//已入库
|
|
{
|
|
where += " AND i.LotNo is not null ";
|
|
}
|
|
#endregion
|
|
|
|
if (MDeptCode.Text != "") {
|
|
where += " and mo.MDeptCode='" + MDeptCode.Text + "'";
|
|
}
|
|
|
|
return where;
|
|
}
|
|
#endregion
|
|
|
|
#region 拼接查询条件
|
|
private string getWhere2()
|
|
{
|
|
#region 亚太零件工号
|
|
string where = " 1 = 1 ";
|
|
//if (!string.IsNullOrWhiteSpace(txtMOVER.Text.Trim()))
|
|
//{
|
|
// where += "AND g.VenderLotNO like'%" + txtMOVER.Text.Trim() + "%'";
|
|
//}
|
|
if (cboMOVER.Text.Trim() == "等于")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtMOVERS.Text.Trim()))
|
|
{
|
|
where += " AND g.VenderLotNO='" + txtMOVERS.Text.Trim() + "'";
|
|
}
|
|
}
|
|
else if (cboMOVER.Text.Trim() == "范围内")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtMOVERS.Text.Trim()))
|
|
{
|
|
where += " AND g.VenderLotNO>='" + txtMOVERS.Text.Trim() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(txtMOVERE.Text.Trim()))
|
|
{
|
|
where += " AND g.VenderLotNO<='" + txtMOVERE.Text.Trim() + "'";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 存货编码
|
|
//if (!string.IsNullOrWhiteSpace(gluItemCode.Text.Trim()))
|
|
//{
|
|
// where += " AND a.ITEMCODE='" + gluItemCode.Text.Trim() + "'";
|
|
//}
|
|
if (cboItemCode.Text.Trim() == "等于")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtItemCodeS.Text.Trim()))
|
|
{
|
|
where += " AND a.ITEMCODE='" + txtItemCodeS.Text.Trim() + "'";
|
|
}
|
|
}
|
|
else if (cboItemCode.Text.Trim() == "范围内")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtItemCodeS.Text.Trim()))
|
|
{
|
|
where += " AND a.ITEMCODE>='" + txtItemCodeS.Text.Trim() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(txtItemCodeE.Text.Trim()))
|
|
{
|
|
where += " AND a.ITEMCODE<='" + txtItemCodeE.Text.Trim() + "'";
|
|
}
|
|
}
|
|
#endregion
|
|
#region 类别
|
|
if (string.IsNullOrEmpty(txtINVMACHINETYPE.Text) == false)
|
|
{
|
|
where += " and d.EATTRIBUTE2 in (" + txtINVMACHINETYPE.Text.Trim() + ") ";
|
|
}
|
|
#endregion
|
|
#region 途程代码
|
|
if (!string.IsNullOrWhiteSpace(gluRouteCode.Text.Trim()))
|
|
{
|
|
where += " AND h.RouteCode='" + gluRouteCode.Text.Trim() + "'";
|
|
}
|
|
#endregion
|
|
|
|
#region 工单号
|
|
if (cboMoCode.Text.Trim() == "等于")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtMoCodeS.Text.Trim()))
|
|
{
|
|
where += " AND a.MOCODE='" + txtMoCodeS.Text.Trim() + "'";
|
|
}
|
|
}
|
|
else if (cboMoCode.Text.Trim() == "范围内")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtMoCodeS.Text.Trim()))
|
|
{
|
|
where += " AND a.MOCODE>='" + txtMoCodeS.Text.Trim() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(txtMoCodeE.Text.Trim()))
|
|
{
|
|
where += " AND a.MOCODE<='" + txtMoCodeE.Text.Trim() + "'";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 项目号
|
|
if (txtOrderNo.Text.Trim() != "")
|
|
{
|
|
where += " and a.OrderNO like '%" + txtOrderNo.Text + "%'";
|
|
}
|
|
#endregion
|
|
|
|
#region 产品跟踪单号
|
|
if (cboLotNO.Text.Trim() == "等于")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtLotNOS.Text.Trim()))
|
|
{
|
|
where += " AND g.LOTNO='" + txtLotNOS.Text.Trim() + "'";
|
|
}
|
|
}
|
|
else if (cboLotNO.Text.Trim() == "范围内")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(txtLotNOS.Text.Trim()))
|
|
{
|
|
where += " AND g.LOTNO>='" + txtLotNOS.Text.Trim() + "'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(txtLotNOE.Text.Trim()))
|
|
{
|
|
where += " AND g.LOTNO<='" + txtLotNOE.Text.Trim() + "'";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 派工生产日期
|
|
//if (chkMO2UserDate.Checked)
|
|
//{
|
|
// where += " AND b.PlanDate>='" + int.Parse(Convert.ToDateTime(dtpMO2UserDateS.Text.Trim()).ToString("yyyyMMdd")) +
|
|
// "' AND b.PlanDate<='" + int.Parse(Convert.ToDateTime(dtpMO2UserDateE.Text.Trim()).ToString("yyyyMMdd")) + "'";
|
|
//}
|
|
#endregion
|
|
|
|
#region 接收任务日期
|
|
//if (chkLotBeginDate.Checked)
|
|
//{
|
|
// where += " AND c.BeginDate>='" + int.Parse(Convert.ToDateTime(dtpLotBeginDateS.Text.Trim()).ToString("yyyyMMdd")) +
|
|
// "' AND c.BeginDate<='" + int.Parse(Convert.ToDateTime(dtpLotBeginDateE.Text.Trim()).ToString("yyyyMMdd")) + "'";
|
|
//}
|
|
#endregion
|
|
|
|
#region 未完工
|
|
if (this.cbxISCOM.Checked)
|
|
{
|
|
where += " AND isnull(dbo.GetMOCOMQTY(a.MOCODE),0) != mo.MOPlanQty ";
|
|
}
|
|
#endregion
|
|
|
|
#region 预计完工时间
|
|
if (checkDate.Checked)
|
|
{
|
|
where += " and a.MOPLANENDDATE BETWEEN " + "'" + Convert.ToDateTime(txtStartDate.Text).ToString("yyyy-MM-dd") + "'" + " AND " + "'" + Convert.ToDateTime(txtEndDate.Text).ToString("yyyy-MM-dd") + "'";
|
|
}
|
|
#endregion
|
|
#region 工单下发时间
|
|
if (checkBox1.Checked)
|
|
{
|
|
where += " AND a.SendDATE>='" + dateTimePicker1.Value + "' AND a.SendDATE<='" + dateTimePicker2.Value + "' ";
|
|
}
|
|
#endregion
|
|
#region 未入库
|
|
if (checkAll.Checked)//全部
|
|
{
|
|
where += " AND 1=1 ";
|
|
}
|
|
else if (checkProcessing.Checked)//在制
|
|
{
|
|
where += " AND i.LotNo is null ";
|
|
}
|
|
else if (checkStockIn.Checked)//已入库
|
|
{
|
|
where += " AND i.LotNo is not null ";
|
|
}
|
|
#endregion
|
|
|
|
if (MDeptCode.Text != "")
|
|
{
|
|
where += " and a.MDeptCode='" + MDeptCode.Text + "'";
|
|
}
|
|
return where;
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
private void btnFilter_Click(object sender, EventArgs e)
|
|
{
|
|
grvDetail.Columns.Clear();
|
|
grdDetail.DataSource = null;
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
|
|
try
|
|
{
|
|
|
|
_wait.Show();
|
|
|
|
string msg = check();
|
|
if (!string.IsNullOrWhiteSpace(msg))
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox(msg);
|
|
return;
|
|
}
|
|
|
|
dataSource = null;
|
|
|
|
DateTime time1 = Convert.ToDateTime(txtStartDate.Text);
|
|
DateTime time2 = Convert.ToDateTime(txtEndDate.Text);
|
|
int compNum = DateTime.Compare(time1, time2);
|
|
if (compNum>0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("开始时间不能大于结束时间!");
|
|
return;
|
|
}
|
|
|
|
#region 查询sql
|
|
sqltxt = @"SELECT DISTINCT g.VenderLotNO,
|
|
a.MOCODE,
|
|
a.MOSEQ,
|
|
a.ITEMCODE,
|
|
d.INVNAME,
|
|
d.INVSTD,
|
|
d.eattribute2,
|
|
b.RouteCode,
|
|
e.ROUTEDESC,
|
|
g.LOTNO
|
|
,g.EATTRIBUTE5 as QCCheck
|
|
,a.MOPLANENDDATE,
|
|
a.MDeptCode,
|
|
a.eattribute4,
|
|
a.orderno as 项目号,
|
|
case when isnull(g.iscom,'')='1' then '是' else '否' end as 是否入库,
|
|
g.storageMuser as 入库人,
|
|
g.storagedate as 入库时间,
|
|
--,CASE WHEN g.EATTRIBUTE2= '1' THEN '合格' WHEN g.EATTRIBUTE2='0' THEN '不合格' WHEN g.EATTRIBUTE2 is null THEN '未检验' END AS QCCheckResult
|
|
CASE WHEN h.ISCOM=1 THEN h.MTIME WHEN h.ISCOM=0 THEN null END AS MTIME
|
|
INTO #tmfp
|
|
FROM ICSMO a with(nolock)
|
|
LEFT JOIN ICSMO2Route b with(nolock) ON a.ID = b.MOID
|
|
LEFT JOIN ICSINVENTORY d with(nolock) ON a.ITEMCODE = d.INVCODE
|
|
LEFT JOIN ICSROUTE e with(nolock) ON b.RouteCode = e.ROUTECODE
|
|
LEFT JOIN ICSITEMLot g with(nolock) ON g.TransNO=a.MOCODE and g.TransLine=a.MOSEQ
|
|
LEFT JOIN ICSLOTSIMULATION h with(nolock) ON h.LOTNO=g.LOTNO
|
|
LEFT JOIN ICSWareHouseLotInfo i with(nolock) ON g.LotNo=i.LotNo
|
|
WHERE a.mostatus<>'关单' and {1}
|
|
|
|
IF NOT EXISTS(SELECT MOCODE FROM #tmfp)
|
|
BEGIN
|
|
RAISERROR('未查询到数据!',16,0)
|
|
END
|
|
|
|
SELECT distinct a.LOTNO,
|
|
SUM(CAST(DATEDIFF(HOUR,a.BeginTime,a.EndTime)-ISNULL(f.ff, 0) as NUMERIC(10,1))) as realtime,
|
|
SUM(c.STIME*a.LOTQTY) as sumtime
|
|
--SUM(CASE WHEN g.IDMERGETYPE='' THEN 0 ELSE CAST(g.IDMERGETYPE AS DECIMAL(18,5)) END) as realtime
|
|
INTO #tmgp
|
|
FROM ICSLOTONWIP a with(nolock)
|
|
LEFT JOIN ICSEquipment b with(nolock) ON a.EQPCODE=b.EQPCode
|
|
LEFT JOIN ICSEQPSTP c with(nolock) on b.EType=c.EQPTypeCode AND a.ITEMCODE=c.ITEMCODE AND a.OPCODE=c.OPCODE
|
|
LEFT JOIN (SELECT LOTNO,SEQ,SUM(DATEDIFF(HOUR,BeginTime,EndTime)) as ff
|
|
FROM ICSLOTPAUSE with(nolock)
|
|
GROUP BY LOTNO,SEQ)f ON a.LOTNO=f.LOTNO AND a.SEQ=f.SEQ
|
|
where 1=1
|
|
group by a.LOTNO
|
|
|
|
IF NOT EXISTS(SELECT LotNO FROM #tmgp)
|
|
BEGIN
|
|
RAISERROR('未查询到数据!',16,0)
|
|
END
|
|
|
|
SELECT
|
|
a.LOTNO as LOTNO,
|
|
'工序'+RIGHT('0'+CAST(row_number() over (partition by a.LotNo ORDER BY r.opseq) AS VARCHAR(100)), 2) AS Ind,
|
|
(CASE WHEN us.EATTRIBUTE1='1' THEN '委外:'+r.OPCODE +':'+ s.opdesc
|
|
ELSE r.OPCODE +':'+ s.opdesc
|
|
END )as OPCODE,
|
|
mo.SendDATE
|
|
--r.OPCODE as OPCODE
|
|
INTO #tmep
|
|
FROM
|
|
ICSITEMLot a with(nolock)
|
|
LEFT JOIN ICSMO mo with(nolock) ON a.TransNO = mo.MOCODE AND a.TransLine = mo.MOSEQ
|
|
LEFT JOIN ICSMO2ROUTE h with(nolock) ON mo.ID = h.MOID
|
|
left join icsinventory inv on inv.invcode=mo.itemcode
|
|
LEFT JOIN ICSITEMROUTE2OPLot r with(nolock) ON MO.ITEMCODE = r.ITEMCODE AND h.ROUTECODE = r.ROUTECODE AND a.LotNO = r.LotNo
|
|
INNER JOIN ICSMO2User us with(nolock) ON mo.MOCODE=us.MOCODE and a.LOTNO=us.LOTNO and us.opcode=r.opcode
|
|
LEFT JOIN ICSOP s with(nolock) ON r.opcode=s.opcode
|
|
LEFT JOIN ICSWareHouseLotInfo i with(nolock) ON a.LotNo=i.LotNo
|
|
WHERE {0}--a.LotNO LIKE 'SCDD190800031%'
|
|
ORDER BY a.LOTNO,r.OPSEQ
|
|
|
|
IF NOT EXISTS(SELECT LotNO FROM #tmep)
|
|
BEGIN
|
|
RAISERROR('未查询到数据!',16,0)
|
|
END
|
|
|
|
SELECT DISTINCT Ind INTO #tmip FROM #tmep ORDER BY Ind
|
|
DECLARE @SQL VARCHAR (8000)
|
|
SELECT @SQL = isnull(@SQL + ',', '') + ' MAX(CASE Ind WHEN ''' + Ind + ''' THEN OPCODE ELSE '''' END) [' + Ind + ']'
|
|
FROM(SELECT Ind FROM #tmip) AS a
|
|
SET @SQL = 'SELECT ROW_NUMBER() over(order by tmhp.产品跟踪码 ASC) as 序号,#tmfp.VenderLotNO as 零件号,#tmfp.MOCODE as 生产工单号,#tmfp.MOSEQ as 生产订单行号,#tmfp.eattribute4 AS 生产部门,icsmo.SendDATE as 工单下发时间,icsmo.moplanqty as 工单行数量,
|
|
#tmfp.MOPLANENDDATE as 预计完工时间, #tmfp.ITEMCODE as 存货编码,#tmfp.INVSTD as 规格型号,#tmfp.INVNAME as 存货名称,#tmfp.项目号, #tmfp.eattribute2 as 类别,
|
|
#tmfp.RouteCode as 工艺路线,#tmfp.ROUTEDESC as 工艺路线描述,tmhp.*,#tmfp.MTIME as 完工日期,#tmgp.realtime as 已完工总工时,#tmgp.sumtime as 总标准时间,
|
|
Cast(CAST((#tmgp.realtime/#tmgp.sumtime*100) AS NUMERIC(10,1)) as nvarchar(10)) +''%'' as 完成百分比,#tmfp.是否入库,#tmfp.入库人,#tmfp.入库时间
|
|
FROM (SELECT LOTNO AS 产品跟踪码,' +@SQL + ' FROM #tmep GROUP BY LOTNO) tmhp
|
|
inner JOIN #tmfp ON tmhp.产品跟踪码=#tmfp.LOTNO
|
|
LEFT JOIN #tmgp ON tmhp.产品跟踪码=#tmgp.LOTNO
|
|
left join icsmo on #tmfp.MOCODE=icsmo.mocode and #tmfp.MOSEQ=icsmo.moseq
|
|
ORDER BY tmhp.产品跟踪码,#tmfp.MOCODE,#tmfp.ITEMCODE,#tmfp.RouteCode,#tmfp.MTIME ASC'
|
|
|
|
|
|
EXEC (@SQL)
|
|
|
|
DROP TABLE #tmep
|
|
drop table #tmgp
|
|
drop table #tmfp
|
|
drop table #tmip";
|
|
string where = getWhere();
|
|
string where1 = getWhere2();
|
|
//if (!string.IsNullOrWhiteSpace(where))
|
|
//{
|
|
// sqltxt += where;
|
|
//}
|
|
//sqltxt += " ORDER BY a.MOVER,a.MOCODE,g.LOTNO";
|
|
#endregion
|
|
sqltxt = string.Format(sqltxt, where, where1);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqltxt).Tables[0];
|
|
grdDetail.DataSource = dt;
|
|
dataSource = dt;
|
|
grvDetail.BestFitColumns();
|
|
rptPage.PageSize = 50;
|
|
rptPage.PageIndex = 1;
|
|
rptPage.ReLoad();
|
|
_wait.Close();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
|
|
grdDetail.DataSource = null;
|
|
_wait.Close();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region gridControl绑定数据源
|
|
// private void CreatDataSource(DataTable dt)
|
|
// {
|
|
// try
|
|
// {
|
|
// List<string> lotlist = new List<string>();
|
|
// foreach (DataRow dr in dt.Rows)
|
|
// {
|
|
// if ((dr["LOTNO"].ToString() != "") && (!lotlist.Contains(dr["LOTNO"].ToString())))
|
|
// {
|
|
// lotlist.Add(dr["LOTNO"].ToString());
|
|
// }
|
|
|
|
// }
|
|
// DataTable dtone = new DataTable();
|
|
// dtone.Columns.Add("MOVER", typeof(string));
|
|
// dtone.Columns.Add("MOCODE", typeof(string));
|
|
// dtone.Columns.Add("LOTNO", typeof(string));
|
|
// dtone.Columns.Add("ITEMCODE", typeof(string));
|
|
// dtone.Columns.Add("INVNAME", typeof(string));
|
|
// dtone.Columns.Add("RouteCode", typeof(string));
|
|
// dtone.Columns.Add("ROUTEDESC", typeof(string));
|
|
// dtone.Columns.Add("OP1", typeof(string));
|
|
// dtone.Columns.Add("OP2", typeof(string));
|
|
// dtone.Columns.Add("OP3", typeof(string));
|
|
// dtone.Columns.Add("OP4", typeof(string));
|
|
// dtone.Columns.Add("OP5", typeof(string));
|
|
// dtone.Columns.Add("OP6", typeof(string));
|
|
// dtone.Columns.Add("OP7", typeof(string));
|
|
// dtone.Columns.Add("OP8", typeof(string));
|
|
// dtone.Columns.Add("OP9", typeof(string));
|
|
// dtone.Columns.Add("OP10", typeof(string));
|
|
// dtone.Columns.Add("MTIME",typeof(string));
|
|
// dtone.Columns.Add("SumTime", typeof(decimal));
|
|
// dtone.Columns.Add("SumRealtime", typeof(decimal));
|
|
// dtone.Columns.Add("Rate", typeof(string));
|
|
// //dtone.Columns.Add("SSCODE", typeof(string));
|
|
// //dtone.Columns.Add("SSNAME", typeof(string));
|
|
// dtone.Columns.Add("QCCheck", typeof(string));
|
|
|
|
// dtone.Columns["MOVER"].Caption = "零件号";
|
|
// dtone.Columns["MOCODE"].Caption = "生产订单号";
|
|
// dtone.Columns["LOTNO"].Caption = "产品跟踪单号";
|
|
// dtone.Columns["ITEMCODE"].Caption = "存货编码";
|
|
// dtone.Columns["INVNAME"].Caption = "存货名称";
|
|
// dtone.Columns["RouteCode"].Caption = "途程代码";
|
|
// dtone.Columns["ROUTEDESC"].Caption = "途程名称";
|
|
// dtone.Columns["OP1"].Caption = "工序1";
|
|
// dtone.Columns["OP2"].Caption = "工序2";
|
|
// dtone.Columns["OP3"].Caption = "工序3";
|
|
// dtone.Columns["OP4"].Caption = "工序4";
|
|
// dtone.Columns["OP5"].Caption = "工序5";
|
|
// dtone.Columns["OP6"].Caption = "工序6";
|
|
// dtone.Columns["OP7"].Caption = "工序7";
|
|
// dtone.Columns["OP8"].Caption = "工序8";
|
|
// dtone.Columns["OP9"].Caption = "工序9";
|
|
// dtone.Columns["OP10"].Caption = "工序10";
|
|
// dtone.Columns["MTIME"].Caption = "完工时间";
|
|
// dtone.Columns["QCCheck"].Caption = "质量检验";
|
|
|
|
// string sql = @"select
|
|
// a.LOTNO,
|
|
//
|
|
// r.OPCODE,
|
|
// c.OPDESC,
|
|
// NULL as STIME,
|
|
// b.MTIME,
|
|
// r.OPSEQ AS OPSEQ
|
|
// from ICSITEMLot a
|
|
// left join ICSMO mo on a.TransNO=mo.MOCODE and a.TransLine=mo.MOSEQ
|
|
// LEFT JOIN ICSINVENTORY INV ON MO.ITEMCODE=INV.INVCODE
|
|
// left join ICSMO2ROUTE h on mo.ID=h.MOID
|
|
// left join ICSITEMROUTE2OPLot r on MO.ITEMCODE=r.ITEMCODE AND h.ROUTECODE=r.ROUTECODE AND a.LotNO=r.LotNo
|
|
// left join ICSLOTONWIP b on a.LOTNO=b.LOTNO And r.OPCODE = b.OpCode
|
|
// left join ICSOP c on r.OPCODE=c.OPCODE
|
|
//where {0}
|
|
//order by a.LOTNO,r.OPSEQ";
|
|
|
|
// sql = string.Format(sql,getWhere2());
|
|
// DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
|
|
// //查询批次工序完成状况
|
|
|
|
// string sql3 = @"SELECT distinct a.LOTNO,
|
|
// SUM(CAST(DATEDIFF(HOUR,a.BeginTime,a.EndTime)-ISNULL(f.ff, 0) as NUMERIC(10,1))) as realtime
|
|
// --SUM(CASE WHEN g.IDMERGETYPE='' THEN 0 ELSE CAST(g.IDMERGETYPE AS DECIMAL(18,5)) END) as realtime
|
|
// FROM ICSLOTONWIP a
|
|
// LEFT JOIN (SELECT LOTNO,SEQ,SUM(DATEDIFF(HOUR,BeginTime,EndTime)) as ff
|
|
// FROM ICSLOTPAUSE
|
|
// GROUP BY LOTNO,SEQ)f ON a.LOTNO=f.LOTNO AND a.SEQ=f.SEQ
|
|
// where 1=1
|
|
// group by a.LOTNO";
|
|
// sql3 = string.Format(sql3);
|
|
// DataTable dt3 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql3).Tables[0];
|
|
|
|
// for (int i = 0; i < lotlist.Count; i++)
|
|
// {
|
|
|
|
// DataRow[] dr1 = dt.Select("LOTNO ='" + lotlist[i] + "'");
|
|
// DataRow drone = dtone.NewRow();
|
|
// drone["MOVER"] = dr1[0]["MOVER"].ToString();
|
|
// drone["MOCODE"] = dr1[0]["MOCODE"].ToString();
|
|
// drone["LOTNO"] = dr1[0]["LOTNO"].ToString();
|
|
// drone["ITEMCODE"] = dr1[0]["ITEMCODE"].ToString();
|
|
// drone["INVNAME"] = dr1[0]["INVNAME"].ToString();
|
|
// drone["RouteCode"] = dr1[0]["RouteCode"].ToString();
|
|
// drone["ROUTEDESC"] = dr1[0]["ROUTEDESC"].ToString();
|
|
// drone["MTIME"] = dr1[0]["MTIME"].ToString();
|
|
// drone["QCCheck"] = dr1[0]["QCCheck"].ToString();
|
|
// decimal stime = 0M;
|
|
// decimal realtime = 0M;
|
|
// DataRow[] drs = dt2.Select("LOTNO ='" + lotlist[i] + "'");
|
|
// DataRow[] drs1 = dt3.Select("LOTNO ='" + lotlist[i] + "'");
|
|
// for (int n = 0; n < drs.Length; n++)
|
|
// {
|
|
// //drone["SSCODE"] = drs[0]["SSCODE"].ToString();
|
|
// //drone["SSNAME"] = drs[0]["SSNAME"].ToString();
|
|
// stime += decimal.Parse(drs[n]["STIME"].ToString().Equals("") ? "0" : drs[n]["STIME"].ToString());
|
|
// switch (n)
|
|
// {
|
|
// case 0:
|
|
// drone["OP1"] = drs[0]["OPCODE"].ToString() + " " + drs[0]["OPDESC"].ToString() + " " + drs[0]["STIME"].ToString() ;
|
|
// break;
|
|
// case 1:
|
|
// drone["OP2"] = drs[1]["OPCODE"].ToString() + " " + drs[1]["OPDESC"].ToString() + " " + drs[1]["STIME"].ToString();
|
|
// break;
|
|
// case 2:
|
|
// drone["OP3"] = drs[2]["OPCODE"].ToString() + " " + drs[2]["OPDESC"].ToString() + " " + drs[2]["STIME"].ToString();
|
|
// break;
|
|
// case 3:
|
|
// drone["OP4"] = drs[3]["OPCODE"].ToString() + " " + drs[3]["OPDESC"].ToString() + " " + drs[3]["STIME"].ToString() ;
|
|
// break;
|
|
// case 4:
|
|
// drone["OP5"] = drs[4]["OPCODE"].ToString() + " " + drs[4]["OPDESC"].ToString() + " " + drs[4]["STIME"].ToString();
|
|
// break;
|
|
// case 5:
|
|
// drone["OP6"] = drs[5]["OPCODE"].ToString() + " " + drs[5]["OPDESC"].ToString() + " " + drs[5]["STIME"].ToString();
|
|
// break;
|
|
// case 6:
|
|
// drone["OP7"] = drs[6]["OPCODE"].ToString() + " " + drs[6]["OPDESC"].ToString() + " " + drs[6]["STIME"].ToString() ;
|
|
// break;
|
|
// case 7:
|
|
// drone["OP8"] = drs[7]["OPCODE"].ToString() + " " + drs[7]["OPDESC"].ToString() + " " + drs[7]["STIME"].ToString();
|
|
// break;
|
|
// case 8:
|
|
// drone["OP9"] = drs[8]["OPCODE"].ToString() + " " + drs[8]["OPDESC"].ToString() + " " + drs[8]["STIME"].ToString();
|
|
// break;
|
|
// case 9:
|
|
// drone["OP10"] = drs[9]["OPCODE"].ToString() + " " + drs[9]["OPDESC"].ToString() + " " + drs[9]["STIME"].ToString();
|
|
// break;
|
|
|
|
// }
|
|
// }
|
|
|
|
// drone["SumTime"] = stime;
|
|
// if (drs1.Length == 0)
|
|
// {
|
|
// realtime = 0;
|
|
// }
|
|
// else
|
|
// {
|
|
// realtime = decimal.Parse(drs1[0]["realtime"].ToString().Equals("") ? "0" : drs1[0]["realtime"].ToString());
|
|
// }
|
|
// drone["SumRealtime"] = realtime;
|
|
// if (stime == 0)
|
|
// {
|
|
// drone["Rate"] = 0;
|
|
// }
|
|
// else
|
|
// {
|
|
// drone["Rate"] = (Math.Round(realtime / stime, 2))*100+"%";
|
|
// }
|
|
// dtone.Rows.Add(drone);
|
|
// }
|
|
// grdDetail.DataSource = dtone;
|
|
// grvDetail.BestFitColumns();
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
// }
|
|
#endregion
|
|
|
|
#region 分页
|
|
private void rptPage_PageIndexChanged(object Sender, EventArgs e)
|
|
{
|
|
|
|
DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
|
|
//DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
|
|
grdDetail.DataSource = data;
|
|
}
|
|
#endregion
|
|
|
|
#region 列表
|
|
private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
private void FormICSFACTORY_Load(object sender, EventArgs e)
|
|
{
|
|
//btnFilter_Click(sender, e);
|
|
init();
|
|
}
|
|
#endregion
|
|
|
|
#region 清除
|
|
private void btnClear_Click(object sender, EventArgs e)
|
|
{
|
|
clear();
|
|
}
|
|
#endregion
|
|
|
|
#region 导出
|
|
private void btnOutPut_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
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;
|
|
string name = "";
|
|
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);
|
|
name = url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx");
|
|
}
|
|
else
|
|
{
|
|
grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
|
|
name = url + "\\" + filename + ".pdf";
|
|
}
|
|
DialogResult result = MessageBox.Show("导出成功,是否打开此文件?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
|
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(name))
|
|
{
|
|
System.Diagnostics.Process.Start(name);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void cboMoCode_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (cboMoCode.Text.Trim() == "等于")
|
|
{
|
|
txtMoCodeS.Enabled = true;
|
|
txtMoCodeE.Enabled = false;
|
|
txtMoCodeE.Text = "";
|
|
}
|
|
else if (cboMoCode.Text.Trim() == "范围内")
|
|
{
|
|
txtMoCodeS.Enabled = true;
|
|
txtMoCodeE.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
txtMoCodeS.Enabled = false;
|
|
txtMoCodeE.Enabled = false;
|
|
txtMoCodeS.Text = "";
|
|
txtMoCodeE.Text = "";
|
|
}
|
|
}
|
|
|
|
private void cboLotNO_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (cboLotNO.Text.Trim() == "等于")
|
|
{
|
|
txtLotNOS.Enabled = true;
|
|
txtLotNOE.Enabled = false;
|
|
txtLotNOE.Text = "";
|
|
}
|
|
else if (cboLotNO.Text.Trim() == "范围内")
|
|
{
|
|
txtLotNOS.Enabled = true;
|
|
txtLotNOE.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
txtLotNOS.Enabled = false;
|
|
txtLotNOE.Enabled = false;
|
|
txtLotNOS.Text = "";
|
|
txtLotNOE.Text = "";
|
|
}
|
|
}
|
|
|
|
private void chkMO2UserDate_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
//if (chkMO2UserDate.Checked)
|
|
//{
|
|
// dtpMO2UserDateS.Enabled = true;
|
|
// dtpMO2UserDateE.Enabled = true;
|
|
//}
|
|
//else
|
|
//{
|
|
// dtpMO2UserDateS.Enabled = false;
|
|
// dtpMO2UserDateE.Enabled = false;
|
|
//}
|
|
}
|
|
|
|
private void chkLotBeginDate_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
//if (chkLotBeginDate.Checked)
|
|
//{
|
|
// dtpLotBeginDateS.Enabled = true;
|
|
// dtpLotBeginDateE.Enabled = true;
|
|
//}
|
|
//else
|
|
//{
|
|
// dtpLotBeginDateS.Enabled = false;
|
|
// dtpLotBeginDateE.Enabled = false;
|
|
//}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkDate_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (checkDate.Checked)
|
|
{
|
|
txtStartDate.Enabled = true;
|
|
txtEndDate.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
txtStartDate.Enabled = false;
|
|
txtEndDate.Enabled = false;
|
|
}
|
|
}
|
|
|
|
private void cboMOVER_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (cboMOVER.Text.Trim() == "等于")
|
|
{
|
|
txtMOVERS.Enabled = true;
|
|
txtMOVERE.Enabled = false;
|
|
txtMOVERE.Text = "";
|
|
}
|
|
else if (cboMOVER.Text.Trim() == "范围内")
|
|
{
|
|
txtMOVERS.Enabled = true;
|
|
txtMOVERE.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
txtMOVERS.Enabled = false;
|
|
txtMOVERE.Enabled = false;
|
|
txtMOVERS.Text = "";
|
|
txtMOVERE.Text = "";
|
|
}
|
|
}
|
|
|
|
private void cboItemCode_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (cboItemCode.Text.Trim() == "等于")
|
|
{
|
|
txtItemCodeS.Enabled = true;
|
|
txtItemCodeE.Enabled = false;
|
|
txtItemCodeE.Text = "";
|
|
}
|
|
else if (cboItemCode.Text.Trim() == "范围内")
|
|
{
|
|
txtItemCodeS.Enabled = true;
|
|
txtItemCodeE.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
txtItemCodeS.Enabled = false;
|
|
txtItemCodeE.Enabled = false;
|
|
txtItemCodeS.Text = "";
|
|
txtItemCodeE.Text = "";
|
|
}
|
|
}
|
|
|
|
private void rptPage_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void txtINVMACHINETYPE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = @"select eattribute2 as 类别 from ICSINVENTORY
|
|
group by eattribute2
|
|
having EATTRIBUTE2 <> '' and EATTRIBUTE2 is not null";
|
|
//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 = true;
|
|
reForm.RowIndexWidth = 35;
|
|
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;
|
|
string type = "";
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
type += "'"+dr["类别"].ToString() +"'"+",";
|
|
|
|
}
|
|
txtINVMACHINETYPE.Text= type.Trim(',');
|
|
}
|
|
|
|
}
|
|
|
|
private void rptPage_PageIndexChanged_1(object Sender, EventArgs e)
|
|
{
|
|
if (dataSource != null)
|
|
{
|
|
DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
|
|
//DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
|
|
grdDetail.DataSource = data;
|
|
}
|
|
}
|
|
|
|
//private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
|
|
//{
|
|
|
|
//}
|
|
|
|
private void grvDetail_RowCellStyle_1(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
|
|
{
|
|
|
|
|
|
//单元格
|
|
if (e != null && e.RowHandle >= 0 && e.Column.FieldName.Contains("工序") && grvDetail.GetRowCellValue(e.RowHandle, e.Column.FieldName) != null)
|
|
{
|
|
string oppcode = "";
|
|
string oppcodes = "";
|
|
string opcode = grvDetail.GetRowCellValue(e.RowHandle, e.Column.FieldName).ToString();
|
|
string lotno = grvDetail.GetRowCellValue(e.RowHandle, "产品跟踪码").ToString();
|
|
string[] opArray = opcode.Split(':');
|
|
DataSet table = new DataSet();
|
|
if (opArray.Length == 3)
|
|
{
|
|
oppcode = opArray[1];
|
|
}
|
|
else
|
|
{
|
|
oppcode = opArray[0];
|
|
}
|
|
if (opcode.Contains("委外"))
|
|
{
|
|
//判断当前工序供应商与上道工序供应商是否一致
|
|
string sqls = @"SELECT e.VenCode ,f.TransNO
|
|
FROM ICSITEMROUTE2OPLot a WITH(nolock)
|
|
LEFT JOIN ICSMO2User c WITH(nolock) ON a.LotNo=c.LOTNO AND a.OPCODE=c.OPCODE
|
|
LEFT JOIN ICSPO_PoMain e WITH(nolock) ON e.InvCode=a.ITEMCODE+'_'+a.OPCODE AND e.Free1=c.PRLineID
|
|
LEFT JOIN ICSWareHouseLotInfoLog f WITH(nolock) ON a.LotNo=f.LotNO AND f.TransType='收' AND a.OPCODE=f.Memo
|
|
WHERE c.LotNo = '{0}' AND a.OPCODE='{1}'
|
|
ORDER BY a.LotNo,a.OPSEQ ";
|
|
sqls = string.Format(sqls, lotno, oppcode);
|
|
DataSet dts = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqls);
|
|
table = dts;
|
|
if (opcodes.Contains("委外") && opcode.Contains("委外") && dts.Tables[0].Rows.Count > 0 && dts.Tables[0].Rows[0]["VenCode"].ToString() == vencode && dts.Tables[0].Rows[0]["TransNO"].ToString() == pocode)
|
|
{
|
|
e.Appearance.BackColor = color;
|
|
return;
|
|
}
|
|
}
|
|
|
|
string sql = @"SELECT DISTINCT
|
|
a.LOTNO,
|
|
a.OPCODE,
|
|
b.Result,
|
|
a.ACTIONRESULT,
|
|
NCR.ID
|
|
FROM ICSLOTONWIP a WITH(nolock)
|
|
LEFT JOIN ICSLOTONWIPCheck b WITH(nolock) ON a.ID=b.ONWIPID
|
|
LEFT JOIN ICSLOTSIMULATION c WITH(nolock) ON a.MOCODE=c.MOCODE AND a.MOSEQ=c.MOSEQ AND a.LOTNO=c.LOTNO
|
|
LEFT JOIN ICSNCRDoc ncr on ncr.LOTNO=A.LotNO and ncr.OPCode=A.OPCODE and ncr.ErrorType='自检'
|
|
WHERE a.LOTNO='{0}' AND a.OPCODE='{1}' AND (a.EATTRIBUTE1 is null OR a.EATTRIBUTE1 <>'转移') ";
|
|
|
|
sql = string.Format(sql, lotno, oppcode);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
|
|
//完工、检验合格
|
|
if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["Result"].ToString() == "合格" && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END")
|
|
{
|
|
e.Appearance.BackColor = Color.Green;
|
|
color = Color.Green;
|
|
}
|
|
//完工、检验不合格
|
|
else if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["Result"].ToString() == "不合格" && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END")
|
|
{
|
|
e.Appearance.BackColor = Color.Red;
|
|
color = Color.Red;
|
|
}
|
|
//完工、自检不合格
|
|
else if (dt != null && dt.Rows.Count > 0 && (dt.Rows[0]["Result"].ToString() == "") && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END" &&!String.IsNullOrEmpty( dt.Rows[0]["ID"].ToString()))
|
|
{
|
|
e.Appearance.BackColor = Color.FromArgb(254, 177, 95);
|
|
color = Color.FromArgb(254, 177, 95);
|
|
}
|
|
//完工、未检验
|
|
else if (dt != null && dt.Rows.Count > 0 && (dt.Rows[0]["Result"].ToString() == "" || dt.Rows[0]["Result"].ToString() == "待检") && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END")
|
|
{
|
|
e.Appearance.BackColor = Color.GreenYellow;
|
|
color = Color.GreenYellow;
|
|
}
|
|
//开工、未完工
|
|
else if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_BEGIN" && dt.Rows[0]["ACTIONRESULT"].ToString() != "COLLECT_END")
|
|
{
|
|
e.Appearance.BackColor = Color.Yellow;
|
|
color = Color.Yellow;
|
|
}
|
|
else
|
|
{
|
|
color = Color.White;
|
|
}
|
|
|
|
opcodes = grvDetail.GetRowCellValue(e.RowHandle, e.Column.FieldName).ToString();
|
|
if (table.Tables.Count > 0 && table.Tables[0].Rows.Count > 0)
|
|
{
|
|
vencode = table.Tables[0].Rows[0]["VenCode"].ToString();
|
|
pocode = table.Tables[0].Rows[0]["TransNO"].ToString();
|
|
}
|
|
else
|
|
{
|
|
vencode = "";
|
|
pocode = "";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
private void MDeptCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = @"select distinct MDeptCode from icsmo";
|
|
//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.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;
|
|
string type = "";
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
MDeptCode.Text = dr["MDeptCode"].ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|