|
|
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 FormICSPickingEditAdd : DevExpress.XtraEditors.XtraForm { string VRow = ""; String guid = ""; FormICSPickingModel entity = new FormICSPickingModel();
#region 构造函数
public FormICSPickingEditAdd() { InitializeComponent(); this.txtWeight.Properties.ReadOnly = true; if (this.cboIsMROItem.Checked == true) { this.txtMOCode.Properties.ReadOnly = true; this.txtMORow.Properties.ReadOnly = true; txtMOCode.Enabled = false;
txtMO.Enabled = false; } else { this.txtOutCategory.Properties.ReadOnly = true;
//20200407新增
this.txtMROBatch.Enabled = false; this.txtMROBatch.Properties.ReadOnly = true;
txtMO.Enabled = true; }
} public FormICSPickingEditAdd(String id) { InitializeComponent(); guid = id; this.txtWeight.Properties.ReadOnly = true; if (cboIsMROItem.Checked == true)//是否MRO物料选中
{ txtMO.Enabled = false; txtMOCode.Properties.ReadOnly = true; txtMORow.Properties.ReadOnly = true; } else { txtOutCategory.Properties.ReadOnly = true;
//20200407新增
this.txtMROBatch.Enabled = false; this.txtMROBatch.Properties.ReadOnly = true;
txtMO.Enabled = true; } } #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) { //if (txtPickingNO.Text.Trim() == "" || txtWHCode.Text.Trim() == "" || txtCode.Text.Trim() == "" || txtiQuantity.Text.Trim() == "" )
//if (txtPickingNO.Text.Trim() == "" || txtWHCode.Text.Trim() == "" || txtOutCategory.Text.Trim() == "")
//{
// ICSBaseSimpleCode.AppshowMessageBox("请输入退料单号、仓库、出库类别内容!");
// return;
//}
for (int i = 0; i < grdDetail.RowCount; i++) { string PickingNO = string.Empty; PickingNO = grdDetail.GetRowCellValue(i, colPickingNO).ToString(); if (string.IsNullOrWhiteSpace(PickingNO)) { ICSBaseSimpleCode.AppshowMessageBox("请添加字表行信息!"); return; } }
entity.ID = guid; entity.VouchCode = txtPickingNO.Text.Trim(); entity.MUSER = AppConfig.UserCode; entity.MUSERName = AppConfig.UserName; entity.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss"); entity.WorkPoint = AppConfig.WorkPointCode; entity.EATTRIBUTE1 = null; entity.CreateTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss"); entity.CreateUSER = AppConfig.UserName; entity.IsPickingOrBack = 3; entity.IsMROItem = this.cboIsMROItem.Checked; //是否MRO物料
entity.WHCode = txtWHCode.Text.Trim(); //仓库
entity.OutCategory = txtOutCategory.Text.Trim();//出库类别
try {
guid = ICSPickingBLL.Add(entity, AppConfig.AppConnectString); this.Close(); ICSBaseSimpleCode.AppshowMessageBox("操作成功"); } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); } } #endregion
#region 取消
private void can_Click(object sender, EventArgs e) { this.Close(); } #endregion
#region 页面加载
private void FormICSINVENTORYEditAdd_Load(object sender, EventArgs e) { if (guid != "") { lblTitle.Text = "退料单维护"; txtPickingNO.Properties.ReadOnly = true; txtWHCode.Properties.ReadOnly = true; entity = ICSPickingBLL.SearchInfoByID(guid, AppConfig.AppConnectString); txtPickingNO.Text = entity.VouchCode; txtWHCode.Text = entity.WHCode; txtMUSERName.Text = AppConfig.UserName; txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); txtOutCategory.Text = entity.OutCategory; cboIsMROItem.Checked = entity.IsMROItem;
txtOutCategory.Properties.ReadOnly = true; cboIsMROItem.Enabled = false; //cboIsMROItem
txtMOCode.Properties.ReadOnly = true; txtMORow.Properties.ReadOnly = true;
DataTable body = ICSPickingBLL.GetDetailList(entity.VouchCode); grvDetail.DataSource = body; grdDetail.BestFitColumns();
txtMOCode.Text = ""; txtMORow.Text = ""; txtMoverCode.Text = ""; txtDDNo.Text = ""; txtCode.Text = ""; txtcInvName.Text = ""; txtiQuantity.Text = "";
txtcInvStd.Text = ""; txtINVUOM.Text = ""; txtWeight.Text = "";
txtDetailId.Text = "0";
txtRemarks.Text = ""; txtAllWeight.Text = "";
} else { lblTitle.Text = "退料单维护"; txtPickingNO.Properties.ReadOnly = true; txtPickingNO.Text = ICSPickingBLL.GetOutInNo(AppConfig.AppConnectString); txtMUSERName.Text = AppConfig.UserName; txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string sqlYTMoverCode = @"SELECT '' as [零件号] "; DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0]; txtMoverCode.Properties.ValueMember = "零件号"; txtMoverCode.Properties.DisplayMember = "零件号"; txtMoverCode.Properties.DataSource = _dt; txtMoverCode.Properties.NullText = "";//空时的值
txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
string sqlYTLineNo = @"SELECT '' as [生产订单行号号] "; DataTable _dt_ = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTLineNo).Tables[0]; txtMORow.Properties.ValueMember = "生产订单行号号"; txtMORow.Properties.DisplayMember = "生产订单行号号"; txtMORow.Properties.DataSource = _dt; txtMORow.Properties.NullText = "";//空时的值
txtMORow.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtMORow.Properties.ValidateOnEnterKey = true;//回车确认
txtMORow.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtMORow.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtMORow.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
#region
//4.1. 当勾选‘是否MRO物料’后,系统判定:工单号,工号行号为灰色,不可选取;
//4.2. 当勾选取消时,系统判定:出库类别,为灰色,不可选取;
//if (cboIsMROItem.Checked == true)//是否MRO物料选中
//{
// txtMOCode.Properties.ReadOnly = true;
// txtMORow.Properties.ReadOnly = true;
//}
//else
//{
// txtOutCategory.Properties.ReadOnly = true;
//}
#endregion
} init(); } #endregion
#region 初始化查询条件
private void init() { #region 存货编码
string sql = "SELECT DISTINCT INVCODE AS [存货编码] ,INVNAME AS [存货名称] ,INVSTD AS [规格型号] FROM ICSINVENTORY WHERE WorkPoint='{0}' ORDER BY INVCODE "; 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
#region 仓库
string sql1 = "SELECT DISTINCT StorageCode AS [仓库编号] ,StorageName AS[仓库名称] FROM ICSStorage WHERE WorkPoint='{0}' ORDER BY StorageCode"; sql1 = string.Format(sql1, AppConfig.WorkPointCode); DataTable dt1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql1).Tables[0]; txtWHCode.Properties.ValueMember = "仓库编号"; txtWHCode.Properties.DisplayMember = "仓库编号"; txtWHCode.Properties.DataSource = dt1; txtWHCode.Properties.NullText = "";//空时的值
txtWHCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtWHCode.Properties.ValidateOnEnterKey = true;//回车确认
txtWHCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtWHCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtWHCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion
#region 出库类型
string sql2 = "SELECT DISTINCT cRdCode AS [出库类型编号],cRdName AS [出库类型名称] FROM ICSRdStyle WHERE WorkPoint = '{0}' AND bRdFlag=0 AND bRdEnd=1 ORDER BY cRdCode"; sql2 = string.Format(sql2, AppConfig.WorkPointCode); DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0]; txtOutCategory.Properties.ValueMember = "出库类型编号"; txtOutCategory.Properties.DisplayMember = "出库类型编号"; txtOutCategory.Properties.DataSource = dt2; txtOutCategory.Properties.NullText = "";//空时的值
txtOutCategory.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtOutCategory.Properties.ValidateOnEnterKey = true;//回车确认
txtOutCategory.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtOutCategory.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtOutCategory.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion
#region 工单号
string sql3 = @"SELECT DISTINCT MOCODE 生产工单号, MOSEQ 行号, CUSNAME 订单类型, ITEMCODE 存货编码, INVNAME 存货名称, INVSTD 规格型号, MOVER 订单总批号
FROM ICSMO A INNER JOIN ICSINVENTORY B ON A.ITEMCODE = B.INVCODE WHERE 1=1 ORDER BY MOCODE";
sql2 = string.Format(sql3, AppConfig.WorkPointCode); DataTable dt3 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0]; txtMO.Properties.ValueMember = "生产工单号"; txtMO.Properties.DisplayMember = "生产工单号"; txtMO.Properties.DataSource = dt3; txtMO.Properties.NullText = "";//空时的值
txtMO.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtMO.Properties.ValidateOnEnterKey = true;//回车确认
txtMO.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtMO.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtMO.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion
#region 部门
string sql4 = "SELECT DISTINCT cDepCode AS [部门编号],cDepName AS [部门名称] FROM ICSDepartment WHERE WorkPoint = '{0}' AND bDepEnd = 1 ORDER BY cDepCode"; sql4 = string.Format(sql4, AppConfig.WorkPointCode); DataTable dt4 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql4).Tables[0]; txtDept.Properties.ValueMember = "部门编号"; txtDept.Properties.DisplayMember = "部门编号"; txtDept.Properties.DataSource = dt4; txtDept.Properties.NullText = "";//空时的值
txtDept.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtDept.Properties.ValidateOnEnterKey = true;//回车确认
txtDept.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtDept.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtDept.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion
} #endregion
#region 零件号
// //txtMoverCode txtMOCode工单号 20191111新增 历史数据中零件号进行对比
private void initMoverCode(string mocode) { //string sqlYTMoverCode = @"select distinct a.venderlotno as [零件号] from icsitemlot a where a.transno='{0}' ";
//sqlYTMoverCode = string.Format(sqlYTMoverCode, mocode);
//20200407新增
string sqlYTMoverCode = @"SELECT DISTINCT b.VenderLotNO as [零件号]
from ICSWareHouseLotInfoLog a left JOIN ICSITEMLot b on b.lotno=a.LotNO where a.TransNO='{0}' and a.TransLine='{1}' ";
sqlYTMoverCode = string.Format(sqlYTMoverCode, mocode, txtMORow.Text);
DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0]; txtMoverCode.Properties.ValueMember = "零件号"; txtMoverCode.Properties.DisplayMember = "零件号"; txtMoverCode.Properties.DataSource = _dt; txtMoverCode.Properties.NullText = "";//空时的值
txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; txtMoverCode.EditValue = ""; txtMoverCode.Text = ""; //if (txtMOCode.Text == "")
//{
//}
if (mocode == "") { } if (_dt.Rows.Count > 0) { //默认选择第一项
txtMoverCode.EditValue = _dt.Rows[0][0].ToString().Trim(); } } #endregion
#region 工单号
private void txtMOCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { string sql = @" SELECT DISTINCT MOCODE AS [工单号],MOSEQ AS [生产订单行号],ITEMCODE AS [料品编码] FROM ICSMO "; DataTable data = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0]; FormDataRefer reForm = new FormDataRefer(); reForm.FormTitle = "工单信息"; reForm.DataSource = data; reForm.MSelectFlag = false; reForm.RowIndexWidth = 35; reForm.Width = 600; reForm.FormHeight = 900; if (reForm.ShowDialog() == DialogResult.OK) { foreach (DataRow dr in reForm.ReturnData.Rows) { txtMOCode.Text = dr["生产订单号"].ToString();
} } //if (data != null&&data.Rows.Count>0) {
// txtMORow.Text = data.Rows[0]["生产订单行号"].ToString();
// txtMoverCode.Text = data.Rows[0]["苏船工号"].ToString();
//}
initMoverCode(txtMOCode.Text); } #endregion
//#region 库房
//private void txtWHCode_EditValueChanged(object sender, EventArgs e)
//{
// string sql = "SELECT DISTINCT StorageCode AS [仓库编号] FROM ICSStorage WHERE WorkPoint='{0}' ORDER BY StorageCode";
// sql = string.Format(sql, AppConfig.WorkPointCode);
// DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
// txtWHCode.Properties.ValueMember = "行号";
// txtWHCode.Properties.DisplayMember = "行号";
// txtWHCode.Properties.DataSource = dt;
// txtWHCode.Properties.NullText = "";//空时的值
// txtWHCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
// txtWHCode.Properties.ValidateOnEnterKey = true;//回车确认
// txtWHCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
// txtWHCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
// //自适应宽度
// txtWHCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
//}
//#endregion
#region 行号
private void txtMORow_EditValueChanged(object sender, EventArgs e) { string MOCODE = txtMOCode.EditValue.ToString(); //string sql = "SELECT DISTINCT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE='{0}' ORDER BY MOSEQ";
string sql = "SELECT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE = '{0}' ORDER BY CAST (MOSEQ AS INT)";
sql = string.Format(sql, MOCODE); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; txtMORow.Properties.ValueMember = "行号"; txtMORow.Properties.DisplayMember = "行号"; txtMORow.Properties.DataSource = dt; txtMORow.Properties.NullText = "";//空时的值
txtMORow.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtMORow.Properties.ValidateOnEnterKey = true;//回车确认
txtMORow.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtMORow.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtMORow.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; txtMORow.EditValue = ""; txtMoverCode.Text = ""; if (MOCODE == "") { //txtMoverCode.Properties.ReadOnly = false;
} else { //txtMoverCode.Properties.ReadOnly = true;
} //DataTable dt_temp = (DataTable)glue.Properties.DataSource;
//if (dt_temp.Rows.Count > 0)
if (dt.Rows.Count > 0) { //默认选择第一项
txtMORow.EditValue = dt.Rows[0][0].ToString().Trim(); } } #endregion
/// <summary>
/// 退料单保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSaveDetail_Click(object sender, EventArgs e) { try { //20190911新增一个单据只能保存一个是否MRO物料
string sqlIsMRO = @" SELECT
j.IsMROItem, a.MoveType FROM ICSMaterialPick a LEFT JOIN ICSMaterial j ON a.VouchCode = j.VouchCode WHERE a.VouchCode = '{0}' AND a.WorkPoint = '" + AppConfig.WorkPointCode + "' ";
sqlIsMRO = string.Format(sqlIsMRO, this.txtPickingNO.Text); DataTable dtIsMRO = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlIsMRO).Tables[0]; if (dtIsMRO != null && dtIsMRO.Rows.Count > 0) { bool _IsMRO = bool.Parse(dtIsMRO.Rows[0][0].ToString()); if (_IsMRO != this.cboIsMROItem.Checked) { ICSBaseSimpleCode.AppshowMessageBox("一张退料单不能即出现MRO物料又出现非MRO物料!"); return; } }
if (txtWHCode.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("请选择仓库!"); return; } if (txtCode.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("存货编码不能为空"); return; } if (txtiQuantity.Text == "" || Convert.ToDecimal(txtiQuantity.Text) == 0) { ICSBaseSimpleCode.AppshowMessageBox("数量不能为空"); return; }
if (this.cboIsMROItem.Checked == true) { if (this.txtOutCategory.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("入库类别不能为空"); return; } } //判断,如果存货编码参数bInvBatch(是否批次管理)为打钩状态,那么零件号不能为空,需报错;
//如果bInvBatch(是否批次管理)未打钩,零件号填了数值,那么也需要报错;
if (true) { if (cboIsMROItem.Checked) { string sql = @" SELECT INVCONTROLTYPE FROM ICSINVENTORY a WHERE INVCODE='" + this.txtCode.Text + "' "; sql = string.Format(sql); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { bool IsbInvBatch = bool.Parse(dt.Rows[0][0].ToString()); if (IsbInvBatch) { if (txtMROBatch.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("MRO批号不能为空"); return; } } else { if (txtMROBatch.Text != "") { ICSBaseSimpleCode.AppshowMessageBox("MRO批号需要为空,不能维护"); return; } } } else { ICSBaseSimpleCode.AppshowMessageBox("物料表中没有该物料,不能进行保存"); return; } } else { string sql = @" SELECT INVCONTROLTYPE FROM ICSINVENTORY a WHERE INVCODE='" + this.txtCode.Text + "' "; sql = string.Format(sql); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { bool IsbInvBatch = bool.Parse(dt.Rows[0][0].ToString()); if (IsbInvBatch) { if (txtMoverCode.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("零件号不能为空"); return; } } else { if (txtMoverCode.Text != "") { ICSBaseSimpleCode.AppshowMessageBox("零件号需要为空,不能维护"); return; } } } else { ICSBaseSimpleCode.AppshowMessageBox("物料表中没有该物料,不能进行保存"); return; } } }
#region 验证退料数量是否大于领料数量 20200413
if (cboIsMROItem.Checked == false) { //工单领料数量
#region delete by summer 2020.04.16
// string sql = @"
//SELECT ISNULL(c.HasQuantity, 0) HasQuantity FROM ICSMO a
//INNER JOIN ICSMOBOM b ON a.MOCODE=b.MOCODE
//INNER JOIN ICSMOPickLog c ON B.MOCODE=C.MOCODE AND B.SEQ=C.MOSEQ and B.MOBOMLINE=C.SEQ
//WHERE b.MOCODE = '{0}'
//AND b.SEQ = '{1}'
//AND b.MOBITEMCODE = '{2}'
//AND a.MOVER='{3}' ";
#endregion
#region delete by summer 2020.07.04
// string sql = @"
//SELECT ISNULL(c.HasQuantity, 0) HasQuantity FROM ICSMO A
//INNER JOIN ICSMOBOM b ON a.MOCODE=b.MOCODE AND A.MOSEQ = B.SEQ
//INNER JOIN ICSMOPickLog c ON B.MOCODE=C.MOCODE AND B.SEQ=C.MOSEQ and B.MOBOMLINE=C.SEQ
//INNER JOIN ICSWareHouseLotInfoLog D ON D.TransNO = C.MOCODE AND D.TransLine = C.MOSEQ
//INNER JOIN ICSITEMLot E ON D.LotNO = E.LotNO
//WHERE b.MOCODE = '{0}' AND b.SEQ = '{1}' AND b.MOBITEMCODE = '{2}' AND E.VenderLotNO = '{3}' ";
// //sql = string.Format(sql, this.txtMO.EditValue.ToString(), this.txtMORow.Text, this.txtCode.Text, this.txtMoverCode.Text);
#endregion
string sql = @"
SELECT ISNULL(c.HasQuantity, 0) HasQuantity FROM ICSMO A INNER JOIN ICSMOBOM b ON a.MOCODE=b.MOCODE AND A.MOSEQ = B.SEQ INNER JOIN ICSMOPickLog c ON B.MOCODE=C.MOCODE AND B.SEQ=C.MOSEQ and B.MOBOMLINE=C.SEQ WHERE b.MOCODE = '{0}' AND b.SEQ = '{1}' AND B.MOBITEMCODE = '{2}' ";
sql = string.Format(sql, this.txtMO.EditValue.ToString(), this.txtMORow.Text, this.txtCode.Text); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; Decimal Qty = 0; if (dt != null && dt.Rows.Count > 0) { foreach (DataRow item in dt.Rows) { Qty += Decimal.Parse(item["HasQuantity"].ToString()); } }
#region 原逻辑 delete by summer 2021.03.01
// string oldTLSql = string.Empty;
// if (!string.IsNullOrWhiteSpace(this.txtMoverCode.Text))
// {
// oldTLSql = @"SELECT Quantity FROM ICSMaterialPick
// WHERE MOCode='{0}' AND MORow='{1}' AND SubInvCode='{2}' AND MoveType='退料' AND VoucherNO='{3}' ";
// oldTLSql = string.Format(oldTLSql, this.txtMO.EditValue.ToString(), this.txtMORow.Text, this.txtCode.Text, this.txtMoverCode.Text);
// }
// else
// {
// oldTLSql = @"SELECT Quantity FROM ICSMaterialPick
// WHERE MOCode='{0}' AND MORow='{1}' AND SubInvCode='{2}' AND MoveType='退料' ";
// oldTLSql = string.Format(oldTLSql, this.txtMO.EditValue.ToString(), this.txtMORow.Text, this.txtCode.Text);
// }
// //历史退料信息
// DataTable OldTLdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, oldTLSql).Tables[0];
// Decimal OldTLKeyQty = 0;
// if (OldTLdt != null && OldTLdt.Rows.Count > 0)
// {
// foreach (DataRow item in OldTLdt.Rows)
// {
// OldTLKeyQty += Decimal.Parse(item["Quantity"].ToString());
// }
// }
// Decimal KeyQty = 0;
// KeyQty = Decimal.Parse(this.txtiQuantity.Text);
// if (KeyQty + OldTLKeyQty > Qty)
// {
// //string msg = string.Empty;
// //msg = "历史退料单数量+当前维护退料单数量>历史领料单数量";
// ICSBaseSimpleCode.AppshowMessageBox("退料单数量不能大于领料单数量");
// return;
// }
#endregion
Decimal KeyQty = 0; KeyQty = Decimal.Parse(this.txtiQuantity.Text); if (KeyQty > Qty) { ICSBaseSimpleCode.AppshowMessageBox("退料单数量不能大于领料单数量"); return; } } #endregion
} catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); return; }
try { FormICSPickingModel Picking = new FormICSPickingModel(); Picking.ID = guid; Picking.VouchCode = txtPickingNO.Text.Trim(); //Picking.StorageID = txtStorageID.Text.Trim();
Picking.MUSER = AppConfig.UserId; Picking.MUSERName = AppConfig.UserName; Picking.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss"); Picking.WorkPoint = AppConfig.WorkPointCode; Picking.CreateTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss"); Picking.CreateUSER = AppConfig.UserName; Picking.IsMROItem = cboIsMROItem.Checked; Picking.IsPickingOrBack = 3; Picking.OutCategory = txtOutCategory.Text;
Picking.FormICSPickingDetail = new List<FormICSPickingDetailModel>(); if (string.IsNullOrWhiteSpace(txtirowno.Text)) { txtirowno.Text = ICSPickingBLL.GetPickingRowNo(guid, AppConfig.AppConnectString);//入库单行号
} FormICSPickingDetailModel PickingDetail = new FormICSPickingDetailModel(); bool detailIsID = false; if (txtDetailId.Text == "") { detailIsID = true; PickingDetail.ID = "0";//领料单明细ID
} else { PickingDetail.ID = txtDetailId.Text; //领料单ID
} PickingDetail.VoucherNO = txtMoverCode.EditValue.ToString();//批次号ZM
//PickingDetail.VoucherNO = txtMoverCode.Text.Trim();//批次号ZM
//20200407新增 关于MRO批号,要手写
if (!string.IsNullOrWhiteSpace(this.txtMROBatch.Text)) { PickingDetail.VoucherNO = txtMROBatch.Text.Trim();//MRO批号
}
PickingDetail.VouchCode = txtPickingNO.Text.Trim();//退料单号
string strtime = DateTime.Now.ToString("yyyyMMdd"); string sql = @"SELECT CONVERT(INT,RIGHT(MAX(A.VouchRow),4)) AS MAXLOT FROM ICSMaterialPick A WHERE A.VouchCode ='{0}'"; sql = string.Format(sql, PickingDetail.VouchCode);//取已存的transNo后四位
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0]; if (dt == null || dt.Rows.Count <= 0) { VRow = "0001"; } else if (dt.Rows[0][0] == null || dt.Rows[0][0].ToString() == "") { VRow = "0001"; } else { VRow = (Convert.ToInt32(dt.Rows[0][0]) + 1).ToString().PadLeft(4, '0');//自动生成transNo
} //PickingDetail.
PickingDetail.VouchRow = VRow; //入库单行号
PickingDetail.SubInvCode = txtCode.Text.Trim();//物料代码
PickingDetail.WHCode = txtWHCode.Text.Trim();//仓库
PickingDetail.MOCode = txtMO.EditValue.ToString();//工单号
//PickingDetail.MOCode = txtMOCode.Text.Trim();//工单号
PickingDetail.Dept = txtDept.EditValue.ToString(); if (!string.IsNullOrWhiteSpace(txtAllWeight.Text)) { PickingDetail.SupplyQuantity = Decimal.Parse(txtAllWeight.Text.Trim());//总单重
} else { PickingDetail.SupplyQuantity = 0; }
if (txtMO.EditValue == null) //if (txtMOCode.Text == "")
{ PickingDetail.MORow = ""; } else { PickingDetail.MORow = txtMORow.Text.Trim();//行号
} PickingDetail.Quantity = Convert.ToDecimal(txtiQuantity.Text.Trim());//应退数量
//PickingDetail.HasQuantity = Convert.ToDecimal(txtiQuantity.Text.Trim());//已退数量
PickingDetail.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");//领料时间
PickingDetail.DDNo = this.txtDDNo.Text.Trim(); PickingDetail.Remarks = this.txtRemarks.Text.Trim();
Picking.FormICSPickingDetail.Add(PickingDetail);
string id = ICSPickingBLL.AddAndEditDetail(Picking, AppConfig.AppConnectString); if (guid == "" && string.IsNullOrWhiteSpace(guid)) { guid = id; } if (string.IsNullOrWhiteSpace(txtDetailId.Text.Trim())) { txtDetailId.Text = ""; txtirowno.Text = ""; ICSBaseSimpleCode.AppshowMessageBox(0, "新增成功");
txtWHCode.Text = ""; txtOutCategory.Text = ""; this.cboIsMROItem.Checked = false;
} else { ICSBaseSimpleCode.AppshowMessageBox(0, "维护成功"); txtWHCode.Text = ""; txtCode.Text = ""; txtcInvName.Text = ""; txtcInvStd.Text = ""; txtINVUOM.Text = ""; txtiQuantity.Text = ""; txtMOCode.Text = ""; txtMORow.Text = ""; txtDetailId.Text = "0"; txtDDNo.Text = ""; txtRemarks.Text = "";
//20200407新增
txtMROBatch.Text = ""; } FormICSINVENTORYEditAdd_Load(null, null); } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); return; } }
private void btnDelDetail_Click(object sender, EventArgs e) { grdDetail.PostEditor(); this.Validate(); if (grdDetail.RowCount == 0) return; List<string> guidList = new List<string>(); List<string> codeList = new List<string>(); for (int i = 0; i < grdDetail.RowCount; i++) { if (grdDetail.GetRowCellValue(i, colisSelect).ToString() == "Y") { guidList.Add(grdDetail.GetRowCellValue(i, colID).ToString()); } }
if (guidList.Count == 0) { ICSBaseSimpleCode.AppshowMessageBox("请选择数据!"); return; }
#region 20190920ZM新增
string HasQuantityMsg = string.Empty; foreach (var item in guidList) { string VouchCode = string.Empty; string VouchRow = string.Empty;
string sql = @"SELECT VouchCode,VouchRow FROM ICSMaterialPick WHERE ID='" + item + "' AND HasQuantity>0"; sql = string.Format(sql); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { VouchCode = dt.Rows[0]["VouchCode"].ToString(); VouchRow = dt.Rows[0]["VouchRow"].ToString(); HasQuantityMsg += "单号:" + VouchCode + " 行号:" + VouchRow + " 已有退料不能删除该行!"; }
} if (!string.IsNullOrWhiteSpace(HasQuantityMsg)) { ICSBaseSimpleCode.AppshowMessageBox(HasQuantityMsg); return; } #endregion
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该领料信息吗?删除后无法恢复,确定吗?") != DialogResult.OK) return; try { ICSPickingBLL.deleteDetailInfo(guidList, AppConfig.AppConnectString); txtirowno.Text = ""; txtDetailId.Text = ""; ICSBaseSimpleCode.AppshowMessageBox(0, "删除成功"); FormICSINVENTORYEditAdd_Load(null, null); } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); } }
private void btnUpdateDetail_Click(object sender, EventArgs e) { int count = 0; for (int i = 0; i < grdDetail.RowCount; i++) { if (grdDetail.GetRowCellValue(i, colisSelect).ToString() == "Y") { count++; } } if (count != 1) { ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!"); return; } try { FormICSPickingModel Picking = new FormICSPickingModel(); //Picking.ID = guid;
Picking.VouchCode = txtPickingNO.Text.Trim(); //Picking.StorageID = txtStorageID.Text.Trim();
Picking.FormICSPickingDetail = new List<FormICSPickingDetailModel>();
FormICSPickingDetailModel PickingDetail = new FormICSPickingDetailModel(); //PickingDetail.DetailID = txtDetailId.Text.Trim();//领料单明细ID
//PickingDetail.PickingID = guid;//领料单ID
PickingDetail.VouchCode = txtPickingNO.Text.Trim();//退料单号
PickingDetail.SubInvCode = txtCode.Text.Trim();//物料代码
PickingDetail.WHCode = txtWHCode.Text.Trim();//仓库
if (txtMOCode.Text == "") { PickingDetail.MOCode = ""; PickingDetail.MORow = ""; } else { PickingDetail.MOCode = txtMOCode.Text.Trim();//工单号
PickingDetail.MORow = txtMORow.Text.Trim();//行号
} PickingDetail.Quantity = Convert.ToDecimal(txtiQuantity.Text.Trim());//应退数量
//PickingDetail.HasQuantity = Convert.ToDecimal(txtiQuantity.Text.Trim());//已退数量
//PickingDetail.CreateTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
//PickingDetail.CreateUSER = AppConfig.UserName;
Picking.FormICSPickingDetail.Add(PickingDetail);
string id = ICSPickingBLL.AddAndEditDetail(Picking, AppConfig.AppConnectString); if (guid == "" && string.IsNullOrWhiteSpace(guid)) { guid = Picking.VouchCode; } ICSBaseSimpleCode.AppshowMessageBox(0, "修改成功"); FormICSINVENTORYEditAdd_Load(null, null); } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); return; } }
private void grvDetail_DoubleClick(object sender, EventArgs e) { if (grdDetail.FocusedRowHandle < 0) { return; } for (int i = 0; i < grdDetail.RowCount; i++) { grdDetail.SetRowCellValue(i, colisSelect, ""); } if (grdDetail.FocusedColumn == colisSelect) { if (grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colisSelect).ToString() == "") { grdDetail.SetRowCellValue(grdDetail.FocusedRowHandle, colisSelect, "Y"); } else { grdDetail.SetRowCellValue(grdDetail.FocusedRowHandle, colisSelect, ""); } } string ID = ""; for (int i = 0; i < grdDetail.RowCount; i++) { if (grdDetail.GetRowCellValue(i, colisSelect).ToString() == "Y") { ID = grdDetail.GetRowCellValue(i, colID).ToString(); } } DataTable dt = ICSPickingBLL.GetDetailInfo(ID); foreach (DataRow dr in dt.Rows) {
txtPickingNO.Text = dr["VouchCode"].ToString().Trim(); txtMTIME.Text = dr["dDate"].ToString().Trim(); txtMUSERName.Text = dr["cMaker"].ToString().Trim(); txtWHCode.Text = dr["iWHCode"].ToString().Trim(); txtCode.Text = dr["cInvCode"].ToString().Trim(); txtcInvName.Text = dr["cInvName"].ToString().Trim(); txtcInvStd.Text = dr["cInvStd"].ToString().Trim(); txtINVUOM.Text = dr["cInvStd"].ToString().Trim(); txtiQuantity.Text = dr["iQuantity"].ToString().Trim(); txtINVUOM.Text = dr["INVUOM"].ToString().Trim(); txtMOCode.Text = dr["MOCode"].ToString().Trim(); txtMO.EditValue = dr["MOCode"].ToString().Trim(); txtMORow.Text = dr["MORow"].ToString().Trim(); txtDetailId.Text = dr["ID"].ToString().Trim(); txtRemarks.Text = dr["Remarks"].ToString().Trim(); txtMoverCode.Text = dr["VoucherNO"].ToString().Trim(); txtDDNo.Text = dr["DDNo"].ToString().Trim(); txtAllWeight.Text = dr["SupplyQuantity"].ToString().Trim();
//20200407新增 关于界面上是否MRO勾选,将零件号赋值在不同的栏位上面
if (cboIsMROItem.Checked == true) { txtMROBatch.Text = dr["VoucherNO"].ToString().Trim(); } } }
private void txtCode_EditValueChanged(object sender, EventArgs e) { try { string Code = txtCode.EditValue.ToString(); string sql = @"select INVCODE as 存货编码, INVNAME as 存货名称,INVSTD as 规格型号,INVGROUP AS 单重, INVUOM as 单位
from ICSINVENTORY WHERE INVCODE='{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) { txtcInvName.Text = dt.Rows[0]["存货名称"].ToString(); txtcInvStd.Text = dt.Rows[0]["规格型号"].ToString(); //txtcDepName.Text = dt.Rows[0]["生产部门"].ToString();
txtINVUOM.Text = dt.Rows[0]["单位"].ToString(); txtiQuantity.Text = ""; txtWeight.Text = dt.Rows[0]["单重"].ToString(); } } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.ToString()); } }
private void txtMORow_EditValueChanged_1(object sender, EventArgs e) { try { string Row = txtMORow.EditValue.ToString(); string sql = @"select MOCODE ,MOSEQ ,MOVER from ICSMO WHERE MOCODE='{0}' and MOSEQ='{1}'"; sql = string.Format(sql, txtMO.EditValue.ToString(), txtMORow.Text.Trim()); //sql = string.Format(sql, txtMOCode.Text.Trim(), txtMORow.Text.Trim());
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { //txtMoverCode.Text = dt.Rows[0]["MOVER"].ToString();
}
#region
#region by summer 2020-07-24
////20200413 关联领料单信息,没有领料的不需要显示
////old
////string sql1 = "SELECT MOCODE 工单号,SEQ 生产订单行号,MOBITEMCODE 存货编码 FROM ICSMOBOM WHERE MOCODE='{0}' and SEQ='{1}'";
////new
//string sql1 = "SELECT a.MOBITEMCODE 存货编码 , INVNAME as 存货名称,INVSTD as 规格型号 FROM ICSMOBOM a " +
// " INNER JOIN ICSMOPickLog c ON c.MOCODE=a.MOCODE AND C.MOSEQ = A.SEQ " + //AND b.MoveType='领料'
// " INNER JOIN ICSINVENTORY d ON d.INVCODE=a.MOBITEMCODE " +
// " WHERE a.MOCODE='{0}' and a.SEQ='{1}'";
#endregion
#region by summer 2020-07-24
//20200413 关联领料单信息,没有领料的不需要显示
//old
//string sql1 = "SELECT MOCODE 工单号,SEQ 生产订单行号,MOBITEMCODE 存货编码 FROM ICSMOBOM WHERE MOCODE='{0}' and SEQ='{1}'";
//new
string sql1 = @"
SELECT A.MOBITEMCODE AS 存货编码, D.INVNAME AS 存货名称,INVSTD AS 规格型号, A.MOCODE, A.SEQ FROM ICSMOBOM A INNER JOIN ICSMOPickLog C ON C.MOCODE = A.MOCODE AND C.MOSEQ = A.SEQ AND A.MOBOMLINE = C.SEQ INNER JOIN ICSINVENTORY D ON D.INVCODE = A.MOBITEMCODE WHERE A.MOCODE = '{0}' AND A.SEQ = '{1}'";
#endregion
sql1 = string.Format(sql1, txtMO.EditValue.ToString(), txtMORow.Text.Trim()); DataTable dt1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql1).Tables[0]; txtCode.Properties.ValueMember = "存货编码"; txtCode.Properties.DisplayMember = "存货编码"; txtCode.Properties.DataSource = dt1; 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
//string sqlYTMoverCode = @"SELECT DISTINCT A.VenderLotNO as [零件号] FROM ICSITEMLot A where A.TransNO='{0}'";
//sqlYTMoverCode = string.Format(sqlYTMoverCode, txtMOCode.Text.Trim());
//20200407
string sqlYTMoverCode = @"SELECT DISTINCT b.VenderLotNO as [零件号]
from ICSWareHouseLotInfoLog a left JOIN ICSITEMLot b on b.lotno=a.LotNO where a.TransNO='{0}' and a.TransLine='{1}'";
sqlYTMoverCode = string.Format(sqlYTMoverCode, txtMO.EditValue.ToString(), txtMORow.Text); DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0]; txtMoverCode.Properties.ValueMember = "零件号"; txtMoverCode.Properties.DisplayMember = "零件号"; txtMoverCode.Properties.DataSource = _dt; txtMoverCode.Properties.NullText = "";//空时的值
txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
if (_dt != null && _dt.Rows.Count > 0) { txtMoverCode.Text = _dt.Rows[0][0].ToString(); }
} catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.ToString()); } }
private void txtcInvName_EditValueChanged(object sender, EventArgs e) {
}
/// <summary>
/// 是否MRO物料选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cboIsMROItem_CheckedChanged(object sender, EventArgs e) { //cboIsMROItem
if (this.cboIsMROItem.Checked == true) { //this.txtMOCode.Properties.ReadOnly = true;
//this.txtMORow.Properties.ReadOnly = true;
//this.txtOutCategory.Properties.ReadOnly = false;
this.txtOutCategory.Properties.ReadOnly = false; this.txtMOCode.Properties.ReadOnly = true; this.txtMOCode.Enabled = false; this.txtMORow.Properties.ReadOnly = true;
//20200407新增
this.txtMROBatch.Enabled = true; this.txtMROBatch.Properties.ReadOnly = false; this.txtMoverCode.Properties.ReadOnly = true; this.txtMoverCode.Enabled = false;
//20200608 summer 新增
txtMO.Enabled = false; } else { this.txtOutCategory.Properties.ReadOnly = true; this.txtMOCode.Properties.ReadOnly = false; this.txtMOCode.Enabled = true; this.txtMORow.Properties.ReadOnly = false;
//20200407新增
this.txtMROBatch.Enabled = false; this.txtMROBatch.Properties.ReadOnly = true; this.txtMoverCode.Properties.ReadOnly = false; this.txtMoverCode.Enabled = true;
//20200608 summer 新增
txtMO.Enabled = true; } }
private void txtMO_EditValueChanged(object sender, EventArgs e) { string MOCODE = txtMO.EditValue.ToString(); //string sql = "SELECT DISTINCT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE='{0}' ORDER BY MOSEQ";
string sql = "SELECT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE = '{0}' ORDER BY CAST (MOSEQ AS INT)";
sql = string.Format(sql, MOCODE); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; txtMORow.Properties.ValueMember = "行号"; txtMORow.Properties.DisplayMember = "行号"; txtMORow.Properties.DataSource = dt; txtMORow.Properties.NullText = "";//空时的值
txtMORow.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtMORow.Properties.ValidateOnEnterKey = true;//回车确认
txtMORow.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtMORow.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtMORow.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; txtMORow.EditValue = ""; txtMoverCode.Text = ""; if (MOCODE == "") { //txtMoverCode.Properties.ReadOnly = false;
} else { //txtMoverCode.Properties.ReadOnly = true;
} //DataTable dt_temp = (DataTable)glue.Properties.DataSource;
//if (dt_temp.Rows.Count > 0)
if (dt.Rows.Count > 0) { //默认选择第一项
txtMORow.EditValue = dt.Rows[0][0].ToString().Trim(); }
initMoverCode(txtMO.EditValue.ToString());
}
//private void txtMoverCode_EditValueChanged(object sender, EventArgs e)
//{
// string MOCODE = txtMOCode.EditValue.ToString();
// string MORow = this.txtMORow.EditValue.ToString();
// //string sqlYTMoverCode = @"SELECT DISTINCT A.VenderLotNO as [零件号] FROM ICSITEMLot A where a.TransNO='{0}' and a.TransLine='{1}'";
// string sqlYTMoverCode = @"SELECT DISTINCT A.VenderLotNO as [零件号] FROM ICSITEMLot A ";
// sqlYTMoverCode = string.Format(sqlYTMoverCode, MOCODE, MORow);
// DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0];
// txtMoverCode.Properties.ValueMember = "零件号";
// txtMoverCode.Properties.DisplayMember = "零件号";
// txtMoverCode.Properties.DataSource = _dt;
// txtMoverCode.Properties.NullText = "";//空时的值
// txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
// txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
// txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
// txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
// //自适应宽度
// txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
// txtMoverCode.EditValue = "";
// this.txtMOCode.Text = "";
// if (txtMOCode.Text == "")
// {
// }
// if (_dt.Rows.Count > 0)
// {
// //默认选择第一项
// txtMoverCode.EditValue = _dt.Rows[0][0].ToString().Trim();
// }
//}
//private void txtMoverCode_EditValueChanged(object sender, EventArgs e)
//{
// //string MOCODE = txtMOCode.EditValue.ToString();
// //string sql = "SELECT DISTINCT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE='{0}' ORDER BY MOSEQ";
// //string MOCODE = txtMOCode.EditValue.ToString();
// string sqlYTMoverCode = @"SELECT DISTINCT A.VenderLotNO as [零件号] FROM ICSITEMLot A ";
// sqlYTMoverCode = string.Format(sqlYTMoverCode);
// DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0];
// txtMoverCode.Properties.ValueMember = "零件号";
// txtMoverCode.Properties.DisplayMember = "零件号";
// txtMoverCode.Properties.DataSource = _dt;
// txtMoverCode.Properties.NullText = "";//空时的值
// txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
// txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
// txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
// txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
// //自适应宽度
// txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
// txtMoverCode.EditValue = "";
// this.txtMOCode.Text = "";
// if (txtMOCode.Text == "")
// {
// }
// if (_dt.Rows.Count > 0)
// {
// //默认选择第一项
// txtMoverCode.EditValue = _dt.Rows[0][0].ToString().Trim();
// }
//}
} }
|