华恒Mes鼎捷代码
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.

331 lines
14 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Linq;
using System.Linq;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid;
using System.IO;
using System.Threading;
using ICSSoft.Base.Language.Tool;
using ICSSoft.Base.Config.AppConfig;
using ICSSoft.Base.UserControl.MessageControl;
using ICSSoft.Base.Config.DBHelper;
using ICSSoft.Base.Report.Filter;
using ICSSoft.Base.UserControl.FormControl;
using ICSSoft.Base.Report.GridReport;
using ICSSoft.Base.ReferForm.AppReferForm;
using ICSSoft.Frame.Data.BLL;
using ICSSoft.Frame.Data.Entity;
namespace ICSSoft.Frame.APP
{
public partial class FormICSITEMROUTE2OP : DevExpress.XtraEditors.XtraForm
{
string itemcode;
string routecode;
#region 构造函数
public FormICSITEMROUTE2OP()
{
InitializeComponent();
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
}
#endregion
#region 构造函数
public FormICSITEMROUTE2OP(string item, string route)
{
itemcode = item;
routecode = route;
InitializeComponent();
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
}
#endregion
#region 操作权限
public DataTable RightOfExute()
{
DataTable rData = new DataTable();
rData.Columns.Add("BtnName");
rData.Columns.Add("ActionName");
//查看权限(必须有)
DataRow seeRow = rData.NewRow();
seeRow["BtnName"] = "see";
seeRow["ActionName"] = "查看";
rData.Rows.Add(seeRow);
foreach (Control ctr in this.Controls)
{
if (ctr.GetType() == typeof(SimpleButton))
{
if (ctr.Name == btnClose.Name)
continue;
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
private void grdDetail_DoubleClick(object sender, EventArgs e)
{
if (grvDetail.FocusedRowHandle < 0)
{
return;
}
if (grvDetail.FocusedColumn == colisSelect)
{
if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
{
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
}
else
{
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
}
}
}
private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
{
//e.DisplayText = FormatHelper.
e.CellValue = "cccc";
}
}
private void btnADD_Click(object sender, EventArgs e)
{
#region
//SimpleButton btntemp = (SimpleButton)sender;
//if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
//{
// ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
// return;
//}
#endregion
int count = 0;
for (int i = 0; i < grvDetail.RowCount; i++)
{
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
{
count++;
}
}
if (count != 1)
{
ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
return;
}
try
{
FormICSITEMROUTE2OPUIModel model=new FormICSITEMROUTE2OPUIModel();
for (int i = 0; i < grvDetail.RowCount; i++)
{
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
{
//产品
model.ITEMCODE = grvDetail.GetRowCellValue(i, colaITEMCODE).ToString();
model.item = new FormICSINVENTORYUIModel();
model.item.INVNAME = grvDetail.GetRowCellValue(i, coldINVNAME).ToString();
model.item.INVDESC = grvDetail.GetRowCellValue(i, coldINVDESC).ToString();
//途程
model.ROUTECODE = grvDetail.GetRowCellValue(i, colaROUTECODE).ToString();
model.route = new FormICSROUTEUIModel();
model.route.ROUTEDESC=grvDetail.GetRowCellValue(i, coleROUTEDESC).ToString();
//产品途程
model.ir = new FormICSITEM2ROUTEUIModel();
model.ir.ISREF = grvDetail.GetRowCellValue(i, colbISREF).ToString();
//工序
model.OPCODE = grvDetail.GetRowCellValue(i, colaOPCODE).ToString();
model.op = new FormICSOPUIModel();
model.op.OPDESC = grvDetail.GetRowCellValue(i, colfOPDESC).ToString();
//途程工序
model.ro = new FormICSROUTE2OPUIModel();
model.ro.OPSEQ = Convert.ToInt32(grvDetail.GetRowCellValue(i, colcOPSEQ).ToString());
model.ro.OPCONTROL = grvDetail.GetRowCellValue(i, colcOPCONTROL).ToString();
//产品途程工序
model.OPTIONALOP = grvDetail.GetRowCellValue(i, colOPTIONALOP).ToString();
model.IDMERGETYPE = grvDetail.GetRowCellValue(i, colaIDMERGETYPE).ToString();
model.IDMERGERULE = Convert.ToInt32(grvDetail.GetRowCellValue(i, colaIDMERGERULE).ToString());
FormICSITEMROUTE2OPAdd add = new FormICSITEMROUTE2OPAdd(model);
add.ShowDialog();
}
}
FormICSITEMROUTE2OP_Load(null, null);
}
catch (Exception ex)
{
//throw ex;
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
}
//private void btnDel_Click(object sender, EventArgs e)
//{
// List<string> opList = new List<string>();
// for (int i = 0; i < grvDetail.RowCount; i++)
// {
// if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
// {
// opList.Add(grvDetail.GetRowCellValue(i, colaOPCODE).ToString());
// }
// }
// if (opList.Count == 0)
// {
// ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
// return;
// }
// if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该资源吗?资源删除后将无法恢复!!") != DialogResult.OK)
// {
// return;
// }
// try
// {
// ICSITEMROUTE2OPBLL.deleteInfo(opList,AppConfig.AppConnectString);
// ICSBaseSimpleCode.AppshowMessageBox("删除成功");
// FormICSITEMROUTE2OP_Load(null, null);
// }
// catch (Exception ex)
// {
// ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
// }
//}
private void FormICSITEMROUTE2OP_Load(object sender, EventArgs e)
{
string sql = @"select '' as [isSelect],
a.ITEMID as aITEMID,a.ITEMCODE as aITEMCODE,d.INVNAME as dINVNAME,d.INVDESC as dINVDESC,
a.ROUTEID as aROUTEID,a.ROUTECODE as aROUTECODE,e.ROUTEDESC as eROUTEDESC,
b.ISREF as bISREF,h.STIME as STIME,h.STIME as STIME,h.RTIME as RTIME,
a.OPID as aOPID,a.OPCODE as aOPCODE,f.OPDESC as fOPDESC,a.OPSEQ as cOPSEQ,a.OPCONTROL as cOPCONTROL,--c.OPSEQ as cOPSEQ //update by summer 2020.06.17
cast(SUBSTRING(a.OPCONTROL,1,1) as bit) as [OP_componentloading],
cast(SUBSTRING(a.OPCONTROL,2,1) as bit) as [OP_testing],
cast(SUBSTRING(a.OPCONTROL,3,1) as bit) as [OP_idtranslate],
cast(SUBSTRING(a.OPCONTROL,4,1) as bit) as [OP_packing],
cast(SUBSTRING(a.OPCONTROL,5,1) as bit) as [OP_oqc],
cast(SUBSTRING(a.OPCONTROL,6,1) as bit) as [OP_ts],
cast(SUBSTRING(a.OPCONTROL,7,1) as bit) as [OP_spc],
cast(SUBSTRING(a.OPCONTROL,8,1) as bit) as [OP_deduct],
cast(SUBSTRING(a.OPCONTROL,9,1) as bit) as [OP_midistoutput],
cast(SUBSTRING(a.OPCONTROL,10,1) as bit) as [OP_midistinput],
cast(SUBSTRING(a.OPCONTROL,11,1) as bit) as [OP_ComponentDown],
cast(SUBSTRING(a.OPCONTROL,12,1) as bit) as [OP_BurnIn],
cast(SUBSTRING(a.OPCONTROL,13,1) as bit) as [OP_BurnOut],
cast(SUBSTRING(a.OPCONTROL,14,1) as bit) as [OP_Offline],
a.OPTIONALOP as aOPTIONALOP,a.IDMERGETYPE as aIDMERGETYPE,a.IDMERGERULE as aIDMERGERULE,a.MUSER as MUSER,a.MUSERName as MUSERName,a.MTIME as MTIME,a.WorkPoint as WorkPoint
from ICSITEMROUTE2OP a
left join ICSITEM2ROUTE b on a.ITEMID=b.ITEMID and a.ROUTEID=b.ROUTEID
left join ICSROUTE2OP c on a.ROUTEID=c.ROUTEID and a.OPID=c.OPID
left join ICSINVENTORY d on a.ITEMID=d.ID
left join ICSROUTE e on a.ROUTEID=e.ID
left join ICSOP f on a.OPID=f.ID
left join ICSEQPSTP h on a.ITEMCODE=h.ITEMCODE
where a.ITEMCODE='{0}' and a.ROUTECODE='{1}' order by c.OPSEQ asc";
sql = string.Format(sql, itemcode, routecode);
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
grdDetail.DataSource = dt;
}
private void grdDetail_Click(object sender, EventArgs e)
{
}
public GridColumn colOPTIONALOP { get; set; }
}
}