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.
835 lines
32 KiB
835 lines
32 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.Lable.PrintTool;
|
|
using System.Linq;
|
|
using System.Data.Linq;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Frame.APP;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormStockBarCode : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
|
|
#region private参数
|
|
|
|
private string sqltxt = "";
|
|
private string sqlconn = "";
|
|
private DataTable dataSource = null;
|
|
#endregion
|
|
|
|
#region 构造函数
|
|
|
|
public FormStockBarCode()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
//grvDetail.OptionsView.ShowIndicator = false;
|
|
//grvDetail.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.None;
|
|
//grvDetail.OptionsSelection.EnableAppearanceFocusedCell = false;
|
|
//grvDetail.OptionsSelection.EnableAppearanceFocusedRow = false;
|
|
//grvDetail.OptionsSelection.EnableAppearanceHideSelection = false;
|
|
}
|
|
|
|
private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
e.Info.ImageIndex = -1;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region SystemOptition
|
|
|
|
/// <summary>
|
|
/// 操作权限
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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(btnDel);
|
|
ControlList.Add(btnExport);
|
|
ControlList.Add(btnPrintOne);
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// 数据权限
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable RightOfData()
|
|
{
|
|
DataTable rData = new DataTable();
|
|
rData.Columns.Add("BodyName");
|
|
rData.Columns.Add("ControlName");
|
|
rData.Columns.Add("ControlCaption");
|
|
|
|
rData.AcceptChanges();
|
|
return rData;
|
|
}
|
|
|
|
#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
|
|
|
|
protected override void OnCreateControl()
|
|
{
|
|
base.OnCreateControl();
|
|
}
|
|
private void btnExport_Click(object sender, EventArgs e)
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
|
|
foe.ShowDialog();
|
|
}
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
private string tempTableName = "";
|
|
private void btnFilter_Click(object sender, EventArgs e)
|
|
{
|
|
FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnDataConfig.Name));
|
|
filter.OldTempTableName = tempTableName;
|
|
if (filter.ShowDialog() == DialogResult.OK)
|
|
{
|
|
try
|
|
{
|
|
tempTableName = filter.NewTempTableName;
|
|
sqltxt = filter.SqlText;
|
|
sqlconn = filter.FilterConnectString;
|
|
dataSource = filter.FilterData.Tables[0];
|
|
grdDetail.DataSource = dataSource;
|
|
grvDetail.BestFitColumns();
|
|
rptPage.RecordNum = dataSource.Rows.Count;
|
|
rptPage.PageSize = 499;
|
|
rptPage.PageIndex = 1;
|
|
rptPage.ReLoad();
|
|
rptPage.PageSize = 500;
|
|
rptPage.PageIndex = 1;
|
|
rptPage.ReLoad();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(1, ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void btnflash_Click(object sender, EventArgs e)
|
|
{
|
|
if (sqlconn == null || sqlconn == "")
|
|
{
|
|
return;
|
|
}
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在刷新数据...请稍等...");
|
|
try
|
|
{
|
|
_wait.Show();
|
|
FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnDataConfig.Name), false);
|
|
dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
|
|
grdDetail.DataSource = dataSource;
|
|
grvDetail.BestFitColumns();
|
|
rptPage.RecordNum = dataSource.Rows.Count;
|
|
rptPage.PageIndex = 1;
|
|
rptPage.ReLoad();
|
|
_wait.Close();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox(1, ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
private void btnDataConfig_Click(object sender, EventArgs e)
|
|
{
|
|
if (AppConfig.UserCode.ToLower() != "demo")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
|
|
return;
|
|
}
|
|
FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnDataConfig.Name);
|
|
fdata.ShowDialog();
|
|
}
|
|
|
|
#region selectAll And selectCancle
|
|
|
|
private void btnSelectAll_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
grvDetail.SetRowCellValue(i, colSelect, "Y");
|
|
}
|
|
}
|
|
|
|
private void btncancleAll_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
grvDetail.SetRowCellValue(i, colSelect, "");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region delete
|
|
|
|
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;
|
|
}
|
|
grvDetail.PostEditor();
|
|
this.Validate();
|
|
List<string> guidList = new List<string>();
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
|
|
{
|
|
string barCode = grvDetail.GetRowCellValue(i, LotNO).ToString();
|
|
guidList.Add(barCode);
|
|
}
|
|
}
|
|
if (guidList.Count == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
|
|
return;
|
|
}
|
|
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定要删除选择的数据吗?") != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
List<string> failDel = new List<string>();
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在删除箱号条码...请稍候...");
|
|
try
|
|
{
|
|
_wait.Show();
|
|
ICSStockBarCodeBLL.delete(guidList, AppConfig.AppConnectString.ToString());
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("删除成功");
|
|
btnflash_Click(null, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_wait.Close();
|
|
Application.DoEvents();
|
|
ICSBaseSimpleCode.AppshowMessageBox(1, ex.Message);
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region print
|
|
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
string batch = "";
|
|
string sql = @"SELECT BatchCode AS 批次,ItemCode AS 存货编码,ItemName AS 存货名称,
|
|
ItemStd AS 规格型号,PackedQuantity AS 数量,cComUnitCode AS 计量单位
|
|
,IsPrint as 是否打印
|
|
FROM dbo.ICSItemLot WHERE BatchCode IN (SELECT DISTINCT BatchCode FROM dbo.ICSCarton)
|
|
";
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
FormDataRefer reForm = new FormDataRefer();
|
|
reForm.FormTitle = "打印批次列表";
|
|
DataTable menuData = data;
|
|
reForm.DataSource = menuData;
|
|
reForm.MSelectFlag = false;
|
|
reForm.RowIndexWidth = 35;
|
|
reForm.FormWidth = 500;
|
|
reForm.FormHeight = 500;
|
|
reForm.FilterKey = "";
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
batch = dr["批次"].ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
|
|
string sqls = @"SELECT Serial FROM dbo.ICSCarton WHERE BatchCode='" + batch + "' ORDER BY CartonNO";
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqls).Tables[0];
|
|
|
|
List<string> failPrint = new List<string>();
|
|
List<string> guidList = new List<string>();
|
|
List<PrintPara> parasList = new List<PrintPara>();
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
string ID = dt.Rows[i]["Serial"].ToString();
|
|
PrintPara para = new PrintPara();
|
|
para.PrintKey = ID;
|
|
para.PrintValues = new object[] { ID };
|
|
parasList.Add(para);
|
|
guidList.Add(ID);
|
|
}
|
|
|
|
if (parasList.Count == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("没有有效的数据,无法打印");
|
|
btnflash_Click(null, null);
|
|
return;
|
|
}
|
|
FormPrintDialog printDialog = new FormPrintDialog("1", "ICSCarton", parasList, false, null);
|
|
printDialog.ShowDialog();
|
|
|
|
string print = @"UPDATE dbo.ICSItemLot SET IsPrint = '是' WHERE BatchCode='" + batch + "'";
|
|
DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, print);
|
|
|
|
}
|
|
|
|
private void btnPrintAgain_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> itemCode = new List<string>();
|
|
List<string> guidList = new List<string>();
|
|
List<PrintPara> parasList = new List<PrintPara>();
|
|
string code = "";
|
|
string custCode = "";
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
string SFlag = grvDetail.GetRowCellValue(i, colSelect).ToString();
|
|
code = grvDetail.GetRowCellValue(i, ItemCode).ToString();
|
|
if (SFlag=="Y")
|
|
{
|
|
if (itemCode.Count > 0 && !itemCode.Contains(code))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择相同物料条码进行打印!!");
|
|
btnflash_Click(null, null);
|
|
return;
|
|
}
|
|
itemCode.Add(code);
|
|
}
|
|
}
|
|
if (itemCode.Count==0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择物料条码进行打印!!");
|
|
btnflash_Click(null, null);
|
|
return;
|
|
}
|
|
|
|
string sql = @"SELECT b.cCusCode as 客户编码,a.cInvName as 存货编码,
|
|
c.cCusName as 客户名称,b.cCusInvName as 客户存货名称 FROM {0}.dbo.Inventory a
|
|
LEFT JOIN {0}.dbo.CusInvContrapose b ON a.cInvCode=b.cInvCode
|
|
LEFT JOIN {0}.dbo.Customer c ON b.cCusCode=c.cCusCode
|
|
WHERE a.cInvCode='" + itemCode[0] + "' and b.cCusCode is not null ";
|
|
sql = string.Format(sql, ICSBaseSimpleCode.GetWorkPointErpData());
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if(data==null||data.Rows.Count==0){
|
|
ICSBaseSimpleCode.AppshowMessageBox("该物料没有在ERP维护客户存货!!");
|
|
btnflash_Click(null, null);
|
|
return;
|
|
}
|
|
FormDataRefer reForm = new FormDataRefer();
|
|
reForm.FormTitle = "客户存货列表";
|
|
DataTable menuData = data;
|
|
reForm.DataSource = menuData;
|
|
reForm.MSelectFlag = false;
|
|
reForm.HideCols.Add("cCusCode");
|
|
reForm.RowIndexWidth = 35;
|
|
reForm.FormWidth = 500;
|
|
reForm.FormHeight = 500;
|
|
reForm.FilterKey = "";
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
custCode = dr["客户编码"].ToString();
|
|
}
|
|
}
|
|
else {
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
string SFlag = grvDetail.GetRowCellValue(i, colSelect).ToString();
|
|
string id = grvDetail.GetRowCellValue(i, ID).ToString();
|
|
|
|
if (SFlag == "Y")
|
|
{
|
|
PrintPara para = new PrintPara();
|
|
para.PrintKey = id;
|
|
para.PrintValues = new object[] { ID , custCode };
|
|
parasList.Add(para);
|
|
itemCode.Add(code);
|
|
}
|
|
}
|
|
|
|
if (parasList.Count == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("没有有效的数据,无法打印");
|
|
btnflash_Click(null, null);
|
|
return;
|
|
}
|
|
FormPrintDialog printDialog = new FormPrintDialog("5", "ICSCarton4", parasList, false, null);
|
|
printDialog.ShowDialog();
|
|
}
|
|
#endregion
|
|
|
|
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;
|
|
}
|
|
FormStockBarCodeSelect pubSelect = new FormStockBarCodeSelect();
|
|
pubSelect.ShowDialog();
|
|
btnflash_Click(null,null);
|
|
//if(pubSelect.ShowDialog()==System.Windows.Forms.DialogResult.OK)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("批号生成成功!!");
|
|
// return;
|
|
//}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 分页
|
|
private void rptPage_PageIndexChanged(object Sender, EventArgs e)
|
|
{
|
|
|
|
DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
|
|
//DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
|
|
grdDetail.DataSource = data;
|
|
}
|
|
#endregion
|
|
|
|
#region 列表
|
|
private void grvDetails_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 FormProductBarCode_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
AppConfig.DropTemTable(tempTableName);
|
|
}
|
|
|
|
private void btnCartonOpen_Click(object sender, EventArgs e)
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
grvDetail.PostEditor();
|
|
this.Validate();
|
|
List<string> guidlist=new List<string>();
|
|
string oldBarCode = "";
|
|
for (int i = 0; i < grvDetail.RowCount;i++ )
|
|
{
|
|
if(grvDetail.GetRowCellValue(i,colSelect).ToString()=="Y")
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
if(guidlist.Count==0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
|
|
return;
|
|
}
|
|
if(guidlist.Count>1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择一条数据进行分箱!");
|
|
return;
|
|
}
|
|
//FormStockBarCodeOpen CartonOpen = new FormStockBarCodeOpen(guidlist,oldBarCode);
|
|
//if(CartonOpen.ShowDialog()==System.Windows.Forms.DialogResult.OK)
|
|
//{
|
|
// btnflash_Click(null, null);
|
|
//}
|
|
}
|
|
|
|
private void btnCartonClose_Click(object sender, EventArgs e)
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
grvDetail.PostEditor();
|
|
this.Validate();
|
|
List<string> guidlist = new List<string>();
|
|
string bacthcode = "";
|
|
decimal Qty = 0;
|
|
decimal Count = 0;
|
|
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
if (guidlist.Count <2)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择两条及以上数据进行分箱!");
|
|
return;
|
|
}
|
|
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在合包...请稍等...");
|
|
try
|
|
{
|
|
//using (AoMyEntityDataContext db = new AoMyEntityDataContext(AppConfig.AppConnectString))
|
|
//{
|
|
// var lines = db.ICSStockBarCode.Where(a => guidlist.Contains(a.Serial)).ToList();
|
|
// foreach (var line in lines)
|
|
// {
|
|
// Qty = Qty + decimal.Parse(line.Quantity.ToString());
|
|
// }
|
|
//}
|
|
//if (Count != Qty)
|
|
//{
|
|
// throw new Exception("分包之前的总数不等于分包之后的总数,分包错误!");
|
|
|
|
//}
|
|
//List<ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat> Listguid = new List<DAL.StockBarCodeDAL.CartonNoCreat>();
|
|
//List<ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat> Delguid = new List<DAL.StockBarCodeDAL.CartonNoCreat>();
|
|
//ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat Newline = new ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat();
|
|
|
|
bool b = true;
|
|
for (int j = 0; j < grvDetail.RowCount; j++)
|
|
{
|
|
|
|
if (grvDetail.GetRowCellValue(j, colSelect).ToString() == "Y" && b == true)
|
|
{
|
|
//Newline.serial = grvDetail.GetRowCellValue(j, Serial).ToString();
|
|
//Newline.Quantity = Count;
|
|
//Listguid.Add(Newline);
|
|
//b = false;
|
|
}
|
|
else if (grvDetail.GetRowCellValue(j, colSelect).ToString() == "Y" && b == false)
|
|
{
|
|
//ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat line = new ICSSoft.AoMy.DAL.StockBarCodeDAL.CartonNoCreat();
|
|
//line.serial = grvDetail.GetRowCellValue(j, Serial).ToString();
|
|
//line.BarCode = grvDetail.GetRowCellValue(j, BarCode).ToString();
|
|
//Delguid.Add(line);
|
|
}
|
|
|
|
}
|
|
//ICSSoft.AoMy.BLL.StockBarCodeBLL.CartonClose(Listguid, Delguid, AppConfig.AppConnectString);
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("合包成功!");
|
|
btnflash_Click(null, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox(1, "合包失败\r\n" + ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void btnCartonModify_Click(object sender, EventArgs e)
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
grvDetail.PostEditor();
|
|
this.Validate();
|
|
List<string> GuidList = new List<string>();
|
|
if(grvDetail.RowCount==0)
|
|
{
|
|
return;
|
|
}
|
|
if(grvDetail.FocusedRowHandle<0)
|
|
{
|
|
return;
|
|
}
|
|
for (int i = 0; i < grvDetail.RowCount;i++ )
|
|
{
|
|
if(grvDetail.GetRowCellValue(i,colSelect).ToString()=="Y")
|
|
{
|
|
GuidList.Add(grvDetail.GetRowCellValue(i,ID).ToString());
|
|
}
|
|
}
|
|
if(GuidList.Count==0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
|
|
return;
|
|
}
|
|
if(GuidList.Count>1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择一条数据进行修改箱号!");
|
|
return;
|
|
}
|
|
//FormStockBarCodeModify CartonModify = new FormStockBarCodeModify(GuidList);
|
|
//if(CartonModify.ShowDialog()==System.Windows.Forms.DialogResult.OK)
|
|
//{
|
|
// btnflash_Click(null, null);
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
private void grvDetail_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
if(grvDetail.RowCount==0)
|
|
{
|
|
return;
|
|
}
|
|
if(grvDetail.FocusedRowHandle<0)
|
|
{
|
|
return;
|
|
}
|
|
if(grvDetail.FocusedColumn==colSelect)
|
|
{
|
|
if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colSelect).ToString() == "Y")
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colSelect, "");
|
|
}
|
|
else
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle,colSelect,"Y");
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void btnfrompallet_Click(object sender, EventArgs e)
|
|
{
|
|
SimpleButton btntemp = (SimpleButton)sender;
|
|
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
return;
|
|
}
|
|
grvDetail.PostEditor();
|
|
this.Validate();
|
|
List<string> GuidList = new List<string>();
|
|
if (grvDetail.RowCount == 0)
|
|
{
|
|
return;
|
|
}
|
|
if (grvDetail.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
if (GuidList.Count == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
|
|
return;
|
|
}
|
|
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定要将选择的箱号脱离栈板吗?") != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
//ICSCartonBLL.FromPallet(GuidList,AppConfig.AppConnectString.ToString());
|
|
ICSBaseSimpleCode.AppshowMessageBox("脱离栈板成功!");
|
|
btnflash_Click(null, null);
|
|
}
|
|
|
|
private void FormCartonProtect_Load(object sender, EventArgs e)
|
|
{
|
|
btnFilter_Click(null, null);
|
|
}
|
|
|
|
private void btnPrintOne_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
List<PrintPara> parasList = new List<PrintPara>();
|
|
List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(i, colSelect).ToString() == "Y")
|
|
{
|
|
PrintPara para = new PrintPara();
|
|
para.PrintKey = "LOTNO";
|
|
para.PrintValues = new object[] { grvDetail.GetRowCellValue(i, LotNO).ToString() };
|
|
parasList.Add(para);
|
|
|
|
ICSITEMLot Info = new ICSITEMLot();
|
|
Info.LotNO = grvDetail.GetRowCellValue(i, LotNO).ToString();
|
|
Info.lastPrintUSERID = AppConfig.UserId;
|
|
Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
|
|
Info.WorkPoint = AppConfig.WorkPointCode;
|
|
InfoList.Add(Info);
|
|
}
|
|
}
|
|
if (parasList.Count == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
|
|
return;
|
|
}
|
|
FormPrintDialog f = new FormPrintDialog("006", this.Text, parasList, false, null);
|
|
f.ShowDialog();
|
|
|
|
//更新打印信息
|
|
ICSRdrecord2LOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
|
|
btnflash_Click(null, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
//SimpleButton btntemp = (SimpleButton)sender;
|
|
//if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
|
|
// return;
|
|
//}
|
|
|
|
//List<string> failPrint = new List<string>();
|
|
//List<string> guidList = new List<string>();
|
|
//List<PrintPara> parasList = new List<PrintPara>();
|
|
//for (int i = 0; i < grvDetail.RowCount; i++)
|
|
//{
|
|
// string SFlag = grvDetail.GetRowCellValue(i, colSelect).ToString();
|
|
// string id = grvDetail.GetRowCellValue(i, ID).ToString();
|
|
// if (SFlag == "Y")
|
|
// {
|
|
// PrintPara para = new PrintPara();
|
|
// para.PrintKey = id;
|
|
// para.PrintValues = new object[] { ID };
|
|
// parasList.Add(para);
|
|
// guidList.Add(id);
|
|
// }
|
|
//}
|
|
//if (parasList.Count == 0)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("没有有效的数据,无法打印");
|
|
// btnflash_Click(null, null);
|
|
// return;
|
|
//}
|
|
//FormPrintDialog printDialog = new FormPrintDialog("1", "ICSStockBarCode", parasList, false, null);
|
|
//printDialog.ShowDialog();
|
|
}
|
|
|
|
}
|
|
}
|