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.
419 lines
20 KiB
419 lines
20 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSHeatTreatmentAdd : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
int flag;
|
|
string ID;
|
|
string Transno;
|
|
string EQPCode;
|
|
private DataTable data =new DataTable();
|
|
ICSOpFile entity = new ICSOpFile();
|
|
|
|
#region 构造函数
|
|
public FormICSHeatTreatmentAdd()
|
|
{
|
|
InitializeComponent();
|
|
flag = 0;
|
|
}
|
|
public FormICSHeatTreatmentAdd(string id, string transno,string eqpcode)
|
|
{
|
|
InitializeComponent();
|
|
flag = 1;
|
|
ID = id;
|
|
EQPCode = eqpcode;
|
|
Transno = transno;
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭 退出
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
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 save_Click(object sender, EventArgs e)
|
|
{
|
|
entity.MUSER = AppConfig.UserId;
|
|
entity.MUSERName = AppConfig.UserName;
|
|
entity.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
|
|
string mocode = "";
|
|
string moseq = "";
|
|
string eqpcode = "";
|
|
string mover = "";
|
|
string eqpname = "";
|
|
try
|
|
{
|
|
List<ICSOpFile> modelList = new List<ICSOpFile>();
|
|
ICSOpFile model = new ICSOpFile();
|
|
if (txtEQPCode.Text.Trim() == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("设备号不能为空!!!");
|
|
return;
|
|
}
|
|
if (!string.IsNullOrEmpty(ID) && gridView4.RowCount <= 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单信息不能为空!!!");
|
|
return;
|
|
}
|
|
|
|
if (data.Rows.Count>0)
|
|
{
|
|
#region 表中有值
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
//if (mocode != gridView4.GetRowCellValue(i, colMOCODE).ToString() || moseq != gridView4.GetRowCellValue(i, colMOSEQ).ToString() ||
|
|
// eqpcode != gridView4.GetRowCellValue(i, colEQPCode).ToString() || mover != gridView4.GetRowCellValue(i, colMOVER).ToString() ||
|
|
// eqpname != gridView4.GetRowCellValue(i, colEQPName).ToString()
|
|
// )
|
|
//{
|
|
// if (i > 0)
|
|
// {
|
|
// modelList.Add(model);
|
|
// model = new ICSOpFile();
|
|
// }
|
|
// mocode = gridView4.GetRowCellValue(i, colMOCODE).ToString();
|
|
// moseq = gridView4.GetRowCellValue(i, colMOSEQ).ToString();
|
|
// eqpcode = gridView4.GetRowCellValue(i, colEQPCode).ToString();
|
|
// mover = gridView4.GetRowCellValue(i, colMOVER).ToString();
|
|
// eqpname = gridView4.GetRowCellValue(i, colEQPName).ToString();
|
|
|
|
// model.MOCODE = mocode;
|
|
// model.MOSEQ = moseq;
|
|
// model.EQPCode = eqpcode;
|
|
// model.EATTRIBUTE2 =mover; //零件号
|
|
// model.EATTRIBUTE3 = eqpname;//设备名称
|
|
//}
|
|
//else
|
|
//{
|
|
if (model.LOTNOs != null)
|
|
{
|
|
model.LOTNOs += gridView4.GetRowCellValue(i, colLotNO).ToString() + ";";
|
|
if (!model.MOCODE.Contains(data.Rows[i]["MOCODE"].ToString()))
|
|
{
|
|
model.MOCODE += gridView4.GetRowCellValue(i, colMOCODE).ToString() + ";";
|
|
}
|
|
if (!model.MOSEQ.Contains(data.Rows[i]["MOSEQ"].ToString()))
|
|
{
|
|
model.MOSEQ += gridView4.GetRowCellValue(i, colMOSEQ).ToString() + ";";
|
|
}
|
|
if (!model.EQPCode.Contains(data.Rows[i]["EQPCode"].ToString()))
|
|
{
|
|
model.EQPCode += gridView4.GetRowCellValue(i, colEQPCode).ToString() + ";";
|
|
}
|
|
if (!model.EATTRIBUTE2.Contains(data.Rows[i]["VenderLotNo"].ToString()))
|
|
{
|
|
model.EATTRIBUTE2 += gridView4.GetRowCellValue(i, gridColumn11).ToString() + ";";
|
|
}
|
|
if (!model.EATTRIBUTE3.Contains(data.Rows[i]["EQPName"].ToString()))
|
|
{
|
|
model.EATTRIBUTE3 += gridView4.GetRowCellValue(i, colEQPName).ToString() + ";";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
model.MOCODE += gridView4.GetRowCellValue(i, colMOCODE).ToString() + ";";
|
|
model.MOSEQ += gridView4.GetRowCellValue(i, colMOSEQ).ToString() + ";";
|
|
model.EQPCode += gridView4.GetRowCellValue(i, colEQPCode).ToString() + ";";
|
|
model.EATTRIBUTE2 += gridView4.GetRowCellValue(i, gridColumn11).ToString() + ";";
|
|
model.EATTRIBUTE3 += gridView4.GetRowCellValue(i, colEQPName).ToString() + ";";
|
|
model.LOTNOs += gridView4.GetRowCellValue(i, colLotNO).ToString() + ";";
|
|
}
|
|
//}
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
model.EQPCode = txtEQPCode.Text.Trim();
|
|
model.EATTRIBUTE3= txtEQPName.Text.Trim();
|
|
}
|
|
model.ID = AppConfig.GetGuid();
|
|
//model.MOCODE = txtMOCode.Text.Trim();
|
|
//model.MOSEQ = Convert.ToInt16(txtMORow.Text.Trim());
|
|
//model.EQPCode = txtEQPCode.Text.Trim();
|
|
model.MUSER = AppConfig.UserId;
|
|
model.MUSERName = AppConfig.UserName;
|
|
model.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
model.WorkPoint = AppConfig.WorkPointCode;
|
|
modelList.Add(model);
|
|
|
|
if (modelList.Count <= 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!!!");
|
|
return;
|
|
}
|
|
|
|
if (flag == 0)
|
|
{
|
|
//ICSHeatTreatmentBLL.AddList(modelList, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox("炉号新增成功!!!");
|
|
this.Close();
|
|
this.DialogResult = DialogResult.Yes;
|
|
}
|
|
else if (flag == 1)
|
|
{
|
|
//ICSHeatTreatmentBLL.AddSample(modelList, ID, Transno, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox("试样号新增成功!!!");
|
|
this.Close();
|
|
this.DialogResult = DialogResult.Yes;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 取消
|
|
private void can_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region 双击
|
|
private void grdDetail_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (grdDetail.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
if (txtMOCode.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("工单号不能为空!");
|
|
return;
|
|
}
|
|
if (txtEQPCode.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("设备号不能为空!");
|
|
return;
|
|
}
|
|
if (grdDetail.FocusedColumn == colisSelect)
|
|
{
|
|
if (grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colisSelect).ToString() == "")
|
|
{
|
|
grdDetail.SetRowCellValue(grdDetail.FocusedRowHandle, colisSelect, "Y");
|
|
DataRow[] drs = data.Select("LotNO='" + grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colLotNO).ToString() + "'");
|
|
if (drs.Length<=0)
|
|
{
|
|
DataRow dr = data.NewRow();
|
|
dr["LotNO"] = grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colLotNO).ToString();
|
|
dr["ItemCode"] = grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colMCODE).ToString();
|
|
dr["INVNAME"] = grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colINVNAME).ToString();
|
|
dr["INVSTD"] = grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colINVSTD).ToString();
|
|
dr["INVUOM"] = grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colINVUOM).ToString();
|
|
dr["num"] = grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colnum).ToString();
|
|
dr["VenderLotNo"] = grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colVenderLotNo).ToString();
|
|
dr["INVEXPORTIMPORT"] = grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colINVEXPORTIMPORT).ToString();
|
|
dr["MOCODE"] = txtMOCode.Text.Trim();
|
|
dr["MOVER"] = txtMoverCode.Text.Trim();
|
|
dr["EQPCODE"] = txtEQPCode.Text.Trim();
|
|
dr["EQPName"] = txtEQPName.Text.Trim();
|
|
dr["MOSEQ"] = txtMORow.Text.Trim();
|
|
data.Rows.Add(dr);
|
|
gridControl1.DataSource = data;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
grdDetail.SetRowCellValue(grdDetail.FocusedRowHandle, colisSelect, "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 页面加载
|
|
private void FormICSItenLotAdd_Load(object sender, EventArgs e)
|
|
{
|
|
init();
|
|
load();
|
|
//新增试样号,设备号不可选
|
|
if (!string.IsNullOrEmpty(EQPCode))
|
|
{
|
|
txtEQPCode.Text = EQPCode;
|
|
txtEQPCode.Enabled = false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化查询条件
|
|
private void init()
|
|
{
|
|
string sql = @" SELECT MOCODE+'-'+MOSEQ AS 工单,MOCODE AS 工单号,MOSEQ AS 生产订单行号,ITEMCODE AS 存货编码,b.INVNAME AS 存货名称,MOPLANQTY AS 工单数量,b.INVSTD AS 规格型号,
|
|
MOVER AS 零件号,MOTYPE AS 工单类型
|
|
FROM ICSMO a
|
|
INNER JOIN ICSINVENTORY b ON a.ITEMCODE=b.INVCODE ORDER BY MOCODE,MOSEQ";
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
txtMOCode.Properties.ValueMember = "工单";
|
|
txtMOCode.Properties.DisplayMember = "工单号";
|
|
txtMOCode.Properties.DataSource = dt;
|
|
txtMOCode.Properties.NullText = "";//空时的值
|
|
txtMOCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
txtMOCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
txtMOCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
txtMOCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
txtMOCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
|
|
|
|
#region 设备
|
|
sql = @"select EQPCode as 设备号,EQPName as 设备名称
|
|
from ICSEquipment";
|
|
dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
txtEQPCode.Properties.ValueMember = "设备号";
|
|
txtEQPCode.Properties.DisplayMember = "设备号";
|
|
txtEQPCode.Properties.DataSource = dt;
|
|
txtEQPCode.Properties.NullText = "";//空时的值
|
|
txtEQPCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
txtEQPCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
txtEQPCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
txtEQPCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
txtEQPCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 工单号改变
|
|
private void txtMOCode_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;
|
|
txtMORow.Text = RowView.Row["生产订单行号"].ToString();
|
|
txtCode.Text = RowView.Row["存货编码"].ToString();
|
|
txtcInvName.Text = RowView.Row["存货名称"].ToString();
|
|
txtMoverCode.Text = RowView.Row["零件号"].ToString();
|
|
txtcInvStd.Text = RowView.Row["规格型号"].ToString();
|
|
txtMOType.Text = RowView.Row["工单类型"].ToString();
|
|
txtiQuantity.Text = RowView.Row["工单数量"].ToString();
|
|
|
|
string sql = @"SELECT '' as isSelect,a.LotNO,a.ItemCode,b.INVNAME,b.INVSTD,a.LOTQTY,b.INVUOM,
|
|
CONVERT(NUMERIC(10,3),(a.LOTQTY*a.EATTRIBUTE3)) AS num,b.INVEXPORTIMPORT,
|
|
a.VenderLotNO as VenderLotNo
|
|
FROM ICSITEMLot a
|
|
INNER JOIN ICSINVENTORY b ON a.ItemCode=b.INVCODE
|
|
WHERE a.TransNO='{0}' AND a.TransLine='{1}' AND ISNULL(a.EATTRIBUTE6, '')<>''
|
|
ORDER BY a.LotNO";
|
|
sql = string.Format(sql, txtMOCode.Text.Trim(), txtMORow.Text.Trim());
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
grvDetail.DataSource = dt;
|
|
grdDetail.BestFitColumns();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 设备号改变
|
|
private void txtEQPCode_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string Code = txtEQPCode.Text.ToString();
|
|
string sql = @"select EQPCode as 设备号,EQPName as 设备名称
|
|
from ICSEquipment
|
|
WHERE EQPCode='{0}'";
|
|
sql = string.Format(sql, Code);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
txtEQPName.Text = dt.Rows[0]["设备名称"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void load()
|
|
{
|
|
string sql = @"SELECT '' as isSelect,a.LotNO,a.ItemCode,b.INVNAME,b.INVSTD,a.LOTQTY,b.INVUOM,CONVERT(NUMERIC(10,3),(a.LOTQTY*a.EATTRIBUTE3)) AS num,b.INVEXPORTIMPORT
|
|
,c.MOCODE,a.VenderLotNO as VenderLotNo,c.MOVER,a.EATTRIBUTE1 as EQPCODE,a.EATTRIBUTE2 as EQPName,c.MOSEQ
|
|
FROM ICSITEMLot a
|
|
INNER JOIN ICSINVENTORY b ON a.ItemCode=b.INVCODE
|
|
LEFT JOIN ICSMO c ON a.TransNO=c.MOCODE AND a.TransLine=c.MOSEQ
|
|
WHERE 1!=1
|
|
ORDER BY a.LotNO";
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
data = dt;
|
|
}
|
|
|
|
#region 删除
|
|
private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
gridView4.DeleteRow(gridView4.FocusedRowHandle);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|