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.
541 lines
20 KiB
541 lines
20 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 ICSSoft.Base.Lable.PrintTool;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSBatchsQuery : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
|
|
|
|
private string sqltxt = "";
|
|
private string sqlconn = "";
|
|
String guid = AppConfig.GetGuid();
|
|
private DataTable dataSource = null;
|
|
private string MoId = "";
|
|
private string MoCode = "";
|
|
private decimal Qty = 0.00m;
|
|
DataTable Serialdata = null;
|
|
private string Type = "";
|
|
private string Status = "";
|
|
|
|
#region 构造函数
|
|
public FormICSBatchsQuery()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
|
|
}
|
|
public FormICSBatchsQuery(string moID, string moCode, decimal qty)
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
MoId = moID;
|
|
MoCode = moCode;
|
|
Qty = qty;
|
|
|
|
}
|
|
#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);
|
|
|
|
List<Control> ControlList = new List<Control>();
|
|
|
|
ControlList.Add(btnAdd);
|
|
ControlList.Add(save);
|
|
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 rptPage_PageIndexChanged(object Sender, EventArgs e)
|
|
{
|
|
|
|
DataTable data = AppConfig.GetPageData(Serialdata, rptPage.PageIndex, rptPage.PageSize).Copy();
|
|
grdDetail.DataSource = data;
|
|
}
|
|
#endregion
|
|
|
|
private bool check()
|
|
{
|
|
int i;
|
|
//if (string.IsNullOrWhiteSpace(txtCode.Text.Trim()))
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("生产工单号不能为空!");
|
|
// return false;
|
|
//}
|
|
//if (string.IsNullOrWhiteSpace(cmbSEQ.Text.Trim()))
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("行号不能为空!");
|
|
// return false;
|
|
//}
|
|
//else if(!int.TryParse(cmbSEQ.Text.Trim(),out i))
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("行号格式不正确!");
|
|
// return false;
|
|
//}
|
|
return true;
|
|
}
|
|
//加载
|
|
private void FormICSRdrecord2LOT_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
Serialdata = new DataTable();
|
|
Serialdata.Columns.Add("isSelect");
|
|
Serialdata.Columns.Add("MOCODE");
|
|
Serialdata.Columns.Add("MOSEQ");
|
|
Serialdata.Columns.Add("MOPLANLINE");
|
|
Serialdata.Columns.Add("ITEMCODE");
|
|
Serialdata.Columns.Add("INVNAME");
|
|
Serialdata.Columns.Add("Batch");
|
|
grdDetail.DataSource = Serialdata;
|
|
init();
|
|
}
|
|
|
|
private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
|
|
{
|
|
if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
|
|
{
|
|
e.CellValue = "cccc";
|
|
}
|
|
}
|
|
|
|
#region 新增
|
|
private void btnCreate_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
if (Status.Equals("已经完成"))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("该物料批号已保存!");
|
|
return;
|
|
}
|
|
if (!check())
|
|
{
|
|
return;
|
|
}
|
|
FormICSRdrecord2LOTCreate form = new FormICSRdrecord2LOTCreate(txtCode.Text.Trim(), cmbSEQ.Text.Trim(), txtBatch.Text, Type);
|
|
form.ShowDialog();
|
|
cmbSEQ_SelectedIndexChanged(null, null);
|
|
//if(ICSBaseSimpleCode.AppshowMessageBoxRepose("是否打印?") == DialogResult.OK)
|
|
//{
|
|
// simpleButton4_Click(null, null);
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化查询条件
|
|
private void init()
|
|
{
|
|
#region 生产工单号
|
|
|
|
string sql = "SELECT DISTINCT MOCODE AS [生产工单号] FROM ICSMO WHERE WorkPoint='{0}' ORDER BY MOCODE";
|
|
sql = string.Format(sql, AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
txtCode.Properties.ValueMember = "生产工单号";
|
|
txtCode.Properties.DisplayMember = "生产工单号";
|
|
txtCode.Properties.DataSource = dt;
|
|
txtCode.Properties.NullText = "";//空时的值
|
|
txtCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
txtCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
txtCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
txtCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
txtCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
#region 行号
|
|
private void txtMOCode_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.txtItemCode.Text = "";
|
|
this.txtItemName.Text = "";
|
|
this.txtMOPLANLINE.Text = "";
|
|
this.txtBatch.Text = "";
|
|
//grdDetail.DataSource = null;
|
|
cmbSEQ.Properties.Items.Clear();
|
|
cmbSEQ.Text = "";
|
|
string Code = txtCode.EditValue.ToString();
|
|
|
|
string sql = "SELECT DISTINCT MOSEQ FROM ICSMO WHERE WorkPoint='{0}' AND MOCODE='{1}' ORDER BY MOSEQ";
|
|
sql = string.Format(sql, AppConfig.WorkPointCode, Code);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
|
|
cmbSEQ.Properties.Items.Add(dt.Rows[0]["MOSEQ"].ToString());
|
|
if (cmbSEQ.Properties.Items.Count > 0)
|
|
cmbSEQ.SelectedIndex = 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 信息
|
|
private void cmbSEQ_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Type = "";
|
|
Status = "";
|
|
if (cmbSEQ.Properties.Items.Count <= 0 || !check())
|
|
{
|
|
return;
|
|
}
|
|
DataSet ds = FormICSBatchsQueryBLL.SearchData(txtCode.Text.Trim(), cmbSEQ.Text.Trim(), AppConfig.AppConnectString);
|
|
if (ds != null)
|
|
{
|
|
DataTable dt = ds.Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
txtItemCode.Text = dt.Rows[0]["ITEMCODE"].ToString();
|
|
txtItemName.Text = dt.Rows[0]["INVNAME"].ToString();
|
|
txtMOPLANLINE.Text = dt.Rows[0]["MOPLANLINE"].ToString();
|
|
Type = dt.Rows[0]["TYPE"].ToString();
|
|
Status = dt.Rows[0]["RECSTATUS"].ToString();
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 全选
|
|
private void btnSelectAll_Click(object sender, EventArgs e)
|
|
{
|
|
grvDetail.PostEditor();
|
|
this.Validate();
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
grvDetail.SetRowCellValue(i, colisSelect, "Y");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 全消
|
|
private void btnCancelAll_Click(object sender, EventArgs e)
|
|
{
|
|
grvDetail.PostEditor();
|
|
this.Validate();
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
grvDetail.SetRowCellValue(i, colisSelect, "");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
private void btnDel_Click(object sender, EventArgs e)
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
List<string> rcardList = new List<string>();
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
rcardList.Add(grvDetail.GetRowCellValue(i, colMOCODE).ToString());
|
|
}
|
|
}
|
|
if (rcardList.Count == 0 || rcardList == null)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
|
|
return;
|
|
}
|
|
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该批号吗?删除后无法恢复,确定吗?") != DialogResult.OK)
|
|
{
|
|
btnCancelAll_Click(sender, e);
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
int count = Serialdata.Rows.Count;
|
|
for (int i = count - 1; i >= 0; i--)
|
|
{
|
|
|
|
if (Serialdata.Rows[i]["isSelect"].ToString() == "Y")
|
|
{
|
|
Serialdata.Rows.RemoveAt(i);
|
|
}
|
|
|
|
}
|
|
ICSBaseSimpleCode.AppshowMessageBox("删除成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
cmbSEQ_SelectedIndexChanged(null, null);
|
|
}
|
|
#endregion
|
|
|
|
#region 选中
|
|
private void grvDetail_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, "");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 生成
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
if (txtCode.Text.ToString() == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("工单号不能为空!");
|
|
return;
|
|
}
|
|
if (txtMOPLANLINE.Text.ToString() == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("产线不能为空!");
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
DataRow dz = Serialdata.Rows[i];
|
|
if (txtCode.Text.ToString().Equals(dz["MOCODE"].ToString()) && txtMOPLANLINE.Text.ToString().Equals(dz["MOPLANLINE"].ToString()) && cmbSEQ.Text.ToString().Equals(dz["MOSEQ"].ToString()) && txtBatch.Text.ToString().Equals(dz["Batch"].ToString()))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("该物料条码已存在!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
DataRow dr = Serialdata.NewRow();
|
|
dr["isSelect"] = "";
|
|
dr["MOCODE"] = txtCode.Text.ToString();
|
|
dr["MOPLANLINE"] = txtMOPLANLINE.Text.ToString();
|
|
dr["MOSEQ"] = cmbSEQ.Text.ToString();
|
|
dr["ITEMCODE"] = txtItemCode.Text.ToString();
|
|
dr["INVNAME"] = txtItemName.Text.ToString();
|
|
dr["Batch"] = txtBatch.Text.ToString();
|
|
Serialdata.Rows.Add(dr);
|
|
grdDetail.DataSource = Serialdata;
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
private void save_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
try
|
|
{
|
|
List<ICSInvBatch> batchInfo = new List<ICSInvBatch>();
|
|
int count = Serialdata.Rows.Count;
|
|
for (int i = count - 1; i >= 0; i--)
|
|
{
|
|
DataRow dz = Serialdata.Rows[i];
|
|
ICSInvBatch Batch = new ICSInvBatch();
|
|
Batch.MOCode = dz["MOCODE"].ToString();
|
|
Batch.MORow = dz["MOSEQ"].ToString();
|
|
Batch.InvCode = dz["ITEMCODE"].ToString();
|
|
Batch.SSCODE = dz["MOPLANLINE"].ToString();
|
|
Batch.Batch = dz["Batch"].ToString();
|
|
Batch.MUSER = AppConfig.UserCode;
|
|
Batch.MUSERName = AppConfig.UserName;
|
|
Batch.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
|
|
Batch.WorkPoint = AppConfig.WorkPointCode;
|
|
Batch.EATTRIBUTE1 = null;
|
|
batchInfo.Add(Batch);
|
|
|
|
|
|
}
|
|
FormICSBatchsQueryBLL.AddBatch(batchInfo, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox("操作成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
this.Close();
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 产线
|
|
private void txtMOPLANLINE_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = "select distinct SSDESC as [产线] from dbo.ICSSS with(nolock) WHERE 1=1";
|
|
|
|
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.HideCols.Add("产线");隐藏字段
|
|
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;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
txtMOPLANLINE.Text = dr["产线"].ToString();
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|