|
|
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 FormICSMROPickingEditAdd : DevExpress.XtraEditors.XtraForm { private DataTable data; //DataTable body;
string VRow = ""; String guid = ""; FormICSPickingModel entity = new FormICSPickingModel(); public string Sys = "";
#region 构造函数
public FormICSMROPickingEditAdd() { InitializeComponent(); } public FormICSMROPickingEditAdd(String id) { InitializeComponent(); guid = id; } #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() == "" )
//{
// ICSBaseSimpleCode.AppshowMessageBox("请添加一行内容!");
// return;
//}
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 = 1; entity.PickingSTATUS = "新建"; 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) { Sys = GetSys(); if (Sys == "") { ICSBaseSimpleCode.AppshowMessageBox("连接数据库不正确!"); return; } if (guid != "") { lblTitle.Text = "MRO领料单维护"; txtPickingNO.Properties.ReadOnly = true; txtWHCode.Properties.ReadOnly = true;
entity = ICSPickingBLL.SearchInfoByID(guid, AppConfig.AppConnectString); txtPickingNO.Text = entity.VouchCode; txtWHCode.Text = entity.WHCode; //20190705ZM
txtDept.Text = entity.Dept; txtCREWCODE.Text = entity.VENDORCODE; this.txtOutCategory.Text = entity.OutCategory; this.txtMEMO.Text = entity.MEMO; //txtRDCode.Text = entity.RDCode;
txtMUSERName.Text = AppConfig.UserName; txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
DataTable body = ICSPickingBLL.GetDetailList(entity.VouchCode); grvDetail.DataSource = body; grdDetail.BestFitColumns(); } else { lblTitle.Text = "MRO领料单修改"; txtPickingNO.Properties.ReadOnly = true; txtDept.Text = entity.Dept; this.txtOutCategory.Text = entity.OutCategory; txtPickingNO.Text = ICSPickingBLL.GetOutInNo(AppConfig.AppConnectString); txtMUSERName.Text = AppConfig.UserName; txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } 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 AND cRdCode != '20201' 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 cDepCode AS [部门编号],cDepName AS [部门名称] FROM ICSDepartment WHERE WorkPoint = '{0}' AND bDepEnd = 1 ORDER BY cDepCode"; sql3 = string.Format(sql3, AppConfig.WorkPointCode); DataTable dt3 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0]; txtDept.Properties.ValueMember = "部门编号"; txtDept.Properties.DisplayMember = "部门编号"; txtDept.Properties.DataSource = dt3; 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
#region 班组
string sql4 = ""; if (Sys == "ICSMES_YTSys") { if (this.txtOutCategory.Text == "20301" && this.txtDept.Text == "0401") { sql4 = @"SELECT CREWCODE 班组编码, CREWDESC 班组名称 FROM ICSCREW
WHERE 1=1 AND WorkPoint = '{0}' AND ISNULL(EATTRIBUTE3, '') = '' AND ISNULL(EATTRIBUTE1, '') = '01' ORDER BY CREWCODE ";
} else if (this.txtOutCategory.Text == "20301" && this.txtDept.Text == "0301") { sql4 = @"SELECT CREWCODE 班组编码, CREWDESC 班组名称 FROM ICSCREW
WHERE 1=1 AND WorkPoint = '{0}' AND ISNULL(EATTRIBUTE3, '') = '' AND ISNULL(EATTRIBUTE1, '') = '02' ORDER BY CREWCODE ";
} else { sql4 = "SELECT CREWCODE 班组编码, CREWDESC 班组名称 FROM ICSCREW WHERE 1=1 AND WorkPoint = '{0}' AND ISNULL(EATTRIBUTE3, '') = '' ORDER BY CREWCODE "; } } else { if (this.txtOutCategory.Text == "20302" && this.txtDept.Text == "0301") { sql4 = @"SELECT CREWCODE 班组编码, CREWDESC 班组名称 FROM ICSCREW
WHERE 1=1 AND WorkPoint = '{0}' AND ISNULL(EATTRIBUTE3, '') = '03' AND ISNULL(EATTRIBUTE1, '') = '03' ORDER BY CREWCODE ";
} else { sql4 = "SELECT CREWCODE 班组编码, CREWDESC 班组名称 FROM ICSCREW WHERE 1=1 AND WorkPoint = '{0}' AND ISNULL(EATTRIBUTE3, '') = '03' ORDER BY CREWCODE "; } } sql4 = string.Format(sql4, AppConfig.WorkPointCode); DataTable dt4 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql4).Tables[0]; txtCREWCODE.Properties.ValueMember = "班组名称"; txtCREWCODE.Properties.DisplayMember = "班组名称"; txtCREWCODE.Properties.DataSource = dt4; txtCREWCODE.Properties.NullText = "";//空时的值
txtCREWCODE.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtCREWCODE.Properties.ValidateOnEnterKey = true;//回车确认
txtCREWCODE.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtCREWCODE.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtCREWCODE.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion
} #endregion
#region 工单号
private void txtMOCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) {
string sql = @" SELECT DISTINCT MOCODE 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();
//}
} #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";
//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
private void btnSaveDetail_Click_bak(object sender, EventArgs e) { //1. 填写出库类别,部门,存货编码,数量三项为必输项,备注为不必输;
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.txtOutCategory.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("出库类别不能为空"); return; } if (this.txtDept.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("部门不能为空!"); return; } try { string sqlQ = @"SELECT '' AS ID,'' VouchCode,'' UserId,'' MUSERName,'' MTIME,'' WorkPoint,'' AS CreateTIME,'' AS CreateUSER,'' AS MEMO, '' AS IsPickingOrBack, '' AS OutCategory "; sqlQ = string.Format(sqlQ, AppConfig.WorkPointCode); data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlQ).Tables[0]; DataRow dr = data.NewRow(); dr["ID"] = new Guid().ToString(); dr["VouchCode"] = txtPickingNO.Text.Trim(); dr["UserId"] = AppConfig.UserId; dr["MUSERName"] = AppConfig.UserName; dr["MTIME"] = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss"); dr["WorkPoint"] = AppConfig.WorkPointCode; dr["CreateTIME"] = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss"); dr["CreateUSER"] = AppConfig.UserName; dr["MEMO"] = txtMEMO.Text.Trim(); dr["IsPickingOrBack"] = 1; //1--领料;3-退料
dr["OutCategory"] = this.txtOutCategory.Text; data.Rows.Add(dr); this.grvDetail.DataSource = data; #region
//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.MEMO = txtMEMO.Text.Trim();
//Picking.IsPickingOrBack = 1; //1--领料;3-退料
//Picking.OutCategory = this.txtOutCategory.Text;
//Picking.FormICSPickingDetail = new List<FormICSPickingDetailModel>();
#endregion
if (string.IsNullOrWhiteSpace(txtirowno.Text)) { txtirowno.Text = ICSPickingBLL.GetPickingRowNo(guid, AppConfig.AppConnectString);//入库单行号
} #region
//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.Text.Trim();//苏船工号
//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.VouchRow = VRow; //入库单行号
//PickingDetail.SubInvCode = txtCode.Text.Trim();//物料代码
//PickingDetail.WHCode = txtWHCode.Text.Trim();//仓库
//PickingDetail.Quantity = Convert.ToDecimal(txtiQuantity.Text.Trim());//应退数量
//PickingDetail.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");//领料时间
//PickingDetail.OutCategory = this.txtOutCategory.Text.Trim();
//PickingDetail.Dept = this.txtDept.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, "新增成功");
//}
//else
//{
// ICSBaseSimpleCode.AppshowMessageBox(0, "维护成功");
// txtWHCode.Text = "";
// txtCode.Text = "";
// txtcInvName.Text = "";
// txtcInvStd.Text = "";
// txtINVUOM.Text = "";
// txtiQuantity.Text = "";
// //txtMOCode.Text = "";
// //txtMORow.Text = "";
// txtDetailId.Text = "0";
// txtDept.Text = "";
// txtOutCategory.Text = "";
//}
//FormICSINVENTORYEditAdd_Load(null, null);
#endregion
} catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); return; } }
private void btnSaveDetail_Click(object sender, EventArgs e) { //20190910新增一个单据只能保存一个出库类别,在表行中新增仓库、出库类别、部门
string sqlOutCategory = @" SELECT DISTINCT
j.OutCategory FROM ICSMaterialPick a LEFT JOIN ICSMaterial j ON a.VouchCode = j.VouchCode WHERE a.VouchCode = '{0}' AND a.WorkPoint = '" + AppConfig.WorkPointCode + "' ";
sqlOutCategory = string.Format(sqlOutCategory, this.txtPickingNO.Text); DataTable dtOutCategory = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlOutCategory).Tables[0]; if (dtOutCategory != null && dtOutCategory.Rows.Count > 0) { string _OutCategory = dtOutCategory.Rows[0][0].ToString(); if (_OutCategory != this.txtOutCategory.Text) { ICSBaseSimpleCode.AppshowMessageBox("一张MRO领料单不能出现两个出库类别!"); return; } } //1. 填写出库类别,部门,存货编码,数量三项为必输项,备注为不必输;
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.txtOutCategory.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("出库类别不能为空"); return; } if (Sys == "ICSMES_YTSys") { if (this.txtOutCategory.Text == "20303" || this.txtOutCategory.Text == "20306") { if (txtMEMO.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("亚太账套,出库类别为20303或20306时,备注不能为空"); return; } } } if (this.txtOutCategory.Text == "20202" && txtRDCode.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("出库类别为20202时, RD号不能为空!"); return; } if (this.txtDept.Text == "") { ICSBaseSimpleCode.AppshowMessageBox("部门不能为空!"); 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.MEMO = txtMEMO.Text.Trim(); Picking.IsPickingOrBack = 1; //1--领料;3-退料
Picking.OutCategory = this.txtOutCategory.Text; Picking.VENDORCODE = txtCREWCODE.Text.Trim(); 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.Text.Trim();//苏船工号
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.VouchRow = VRow; //入库单行号
PickingDetail.SubInvCode = txtCode.Text.Trim();//物料代码
PickingDetail.WHCode = txtWHCode.Text.Trim();//仓库
#region
//PickingDetail.MOCode = txtMOCode.Text.Trim();//工单号
// if (txtMOCode.Text == "")
// {
// PickingDetail.MORow = "";
// }
// else
//{
// PickingDetail.MORow = txtMORow.Text.Trim();//行号
// }
#endregion
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.OutCategory = this.txtOutCategory.Text.Trim(); if (this.txtOutCategory.Text == "20202") { PickingDetail.RDCode = txtRDCode.Text.Trim(); } PickingDetail.Dept = this.txtDept.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, "新增成功"); } else { ICSBaseSimpleCode.AppshowMessageBox(0, "维护成功"); txtWHCode.Text = ""; txtCode.Text = ""; txtcInvName.Text = ""; txtcInvStd.Text = ""; txtINVUOM.Text = ""; txtiQuantity.Text = ""; //txtMOCode.Text = "";
//txtMORow.Text = "";
txtDetailId.Text = "0"; txtDept.Text = ""; txtOutCategory.Text = ""; txtRDCode.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; }
try {
#region 20190920ZM新增有领过料就不能删除单据行不能删除 ICSMaterialPick
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;
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();
//txtMORow.Text = dr["MORow"].ToString().Trim();
txtDetailId.Text = dr["ID"].ToString().Trim(); txtRDCode.Text = dr["RDCode"].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 规格型号,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 = ""; } } 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, 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
//string sql1 = "SELECT MOCODE 工单号,SEQ 生产订单行号,MOBITEMCODE 存货编码 FROM ICSMOBOM WHERE MOCODE='{0}' and SEQ='{1}'";
string sql1 = "SELECT MOCODE 工单号,SEQ 生产订单行号,MOBITEMCODE 存货编码 FROM ICSMOBOM WHERE MOCODE='{0}' and SEQ='{1}'";
//sql1 = string.Format(sql1,txtMOCode.Text.Trim(),txtMORow.Text.Trim());
sql1 = string.Format(sql1);
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
} catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.ToString()); } }
private void txtOutCategory_EditValueChanged(object sender, EventArgs e) { if (txtOutCategory.Text.ToString() == "20202") { txtRDCode.Properties.ReadOnly = false; } else { txtRDCode.Properties.ReadOnly = true; } }
public string GetSys() { string sql = @"SELECT DBName FROM Sys_DataBase WHERE 1=1 AND DBSourceName = 'SYS' AND WorkCode = '{0}' "; sql = string.Format(sql, AppConfig.WorkPointCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { return dt.Rows[0]["DBName"].ToString(); } else { return ""; } } } }
|