756 lines
26 KiB
C#
756 lines
26 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using WMS.Frm.Base;
|
|||
|
|
using WMS.Common;
|
|||
|
|
using WMS.Model.Base;
|
|||
|
|
using System.Text.RegularExpressions;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using DevExpress.XtraGrid.Columns;
|
|||
|
|
using DevExpress.XtraEditors.Repository;
|
|||
|
|
using DevExpress.XtraGrid.Views.Base;
|
|||
|
|
using NPOI.HSSF.UserModel;
|
|||
|
|
using NPOI.SS.UserModel;
|
|||
|
|
using System.IO;
|
|||
|
|
using DevExpress.XtraReports.UI;
|
|||
|
|
using WMS.Business;
|
|||
|
|
using WMS.Business.Base;
|
|||
|
|
using WMS.FrmPrint;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmBaseData
|
|||
|
|
{
|
|||
|
|
public partial class FrmBaseCtlGoods : FormBase
|
|||
|
|
{
|
|||
|
|
#region 全局变量的声明
|
|||
|
|
/// <summary>
|
|||
|
|
/// 容器Model
|
|||
|
|
/// </summary>
|
|||
|
|
public PalletModel sourceModel = new PalletModel();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 容器管理Model
|
|||
|
|
/// </summary>
|
|||
|
|
BaseCtlGoodsModel baseCtlGoodsModel = null;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 本窗体gridView数据集合
|
|||
|
|
/// </summary>
|
|||
|
|
List<BaseCtlGoodsModel> sourceList = null;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 复选框选中数据集合
|
|||
|
|
/// </summary>
|
|||
|
|
List<BaseCtlGoodsModel> checkList;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更换容器 追加新容器ID 条件
|
|||
|
|
/// </summary>
|
|||
|
|
List<BaseCtlGoodsModel> listCondiction;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 加一个int变量主要为了判断是否有checkbox选中项
|
|||
|
|
/// </summary>
|
|||
|
|
int i = 0;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 体积累加
|
|||
|
|
/// </summary>
|
|||
|
|
decimal sumVolume;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 全选判断
|
|||
|
|
/// </summary>
|
|||
|
|
bool m_status = false;
|
|||
|
|
|
|||
|
|
|
|||
|
|
string path = string.Empty;
|
|||
|
|
private HSSFWorkbook _workbook;
|
|||
|
|
// private XSSFWorkbook _xworkbookl;
|
|||
|
|
private ISheet _sheet;
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 构造函数
|
|||
|
|
/// <summary>
|
|||
|
|
/// 无参构造
|
|||
|
|
/// </summary>
|
|||
|
|
public FrmBaseCtlGoods()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 窗体加载
|
|||
|
|
/// <summary>
|
|||
|
|
/// 窗体加载
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void FrmBaseCtlGoods_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//通用查询
|
|||
|
|
FrmSelectModle = new BaseCtlGoodsModel();
|
|||
|
|
//下拉
|
|||
|
|
lkpTranstationType.LoadData();
|
|||
|
|
BindData();
|
|||
|
|
|
|||
|
|
if (frmButtonItem.ContainsKey("Clear")) { frmButtonItem["Clear"].Enabled = true; }
|
|||
|
|
if (frmButtonItem.ContainsKey("Export")) { frmButtonItem["Export"].Enabled = true; }
|
|||
|
|
if (frmButtonItem.ContainsKey("Unbound")) { frmButtonItem["Unbound"].Enabled = true; }
|
|||
|
|
if (frmButtonItem.ContainsKey("Print")) { frmButtonItem["Print"].Enabled = true; }
|
|||
|
|
if (frmButtonItem.ContainsKey("Search")) { frmButtonItem["Search"].Enabled = true; }
|
|||
|
|
if (frmButtonItem.ContainsKey("Refresh")) { frmButtonItem["Refresh"].Enabled = true; }
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm")) { frmButtonItem["Confirm"].Enabled = true; }
|
|||
|
|
|
|||
|
|
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = false; }
|
|||
|
|
//加载时 注册 EditValueChanged事件 为变更搬运人服务
|
|||
|
|
// DictionarycarryReplace.t_dictonary.EditValueChanged += new System.EventHandler(t_dictonary_EditValueChanged);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 事件
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region CheckBox全选的实现:3事件
|
|||
|
|
/// <summary>
|
|||
|
|
/// Click 事件 调用DevControlHelper 帮助类
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void gridViewCtlGoods_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (DevControlHelper.ClickGridCheckBox(this.gridViewCtlGoods, "IsCheck", m_status))
|
|||
|
|
{
|
|||
|
|
m_status = !m_status;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// CustomDrawColumnHeader 事件
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void gridViewCtlGoods_CustomDrawColumnHeader(object sender, DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventArgs e)
|
|||
|
|
{
|
|||
|
|
//if (e.Column != null && e.Column.FieldName == "IsCheck")
|
|||
|
|
//{
|
|||
|
|
// e.Info.InnerElements.Clear();
|
|||
|
|
// e.Painter.DrawObject(e.Info);
|
|||
|
|
// DevControlHelper.DrawCheckBox(e, m_status);
|
|||
|
|
// e.Handled = true;
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// DataSourceChanged 事件
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void gridViewCtlGoods_DataSourceChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
GridColumn column = this.gridViewCtlGoods.Columns.ColumnByFieldName("IsCheck");
|
|||
|
|
if (column != null)
|
|||
|
|
{
|
|||
|
|
column.Width = 80;
|
|||
|
|
column.OptionsColumn.ShowCaption = m_status;
|
|||
|
|
column.ColumnEdit = new RepositoryItemCheckEdit();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 变更搬运人EditValueChanged 事件
|
|||
|
|
//变更搬运人
|
|||
|
|
private void t_dictonary_EditValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//获得选中数据行
|
|||
|
|
GetCheckData();
|
|||
|
|
if (i == 0)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请至少选择一种商品才能进行变更搬运人操作!");
|
|||
|
|
//this.DictionarycarryReplace.TextBoxFlag = string.Empty;
|
|||
|
|
//this.DictionarycarryReplace.TextBoxValue = string.Empty;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (i > 0)
|
|||
|
|
{
|
|||
|
|
foreach (BaseCtlGoodsModel list in sourceList)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(list.User_ID) || !string.IsNullOrEmpty(list.NAME))
|
|||
|
|
{
|
|||
|
|
//list.User_ID = this.DictionarycarryReplace.TextBoxFlag;
|
|||
|
|
//list.NAME = this.DictionarycarryReplace.TextBoxValue;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
this.gridViewCtlGoods.RefreshData();
|
|||
|
|
this.lkpTranstationType.Focus();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 未查询到数据时的提示CustomDrawEmptyForeground 事件
|
|||
|
|
|
|||
|
|
private void gridViewCtlGoods_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)
|
|||
|
|
{
|
|||
|
|
ColumnView columnView = sender as ColumnView;
|
|||
|
|
BindingSource bindingSource = this.gridViewCtlGoods.DataSource as BindingSource;
|
|||
|
|
if (bindingSource.Count == 0)
|
|||
|
|
{
|
|||
|
|
string str = "<对不起,没有查询到你所想要的数据!>";
|
|||
|
|
Font f = new Font("宋体", 11, FontStyle.Regular);
|
|||
|
|
Rectangle r = new Rectangle(e.Bounds.Top + 25, e.Bounds.Left + 25, e.Bounds.Right - 25, e.Bounds.Height - 25);
|
|||
|
|
e.Graphics.DrawString(str, f, Brushes.Gray, r);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 辅助方法
|
|||
|
|
|
|||
|
|
#region 公共菜单 按钮 方法
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询
|
|||
|
|
/// </summary>
|
|||
|
|
public void Search()
|
|||
|
|
{
|
|||
|
|
//将挂起的更改 绑定到数据源
|
|||
|
|
bgsConditions.EndEdit();
|
|||
|
|
BindData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 打印
|
|||
|
|
/// </summary>
|
|||
|
|
public void Print()
|
|||
|
|
{
|
|||
|
|
//if (DialogResult.No == SystemCommon.ShowMessageBoxResult("是否打印选中的库位条码"))
|
|||
|
|
//{
|
|||
|
|
// return;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
List<StorageAreaLocationModel> listLoc = new List<StorageAreaLocationModel>();
|
|||
|
|
|
|||
|
|
for (int handle = 0; handle < gridViewCtlGoods.RowCount; handle++)
|
|||
|
|
{
|
|||
|
|
string id = gridViewCtlGoods.GetRowCellValue(handle, "IsCheck").ToString();
|
|||
|
|
if (gridViewCtlGoods.GetRowCellValue(handle, "IsCheck").ToString() == "1")
|
|||
|
|
{
|
|||
|
|
//BarCodeReport.GetInstance(id, 7).PrintDialog();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//StorageAreaLocationModel loc = new StorageAreaLocationModel();
|
|||
|
|
//loc = GVStorageAreaLocation.GetRow(handle) as StorageAreaLocationModel;
|
|||
|
|
//listLoc.Add(loc);
|
|||
|
|
}
|
|||
|
|
//listLoc.RemoveAll(p=>p.LOCATION_ID == null||p.LOCATION_ID == string.Empty);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 重置
|
|||
|
|
/// </summary>
|
|||
|
|
public void Refresh()
|
|||
|
|
{
|
|||
|
|
this.lkpTranstationType.Text = string.Empty;
|
|||
|
|
this.lkpTranstationType.EditValue = string.Empty;
|
|||
|
|
this.lkpTranstationType.Properties.ShowPopupShadow = false;
|
|||
|
|
this.Dictionarycarry.TextBoxFlag = string.Empty;
|
|||
|
|
this.Dictionarycarry.TextBoxValue = string.Empty;
|
|||
|
|
BindData();
|
|||
|
|
if (frmButtonItem.ContainsKey("Save"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Save"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 清空
|
|||
|
|
/// </summary>
|
|||
|
|
public void Clear()
|
|||
|
|
{
|
|||
|
|
this.lkpTranstationType.EditValue = string.Empty;
|
|||
|
|
this.lkpTranstationType.Text = string.Empty;
|
|||
|
|
|
|||
|
|
this.Dictionarycarry.TextBoxFlag = string.Empty;
|
|||
|
|
this.Dictionarycarry.TextBoxValue = string.Empty;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导出到Excel
|
|||
|
|
/// </summary>
|
|||
|
|
public void Export()
|
|||
|
|
{
|
|||
|
|
DataToExcel();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//选托盘 按钮
|
|||
|
|
/*
|
|||
|
|
public void spallet()
|
|||
|
|
{
|
|||
|
|
//托盘窗体
|
|||
|
|
FrmPallet frmPallet = new FrmPallet(this);
|
|||
|
|
GetCheckData();
|
|||
|
|
//选托盘方法
|
|||
|
|
SearchPallet(frmPallet);
|
|||
|
|
}
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 解除绑定
|
|||
|
|
/// </summary>
|
|||
|
|
public void Unbound()
|
|||
|
|
{
|
|||
|
|
//获得选中数据
|
|||
|
|
GetCheckData();
|
|||
|
|
Unbounds();
|
|||
|
|
BindData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存
|
|||
|
|
/// </summary>
|
|||
|
|
public void Save()
|
|||
|
|
{
|
|||
|
|
#region 验证所更换的容器是否是当前正在使用的容器
|
|||
|
|
foreach (BaseCtlGoodsModel mm in checkList)
|
|||
|
|
{
|
|||
|
|
if (mm.CTL_PALLET_ID == this.Dictionarycarry.TextBoxFlag)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("当前容器即为该选择容器,请重新选择!");
|
|||
|
|
mm.IsCheck = false;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(mm.VC_DICTIONARY_ID))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择这批物料的事务类型!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SaveSelectPallet();
|
|||
|
|
this.gridViewCtlGoods.RefreshData();
|
|||
|
|
BindData();
|
|||
|
|
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = false; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 确认
|
|||
|
|
/// </summary>
|
|||
|
|
public void Confirm()
|
|||
|
|
{
|
|||
|
|
Replace();
|
|||
|
|
//listCondiction.AddRange(checkList);
|
|||
|
|
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = true; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导入Excel 到数据
|
|||
|
|
/// </summary>
|
|||
|
|
public void Audit()
|
|||
|
|
{
|
|||
|
|
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
path = openFileDialog1.FileName;
|
|||
|
|
ReadExecl(path);
|
|||
|
|
}
|
|||
|
|
List<BaseCtlGoodsModel> tabletolist = ConvertHelper<BaseCtlGoodsModel>.ConvertToList(table);
|
|||
|
|
//bgsPallet.DataSource = tabletolist;
|
|||
|
|
//this.gridViewPallet.RefreshData();
|
|||
|
|
}
|
|||
|
|
DataTable table = new DataTable();
|
|||
|
|
private DataTable ReadExecl(string path)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//HSSFWorkbook:是操作Excel2003以前(包括2003)的版本,扩展名是.xls
|
|||
|
|
//XSSFWorkbook:是操作Excel2007的版本,扩展名是.xlsx
|
|||
|
|
_workbook = new HSSFWorkbook(stream);
|
|||
|
|
//_xworkbookl = new XSSFWorkbook(stream);
|
|||
|
|
_sheet = _workbook.GetSheetAt(0);
|
|||
|
|
IRow headerRow = _sheet.GetRow(0);//第一行为标题行
|
|||
|
|
int cellCount = headerRow.LastCellNum;//LastCellNum = PhysicalNumberOfCells
|
|||
|
|
int rowCount = _sheet.LastRowNum;//LastRowNum = PhysicalNumberOfRows - 1
|
|||
|
|
for (int i = headerRow.FirstCellNum; i < cellCount; i++)
|
|||
|
|
{
|
|||
|
|
DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
|
|||
|
|
table.Columns.Add(column);
|
|||
|
|
}
|
|||
|
|
for (int i = (_sheet.FirstRowNum + 1); i <= rowCount; i++)
|
|||
|
|
{
|
|||
|
|
IRow row = _sheet.GetRow(i);
|
|||
|
|
DataRow dataRow = table.NewRow();
|
|||
|
|
if (row != null)
|
|||
|
|
{
|
|||
|
|
for (int j = row.FirstCellNum; j < cellCount; j++)
|
|||
|
|
{
|
|||
|
|
if (row.GetCell(j) != null)
|
|||
|
|
{
|
|||
|
|
dataRow[j] = row.GetCell(j).ToString();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
table.Rows.Add(dataRow);
|
|||
|
|
}
|
|||
|
|
return table;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox("读取EXCEL失败!" + e.Message);
|
|||
|
|
return table;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 通用查询
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 通用查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="table"></param>
|
|||
|
|
public override void LoadListData(DataTable table)
|
|||
|
|
{
|
|||
|
|
sourceList = ConvertHelper<BaseCtlGoodsModel>.ConvertToList(table);
|
|||
|
|
bgsConditions.DataSource = sourceList;
|
|||
|
|
gridViewCtlGoods.RefreshData();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 数据绑定
|
|||
|
|
/// <summary>
|
|||
|
|
/// 数据绑定
|
|||
|
|
/// </summary>
|
|||
|
|
private void BindData()
|
|||
|
|
{
|
|||
|
|
#region 查询条件
|
|||
|
|
//搬运人ID
|
|||
|
|
//baseCtlGoodsModel = bgsConditions.DataSource as BaseCtlGoodsModel;
|
|||
|
|
//baseCtlGoodsModel.User_ID = this.Dictionarycarry.TextBoxFlag;
|
|||
|
|
// bgsConditions.DataSource = new BaseCtlGoodsModel();
|
|||
|
|
baseCtlGoodsModel = new BaseCtlGoodsModel();
|
|||
|
|
baseCtlGoodsModel.CTL_PALLET_ID = this.txtPallet_id.Text;
|
|||
|
|
bgsConditions.DataSource = baseCtlGoodsModel;
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
BaseCtlGoodsModel model = bgsConditions.DataSource as BaseCtlGoodsModel;
|
|||
|
|
|
|||
|
|
sourceList = IBussFactory<BussBaseCtlGoods>.Instance().GetDataList(model);
|
|||
|
|
bgsBaseCtlGoods.DataSource = sourceList;
|
|||
|
|
this.gridViewCtlGoods.RefreshData();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox("网络连接错误!请检查当前网络环境是否可用!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 获得checkbox选中项数据
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获得check 选中项
|
|||
|
|
/// </summary>
|
|||
|
|
private void GetCheckData()
|
|||
|
|
{
|
|||
|
|
checkList = new List<BaseCtlGoodsModel>();
|
|||
|
|
//赋值为初始值 是为了再次操作时 重新计量
|
|||
|
|
i = 0;
|
|||
|
|
sumVolume = 0;
|
|||
|
|
this.lkpTranstationType.Focus();
|
|||
|
|
foreach (BaseCtlGoodsModel model in sourceList)
|
|||
|
|
{
|
|||
|
|
if (model.IsCheck == true)
|
|||
|
|
{
|
|||
|
|
checkList.Add(model);
|
|||
|
|
//累加商品体积
|
|||
|
|
sumVolume += model.GVOLUME;
|
|||
|
|
i++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 解绑按钮方法
|
|||
|
|
/// <summary>
|
|||
|
|
/// 解绑按钮方法
|
|||
|
|
/// </summary>
|
|||
|
|
private void Unbounds()
|
|||
|
|
{
|
|||
|
|
string strmodel;
|
|||
|
|
string errtex;
|
|||
|
|
if (i == 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请至少选择一种商品才能进行解绑操作!!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
#region 操作 解除绑定
|
|||
|
|
if (i == 1)
|
|||
|
|
{
|
|||
|
|
foreach (BaseCtlGoodsModel list in checkList)
|
|||
|
|
{
|
|||
|
|
//1.无商品 有托盘 可解绑
|
|||
|
|
if (string.IsNullOrEmpty(list.GOODS_ID) && !string.IsNullOrEmpty(list.CTL_PALLET_ID))
|
|||
|
|
{
|
|||
|
|
//listCondiction.Add(list);
|
|||
|
|
DialogResult dr = MessageBox.Show("确定要解除绑定吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
|
|||
|
|
if (dr == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//删除表中的 托盘数据信息
|
|||
|
|
|
|||
|
|
errtex = IBussFactory<BussBaseCtlGoods>.Instance().DeleteData(list);
|
|||
|
|
if (!string.IsNullOrEmpty(errtex))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("解除绑定失败!");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("解除绑定成功!");
|
|||
|
|
this.gridViewCtlGoods.RefreshData();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox("网络连接错误!请检查当前网络环境是否可用!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
//2.有商品 有托盘 不能解绑
|
|||
|
|
if (!string.IsNullOrEmpty(list.GOODS_ID) && !string.IsNullOrEmpty(list.CTL_PALLET_ID))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("该容器上放有物料商品,必须把物料移到其他容器才可以解除绑定!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
if (i > 1)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("解除绑定只允许单条解绑,请选择一条数据!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 选托盘按钮方法
|
|||
|
|
|
|||
|
|
/********选托盘按钮方法
|
|||
|
|
private void SearchPallet(FrmPallet frmPallet)
|
|||
|
|
{
|
|||
|
|
if (i == 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请至少选择一种商品!!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (i > 0)
|
|||
|
|
{
|
|||
|
|
DialogResult rlt = frmPallet.ShowDialog();
|
|||
|
|
if (rlt == DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
foreach (BaseCtlGoodsModel model in checkList)
|
|||
|
|
{
|
|||
|
|
model.CTL_PALLET_ID = sourceModel.PALLET_ID;
|
|||
|
|
model.PALLET_NAME = sourceModel.PALLET_NAME;
|
|||
|
|
model.VOLUME = sourceModel.VOLUME;
|
|||
|
|
model.BEARWEIGHT = sourceModel.BEARWEIGHT;
|
|||
|
|
}
|
|||
|
|
this.gridViewCtlGoods.RefreshData();
|
|||
|
|
}
|
|||
|
|
//判断商品总体积是否大于托盘最大体积
|
|||
|
|
if (sumVolume >= sourceModel.VOLUME)
|
|||
|
|
{
|
|||
|
|
DialogResult dr = MessageBox.Show("所选商品体积大于托盘最大体积容量,是否放入容器?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
|
|||
|
|
if (dr == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("放入成功");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
*/
|
|||
|
|
//////
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 导出数据到Excel文件方法
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导出数据到Excel
|
|||
|
|
/// </summary>
|
|||
|
|
private void DataToExcel()
|
|||
|
|
{
|
|||
|
|
SaveFileDialog fileDialog = new SaveFileDialog();
|
|||
|
|
fileDialog.Title = "导出Excel";
|
|||
|
|
fileDialog.Filter = "Excel文件(*.xls)|*.xls";
|
|||
|
|
DialogResult dialogResult = fileDialog.ShowDialog(this);
|
|||
|
|
if (dialogResult == DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
|
|||
|
|
this.gridViewCtlGoods.ExportToXls(fileDialog.FileName);
|
|||
|
|
DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 保存换容器方法
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存换容器数据
|
|||
|
|
/// </summary>
|
|||
|
|
private void SaveSelectPallet()
|
|||
|
|
{
|
|||
|
|
this.lkpTranstationType.Focus();
|
|||
|
|
foreach (BaseCtlGoodsModel s in sourceList)
|
|||
|
|
{
|
|||
|
|
s.OPERATORID = userData.USER_ID;
|
|||
|
|
s.OPERATEDATE = DateTime.Now;
|
|||
|
|
if (s.IsCheck == true)
|
|||
|
|
{
|
|||
|
|
listCondiction.Add(s);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string errtex = IBussFactory<BussBaseCtlGoods>.Instance().Operator(listCondiction, 1);
|
|||
|
|
if (!string.IsNullOrEmpty(errtex))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作失败!");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|||
|
|
foreach (BaseCtlGoodsModel m in sourceList)
|
|||
|
|
{
|
|||
|
|
m.PALLET_NEWID = "";
|
|||
|
|
m.IsCheck = false;
|
|||
|
|
}
|
|||
|
|
this.Dictionarycarry.TextBoxFlag = string.Empty;
|
|||
|
|
this.Dictionarycarry.TextBoxValue = string.Empty;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox("网络连接错误!请检查当前网络环境是否可用!");
|
|||
|
|
}
|
|||
|
|
BindData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 确认按钮显示 新编号
|
|||
|
|
/// <summary>
|
|||
|
|
/// 追加新 容器编号(为了替换原先的容器)
|
|||
|
|
/// </summary>
|
|||
|
|
private void Replace()
|
|||
|
|
{
|
|||
|
|
listCondiction = new List<BaseCtlGoodsModel>();
|
|||
|
|
GetCheckData();
|
|||
|
|
if (i <= 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请至少选择一种商品才能进行更换容器操作!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
else if (i > 0)
|
|||
|
|
{
|
|||
|
|
foreach (BaseCtlGoodsModel model in checkList)
|
|||
|
|
{
|
|||
|
|
//选中项不含商品时
|
|||
|
|
if (string.IsNullOrEmpty(model.GOODS_ID))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("所选数据中含有空容器,不用进行更换,建议解除绑定!");
|
|||
|
|
model.IsCheck = false;
|
|||
|
|
this.Dictionarycarry.TextBoxFlag = string.Empty;
|
|||
|
|
this.Dictionarycarry.TextBoxValue = string.Empty;
|
|||
|
|
this.gridViewCtlGoods.RefreshData();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
else if (string.IsNullOrEmpty(this.Dictionarycarry.TextBoxFlag.Trim()))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请先选择一种容器才能进行更换!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
model.PALLET_NEWID = this.Dictionarycarry.TextBoxFlag;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
this.gridViewCtlGoods.RefreshData();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region lkpTranstationType_EditValueChanged事件
|
|||
|
|
private void lkpTranstationType_EditValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.lkpTranstationType.Focus();
|
|||
|
|
if (string.IsNullOrEmpty(this.lkpTranstationType.EditValue.ToString()))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
//bgsBaseCtlGoods.DataSource = sourceList.FindAll(r => r.VC_DICTIONARY_ID == this.lkpTranstationType.EditValue.ToString());
|
|||
|
|
foreach (BaseCtlGoodsModel bcg in sourceList)
|
|||
|
|
{
|
|||
|
|
if (bcg.IsCheck == true)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(bcg.GOODS_ID))
|
|||
|
|
{
|
|||
|
|
bcg.VC_DICTIONARY_ID = string.Empty;
|
|||
|
|
bcg.VC_DICTIONARY_NAME = string.Empty;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
bcg.VC_DICTIONARY_ID = this.lkpTranstationType.EditValue.ToString();
|
|||
|
|
bcg.VC_DICTIONARY_NAME = this.lkpTranstationType.Text;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
bgsBaseCtlGoods.DataSource = sourceList;
|
|||
|
|
this.gridViewCtlGoods.RefreshData();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|