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.
461 lines
19 KiB
461 lines
19 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.Linq;
|
|
using System.Linq;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Views.BandedGrid;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.Report.GridReport;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSMINNO : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
#region 构造函数
|
|
public FormICSMINNO()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 系统
|
|
#region 操作权限
|
|
public DataTable RightOfExute()
|
|
{
|
|
DataTable rData = new DataTable();
|
|
rData.Columns.Add("BtnName");
|
|
rData.Columns.Add("ActionName");
|
|
//查看权限(必须有)
|
|
DataRow seeRow = rData.NewRow();
|
|
seeRow["BtnName"] = "see";
|
|
seeRow["ActionName"] = "查看";
|
|
rData.Rows.Add(seeRow);
|
|
|
|
List<Control> ControlList = new List<Control>();
|
|
ControlList.Add(btnCreate);
|
|
ControlList.Add(btnOutPut);
|
|
foreach (Control ctr in ControlList)
|
|
{
|
|
|
|
if (ctr.GetType() == typeof(SimpleButton))
|
|
{
|
|
DataRow dr = rData.NewRow();
|
|
dr["BtnName"] = ctr.Name;
|
|
dr["ActionName"] = ctr.Text;
|
|
rData.Rows.Add(dr);
|
|
}
|
|
}
|
|
|
|
rData.AcceptChanges();
|
|
return rData;
|
|
}
|
|
public DataTable RightOfData()// 数据权限
|
|
{
|
|
DataTable rData = new DataTable();
|
|
rData.Columns.Add("BodyName");
|
|
rData.Columns.Add("ControlName");
|
|
rData.Columns.Add("ControlCaption");
|
|
|
|
rData.AcceptChanges();
|
|
return rData;
|
|
}
|
|
#endregion
|
|
|
|
#region 退出
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 移动窗体
|
|
private const int WM_NCHITTEST = 0x84;
|
|
private const int HTCLIENT = 0x1;
|
|
private const int HTCAPTION = 0x2;
|
|
//首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
|
|
//系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
|
|
//假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
|
|
//同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
|
|
|
|
//重写窗体,使窗体可以不通过自带标题栏实现移动
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
|
|
|
|
//当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
|
|
//当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
|
|
//这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
|
|
//注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
|
|
switch (m.Msg)
|
|
{
|
|
case WM_NCHITTEST:
|
|
base.WndProc(ref m);
|
|
if ((int)m.Result == HTCLIENT)
|
|
m.Result = (IntPtr)HTCAPTION;
|
|
return;
|
|
}
|
|
//拦截双击标题栏、移动窗体的系统消息
|
|
if (m.Msg != 0xA3)
|
|
{
|
|
base.WndProc(ref m);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 列表
|
|
private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 导出
|
|
private void btnOutPut_Click(object sender, EventArgs e)
|
|
{
|
|
FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
|
|
foe.ShowDialog();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 刷新
|
|
private void btnRefresh_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
grdDetail_Load(null, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 保存
|
|
private void btnCreate_Click(object sender, EventArgs e)
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
if (SaveBool() == true)
|
|
{
|
|
|
|
|
|
List<ICSMINNO> minnolist = new List<ICSMINNO>();
|
|
//查询工序BOM信息
|
|
string sql = @"select a.*,b.MOPCBAVER,b.MOBIOSVER from ICSOPBOMDETAIL a ";
|
|
sql += " left join ICSMO b on a.ITEMCODE=b.ITEMCODE and a.OPID='" + comROUTE.Text + "'+'" + btnOP.Text + "'+a.ITEMCODE";
|
|
sql += " where a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
//查询批次信息 包括批号,厂商物料代码
|
|
string str = @"select a.*,c.QTY,d.LotNO as [物料批号] from ICSITEMLot a ";
|
|
str += " left join ICSMO b on a.ItemCode=b.ITEMCODE and b.MOCODE='" + btnMO.Text + "'";
|
|
str += " left join ICSWareHouseInfo c on c.INVCode=b.ITEMCODE";
|
|
str += " left join ICSWareHouseLotInfo d on d.INVCode=b.ITEMCODE";
|
|
str += " where a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "' and c.WorkPoint='" + AppConfig.WorkPointCode + "' and d.WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
str = string.Format(str);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, str).Tables[0];
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
ICSMINNO minno = new ICSMINNO();
|
|
if (txtID.Text != "")
|
|
{
|
|
minno.ID = txtID.Text;
|
|
}
|
|
else
|
|
{
|
|
minno.ID = AppConfig.GetGuid();
|
|
}
|
|
minno.SEQ = int.Parse(dr["OBITEMSEQ"].ToString());
|
|
minno.MOBSITEMCODE = dr["OBSITEMCODE"].ToString();
|
|
minno.MITEMCODE = dr["OBITEMCODE"].ToString();
|
|
minno.MOCODE = btnMO.Text;
|
|
minno.ITEMCODE = dr["ITEMCODE"].ToString();
|
|
minno.OPBOMCODE = dr["OBCODE"].ToString();
|
|
minno.OPBOMVER = dr["OPBOMVER"].ToString();
|
|
minno.ROUTECODE = comROUTE.Text;
|
|
minno.OPCODE = btnOP.Text;
|
|
minno.RESCODE = txtRESCODE.Text;//资源代码 (用隐藏框)
|
|
minno.ISTRY = "否";
|
|
minno.TRYITEMCODE = "";
|
|
minno.LOTNO = "";
|
|
minno.PCBA = dr["MOPCBAVER"].ToString();
|
|
minno.BIOS = dr["MOBIOSVER"].ToString();
|
|
minno.VERSION = "";
|
|
minno.VENDORITEMCODE = dt.Rows[0]["VENDORITEMCODE"].ToString();
|
|
minno.VENDORCODE = dt.Rows[0]["VENDORCODE"].ToString();
|
|
minno.DATECODE = DateTime.Parse( dt.Rows[0]["PRODUCTDATE"].ToString());
|
|
minno.QTY = int.Parse(dt.Rows[0]["QTY"].ToString().Split('.')[0].ToString());
|
|
minno.ISLAST = "否";
|
|
minno.MUSER = AppConfig.UserCode;
|
|
minno.MUSERName = AppConfig.UserName;
|
|
minno.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
minno.WorkPoint = AppConfig.WorkPointCode;
|
|
minno.EATTRIBUTE1 = "";
|
|
minno.MITEMNAME = dr["OBITEMNAME"].ToString();
|
|
minno.MITEMPACKEDNO = "";
|
|
minnolist.Add(minno);
|
|
}
|
|
foreach(ICSMINNO minno in minnolist)
|
|
{
|
|
if(minno.SEQ==int.Parse(txtSEQ.Text.Split('.')[0].ToString()))
|
|
{
|
|
minno.LOTNO = txtNO.Text;
|
|
minno.MITEMPACKEDNO = txtNO.Text;
|
|
ICSMINNOBLL.Add(minno,AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox("保存成功!");
|
|
}
|
|
}
|
|
grdDetail_Load(null, null);
|
|
}
|
|
}
|
|
|
|
public bool SaveBool()
|
|
{
|
|
Regex rex = new Regex(@"^\d+$");
|
|
int j = 0;
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
string m = grvDetail.GetRowCellValue(i, OBITEMSEQ).ToString();
|
|
if (m == txtSEQ.Text)
|
|
{
|
|
|
|
if (grvDetail.GetRowCellValue(i, ID).ToString() != "")
|
|
{
|
|
txtID.Text = grvDetail.GetRowCellValue(i, ID).ToString();
|
|
j++;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (btnMO.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("[工单号]不能为空!");
|
|
return false;
|
|
}
|
|
else if (comROUTE.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("[途程]不能为空!");
|
|
return false;
|
|
}
|
|
else if (btnOP.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("[工序]不能为空!");
|
|
return false;
|
|
}
|
|
else if (btnSS.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("[线别]不能为空!");
|
|
return false;
|
|
}
|
|
else if (txtSEQ.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("[顺序号]不能为空!");
|
|
return false;
|
|
}
|
|
else if (txtNO.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("[最小包装条码]不能为空!");
|
|
return false;
|
|
}
|
|
else if(!rex.Match(txtSEQ.Text).Success)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("[顺序号]为正整数!");
|
|
return false;
|
|
}
|
|
else if (j == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("该顺序号不存在!");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
#endregion
|
|
|
|
#region 工单 按钮点击事件
|
|
private void btnMO_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
btnMO.Text = "";
|
|
comROUTE.Text = "";
|
|
btnOP.Text = "";
|
|
btnSS.Text = "";
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = @"select ID,MOCODE as [工单号],MODESC as [描述],MOMEMO as [备注] from ICSMO
|
|
where WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, 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 = 800;
|
|
reForm.FormHeight = 600;
|
|
reForm.FilterKey = btn.Text; //gridView3.GetRowCellValue(gridView3.FocusedRowHandle, gridView3.FocusedColumn).ToString().Trim();
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
btnMO.Text = dr["生产订单号"].ToString();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 途程 下拉框 项赋值
|
|
private void btnMO_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
if (btnMO.Text != "")
|
|
{
|
|
string sql = @"select a.ROUTECODE,b.ROUTEDESC from ICSMO2ROUTE a left join ICSROUTE b on a.ROUTECODE=b.ROUTECODE
|
|
where a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
comROUTE.Items.Add(dr[0].ToString());
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 工序 上料 按钮点击事件
|
|
private void btnOP_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
btnOP.Text = "";
|
|
btnSS.Text = "";
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = @"select a.OPCODE as [工序代码],b.OPDESC as [描述] from ICSROUTE2OP a left join ICSOP b on a.ROUTECODE='" + comROUTE.Text + "' and b.OPCODE=a.OPCODE and SubString(b.OPCONTROL,1,1)='1'";
|
|
sql += " where a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, 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 = 800;
|
|
reForm.FormHeight = 600;
|
|
reForm.FilterKey = btn.Text; //gridView3.GetRowCellValue(gridView3.FocusedRowHandle, gridView3.FocusedColumn).ToString().Trim();
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
btnOP.Text = dr["工序代码"].ToString();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 产线 按钮点击事件
|
|
private void btnSS_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
btnSS.Text = "";
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = @"select DISTINCT b.RESCODE as [资源代码],c.SSCODE as [产线代码],c.SSDESC as [描述] from ICSOP2RES a left join ICSRES b on a.RESCODE=b.RESCODE and a.OPCODE='" + btnOP.Text + "'";
|
|
sql += " left join ICSSS c on b.SSID=c.ID";
|
|
sql += " where a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "' and c.WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, 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("RESCODE");
|
|
reForm.FormWidth = 800;
|
|
reForm.FormHeight = 600;
|
|
reForm.FilterKey = btn.Text; //gridView3.GetRowCellValue(gridView3.FocusedRowHandle, gridView3.FocusedColumn).ToString().Trim();
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
btnSS.Text = dr["产线代码"].ToString();
|
|
txtRESCODE.Text = dr["资源代码"].ToString();//资源代码
|
|
}
|
|
}
|
|
grdDetail_Load(null,null);
|
|
}
|
|
#endregion
|
|
|
|
#region 页面加载事件
|
|
private void grdDetail_Load(object sender, EventArgs e)
|
|
{
|
|
string sql = @"select d.ID as [编号],a.*,c.INVDESC,d.MITEMPACKEDNO from ICSOPBOMDETAIL a ";
|
|
sql += " left join ICSMO b on a.ITEMCODE=b.ITEMCODE";
|
|
sql += " left join ICSITEM2ROUTE e on a.ITEMCODE=e.ITEMCODE ";
|
|
sql += " left join ICSINVENTORY c on a.ITEMCODE=c.INVCODE";
|
|
sql += " left join ICSMINNO d on d.MOCODE='" + btnMO.Text + "' and d.WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql += " where e.ROUTECODE='" + comROUTE.Text + "' and a.OPCODE='" + btnOP.Text + "' and a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "' and c.WorkPoint='" + AppConfig.WorkPointCode + "' and e.WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
grdDetail.DataSource = data;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 下拉框 选择性改变
|
|
private void comROUTE_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
btnOP.Text = "";
|
|
btnSS.Text = "";
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|