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.
268 lines
9.3 KiB
268 lines
9.3 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 ICSSoft.Frame.Data.BLL;
|
|
using System.Data.SqlClient;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSOPBOM : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
String guid = AppConfig.GetGuid();
|
|
private DataTable dataSource = null;
|
|
String itemid = null;
|
|
string workpoint;
|
|
|
|
#region 构造函数
|
|
public FormICSOPBOM()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
}
|
|
#endregion
|
|
|
|
public FormICSOPBOM(string id,string WORKPOINT)
|
|
{
|
|
itemid = id;
|
|
workpoint = WORKPOINT;
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
}
|
|
|
|
#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(btnAdd);
|
|
ControlList.Add(btnExit);
|
|
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 btnFalsh_Click(object sender, EventArgs e)
|
|
{
|
|
grdDetail_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
|
|
|
|
|
|
private void grdDetail_Click(object sender, EventArgs e)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add();
|
|
}
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
int count = 0;
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
count++;
|
|
}
|
|
}
|
|
if (count != 1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
grvDetail.SetRowCellValue(i, colisSelect, "");
|
|
}
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
string itemid;
|
|
string routeid;
|
|
string opid;
|
|
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
itemid = grvDetail.GetRowCellValue(i, colITEMID).ToString();
|
|
routeid = grvDetail.GetRowCellValue(i, colROUTEID).ToString();
|
|
opid = grvDetail.GetRowCellValue(i, colOPID).ToString();
|
|
FormICSOPBOMDETAIL add = new FormICSOPBOMDETAIL(itemid,routeid,opid,workpoint);
|
|
add.ShowDialog();
|
|
}
|
|
}
|
|
btnFalsh_Click(null, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 双击选择
|
|
private void grdDetail_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (grvDetail.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
if (grvDetail.FocusedColumn == colisSelect)
|
|
{
|
|
string a = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString();
|
|
if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
|
|
}
|
|
else
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void grdDetail_Load(object sender, EventArgs e)
|
|
{
|
|
String sql = "select '' as isSelect,a.ITEMID as 产品编号,b.INVDESC as 规格型号,a.ROUTEID as 途程编号,c.ROUTEDESC as 途程描述,d.OPDESC as 工序,a.OPID as 工序编号,b.INVCODE as 存货编码,c.ROUTECODE as 途程代码,d.OPCODE as 工序代码,a.OPSEQ as 工序次序,"+
|
|
"a.OPCONTROL as 工序类型,a.MUSER as 维护人,a.MTIME as 维护时间,a.WorkPoint as 站点 from ICSITEMROUTE2OP as a,ICSINVENTORY as b,ICSROUTE as c ,ICSOP as d"+
|
|
" where a.ITEMID='" + itemid + "' and a.ITEMID=b.ID and a.ROUTEID=c.ID and a.OPID=d.ID and SUBSTRING(a.OPCONTROL,1,1)='1' and a.WorkPoint='" + AppConfig.WorkPointCode + "' and b.WorkPoint='" + AppConfig.WorkPointCode + "'"+
|
|
" and c.WorkPoint='" + AppConfig.WorkPointCode + "' and d.WorkPoint='" + AppConfig.WorkPointCode + "' order by a.ITEMID,a.ROUTEID,c.ROUTECODE,a.OPSEQ";
|
|
try
|
|
{
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
grdDetail.DataSource = dt;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|