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.
486 lines
19 KiB
486 lines
19 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;
|
|
using System.Drawing.Printing;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSITEMBox : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
private string sqltxt = "";
|
|
private string sqlconn = "";
|
|
String guid = AppConfig.GetGuid();
|
|
private DataTable dataSource = null;
|
|
private DataTable data = null;
|
|
|
|
private string MoId = "";
|
|
private string MoCode = "";
|
|
private decimal Qty = 0.00m;
|
|
|
|
private string boxNo = "";
|
|
|
|
private static PrintDocument fPrintDocument = new PrintDocument();
|
|
|
|
#region 构造函数
|
|
public FormICSITEMBox()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
|
|
}
|
|
public FormICSITEMBox(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(btnCreate);
|
|
ControlList.Add(simpleButton4);
|
|
ControlList.Add(btnModify);
|
|
ControlList.Add(btnDel);
|
|
|
|
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
|
|
|
|
|
|
//加载
|
|
private void FormICSITEMBox_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void print(string packno)
|
|
{
|
|
if (string.IsNullOrEmpty(packno)) return;
|
|
|
|
List<string> printlist = GetLocalPrinters();
|
|
string print = "";
|
|
if (printlist == null || printlist.Count == 0)
|
|
{ ICSBaseSimpleCode.AppshowMessageBox("系统中不存在打印机,请检查!"); return; }
|
|
foreach (string str in printlist)
|
|
{ if (str.Contains("GP-1124T")) { print = str; } }
|
|
if (print == null || print == "")
|
|
{ ICSBaseSimpleCode.AppshowMessageBox("默认打印机不存在,请检查!"); return; }
|
|
|
|
List<PrintPara> parasList = new List<PrintPara>();
|
|
PrintPara para = new PrintPara();
|
|
para.PrintKey = "PackNo";
|
|
para.PrintValues = new object[] { packno };
|
|
parasList.Add(para);
|
|
string ID = "f9ce8ba9-4356-457c-8bda-479cbdf02552";
|
|
ICSSoft.Base.Lable.PrintTool.PrintReport prpt = new ICSSoft.Base.Lable.PrintTool.PrintReport(ID, print, true, false, "ICSBarCode", 1, "", "本地打印", parasList);
|
|
Thread.Sleep(1000);
|
|
}
|
|
|
|
#region 获取系统中打印机名称
|
|
//获取本机默认打印机名称
|
|
public static String DefaultPrinter()
|
|
{
|
|
return fPrintDocument.PrinterSettings.PrinterName;
|
|
}
|
|
public static List<String> GetLocalPrinters()
|
|
{
|
|
List<String> fPrinters = new List<String>();
|
|
fPrinters.Add(DefaultPrinter()); //默认打印机始终出现在列表的第一项
|
|
foreach (String fPrinterName in PrinterSettings.InstalledPrinters)
|
|
{
|
|
if (!fPrinters.Contains(fPrinterName))
|
|
{
|
|
fPrinters.Add(fPrinterName);
|
|
}
|
|
}
|
|
return fPrinters;
|
|
}
|
|
#endregion
|
|
|
|
private void txtLOTNO_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (e.KeyChar == 13)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(txtLOTNO.Text.Trim()))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("成品条码不能为空");
|
|
return;
|
|
}
|
|
if (txtLOTNO.Text.Trim().ToUpper().Equals("END"))
|
|
{
|
|
#region 结束字符自动拼箱、打印处理
|
|
btnCreate_Click(null, null);
|
|
grdDetail.DataSource = null;
|
|
|
|
print(boxNo);
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
string sql = @"SELECT
|
|
a.LotNO,
|
|
d.CUSCODE,
|
|
d.CUSORDERNO,
|
|
d.CUSITEMCODE,
|
|
a.INVCode,
|
|
e.INVNAME,
|
|
e.INVUOM,
|
|
e.INVSTD,
|
|
a.LotQty
|
|
FROM
|
|
ICSWareHouseLotInfo a
|
|
LEFT JOIN ICSITEMLot b ON a.LotNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN ICSINVReceiptDetail c ON b.TransNO=c.ReceiptNO AND b.TransLine=c.ReceiptLine AND b.WorkPoint=c.WorkPoint
|
|
LEFT JOIN ICSMO d ON c.MOCODE=d.MOCODE AND c.MOSEQ=d.MOSEQ AND c.WorkPoint=d.WorkPoint
|
|
LEFT JOIN ICSINVENTORY e ON a.INVCode=e.INVCODE AND a.WorkPoint=e.WorkPoint
|
|
WHERE a.LotQty<>0 AND a.LotNO='{0}' AND a.WorkPoint='{1}'";
|
|
sql = string.Format(sql, txtLOTNO.Text.Trim(), AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if (dt == null || dt.Rows.Count <= 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("该产品批号未入库!");
|
|
return;
|
|
}
|
|
if (dataSource == null)
|
|
{
|
|
dataSource = dt;
|
|
}
|
|
else
|
|
{
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
DataRow[] drs = dataSource.Select("LotNO='" + dr["LotNO"] + "'");
|
|
if (drs.Count() > 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("该产品批号已存在!");
|
|
break;
|
|
}
|
|
if (dataSource.Rows.Count > 0 && !dataSource.Rows[0]["CUSCODE"].ToString().Equals(dr["CUSCODE"].ToString()))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("不同的客户不能拼箱!");
|
|
break;
|
|
}
|
|
dataSource.ImportRow(dr);
|
|
}
|
|
}
|
|
grdDetail.DataSource = dataSource;
|
|
grvDetail.BestFitColumns();
|
|
}
|
|
txtLOTNO.Text = "";
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
|
|
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 (dataSource == null || dataSource.Rows.Count <= 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请扫描产品条码后再做拼箱操作!");
|
|
return;
|
|
}
|
|
//if (data == null)
|
|
//{
|
|
data = new DataTable();
|
|
data.Columns.Add("LotNO");
|
|
data.Columns.Add("CUSORDERNO");
|
|
data.Columns.Add("CUSITEMCODE");
|
|
data.Columns.Add("INVSTD");
|
|
data.Columns.Add("LotQty");
|
|
//}
|
|
boxNo = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss.fff").ToString("yyyyMMddHHmmssfff");
|
|
List<FormICSITEMBoxUIModel> itemBoxList = new List<FormICSITEMBoxUIModel>();
|
|
FormICSITEMBoxUIModel itemBox=null;
|
|
|
|
DataRow lastRow=null;
|
|
DataView dv = dataSource.DefaultView;
|
|
dv.Sort = "CUSORDERNO,CUSITEMCODE";
|
|
dataSource = dv.ToTable();
|
|
foreach (DataRow dr in dataSource.Rows)
|
|
{
|
|
ICSITEMBoxDetail detail = new ICSITEMBoxDetail();
|
|
detail.ID = "";
|
|
detail.LOTNO = dr["LotNO"].ToString();
|
|
detail.QTY =Convert.ToDecimal(dr["LotQty"].ToString());
|
|
bool isNew = false; //是否是新行
|
|
if (lastRow != null && lastRow["INVStd"].ToString().Equals(dr["INVStd"].ToString()))
|
|
{
|
|
int index = data.Rows.Count;
|
|
data.Rows[index - 1]["LotQty"] = Convert.ToDecimal(data.Rows[index - 1]["LotQty"]) + Convert.ToDecimal(dr["LotQty"]);
|
|
//data.Rows[index - 1]["LotNO"] = data.Rows[index - 1]["CUSORDERNO"].ToString() + data.Rows[index - 1]["CUSITEMCODE"].ToString() + Convert.ToInt32(data.Rows[index - 1]["LotQty"].ToString());
|
|
|
|
}
|
|
else
|
|
{
|
|
data.ImportRow(dr);
|
|
int index = data.Rows.Count;
|
|
//data.Rows[index - 1]["LotNO"] = data.Rows[index - 1]["CUSORDERNO"].ToString() + data.Rows[index - 1]["CUSITEMCODE"].ToString() + Convert.ToInt32(data.Rows[index - 1]["LotQty"].ToString());
|
|
|
|
itemBox = new FormICSITEMBoxUIModel();
|
|
isNew = true;
|
|
}
|
|
|
|
lastRow = dr;
|
|
|
|
int count = data.Rows.Count;
|
|
detail.NO = data.Rows[count - 1]["LotNO"].ToString();
|
|
itemBox.ITEMBoxDetail.Add(detail);
|
|
|
|
itemBox.ID = "";
|
|
itemBox.BoxNO = boxNo;
|
|
//itemBox.NO = data.Rows[count - 1]["LotNO"].ToString();
|
|
//itemBox.CUSORDERNO = data.Rows[count - 1]["CUSORDERNO"].ToString();
|
|
//itemBox.CUSITEMCODE = data.Rows[count - 1]["CUSITEMCODE"].ToString();
|
|
itemBox.INVStd = data.Rows[count - 1]["INVStd"].ToString();
|
|
itemBox.QTY = Convert.ToDecimal(data.Rows[count - 1]["LotQty"].ToString());
|
|
if (isNew)
|
|
itemBoxList.Add(itemBox);
|
|
else
|
|
{
|
|
itemBoxList.RemoveAt(itemBoxList.Count - 1);
|
|
itemBoxList.Add(itemBox);
|
|
}
|
|
}
|
|
ICSITEMBoxBLL.Add(itemBoxList, AppConfig.AppConnectString);
|
|
gridControlGroup.DataSource = data;
|
|
gridViewGroup.BestFitColumns();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
|
|
private void btnModify_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
|
|
int index = grvDetail.FocusedRowHandle;
|
|
if (index < 0)
|
|
return;
|
|
dataSource.Rows.RemoveAt(index);
|
|
grdDetail.DataSource = dataSource;
|
|
grvDetail.BestFitColumns();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
|
|
private void btnDel_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
|
|
dataSource = null;
|
|
data = null;
|
|
grdDetail.DataSource = null;
|
|
gridControlGroup.DataSource = null;
|
|
boxNo = "";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
|
|
#region 打印
|
|
private void simpleButton4_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 (string .IsNullOrWhiteSpace(boxNo))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("拼箱后才能打印!");
|
|
return;
|
|
}
|
|
|
|
List<PrintPara> parasList = new List<PrintPara>();
|
|
PrintPara para = new PrintPara();
|
|
para.PrintKey = "LOTNO";
|
|
para.PrintValues = new object[] { boxNo };
|
|
parasList.Add(para);
|
|
|
|
if (parasList.Count == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
|
|
return;
|
|
}
|
|
FormPrintDialog f = new FormPrintDialog("013", this.Text, parasList, false, null);
|
|
f.ShowDialog();
|
|
////更新打印信息
|
|
//ICSRdrecord2LOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|