807 lines
33 KiB
C#
807 lines
33 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.Model.Base;
|
|||
|
|
using WMS.Common;
|
|||
|
|
using WMS.Ctrl;
|
|||
|
|
using NPOI.Util.Collections;
|
|||
|
|
using DevExpress.XtraEditors.Repository;
|
|||
|
|
using DevExpress.XtraReports.UI;
|
|||
|
|
using System.Threading;
|
|||
|
|
using WMS.Business;
|
|||
|
|
using WMS.Business.Base;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmBaseData
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 窗体:仓库
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class FrmStorage : FormBase
|
|||
|
|
{
|
|||
|
|
#region 变量
|
|||
|
|
private StorageAreaModel storageAreaModel = new StorageAreaModel();
|
|||
|
|
private List<StorageAreaModel> listStorageAreaModel = new List<StorageAreaModel>();
|
|||
|
|
private List<StorageAreaLocationModel> listStorageAreaLocationModel = new List<StorageAreaLocationModel>();
|
|||
|
|
private int flag = -1;//0:新增;1:修改
|
|||
|
|
private int delFlag = -1;//0:焦点在treelist 1:焦点在GridView 标识删除
|
|||
|
|
//private string strStorageAreaByInfo = string.Empty;//用于绑定GridView的库区字符串列表
|
|||
|
|
|
|||
|
|
//public string StrStorageAreaByInfo
|
|||
|
|
//{
|
|||
|
|
// get { return strStorageAreaByInfo; }
|
|||
|
|
// set { strStorageAreaByInfo = value; }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 构造函数
|
|||
|
|
public FrmStorage()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 加载事件
|
|||
|
|
public void FrmStorage_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BindLoadStorage();
|
|||
|
|
// BindArea();//绑定库区
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
void BindLoadStorage()
|
|||
|
|
{
|
|||
|
|
StorageInfoModel stoModel = new StorageInfoModel();
|
|||
|
|
|
|||
|
|
List<StorageInfoModel> str_list = IBussFactory<BussStorageInfo>.Instance().GetStorageInfoDS(stoModel);
|
|||
|
|
foreach(StorageInfoModel info in str_list)
|
|||
|
|
{
|
|||
|
|
StorageAreaModel storageAreaModel = new StorageAreaModel();
|
|||
|
|
storageAreaModel.STORAGE_ID = "0";
|
|||
|
|
storageAreaModel.STORAGE_AREA_ID = info.STORAGE_ID;
|
|||
|
|
storageAreaModel.STORAGE_AREA_NAME = info.STORAGE_NAME;
|
|||
|
|
listStorageAreaModel.Add(storageAreaModel);
|
|||
|
|
BindArea(info.STORAGE_ID);
|
|||
|
|
}
|
|||
|
|
bsStorageArea.DataSource = listStorageAreaModel;
|
|||
|
|
treeListStorageArea.Refresh();
|
|||
|
|
treeListStorageArea.FocusedNode = treeListStorageArea.Nodes.FirstNode;
|
|||
|
|
treeListStorageArea.ExpandAll();//展开整个树
|
|||
|
|
storageAreaModel = listStorageAreaModel[0];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#region 绑定库区
|
|||
|
|
private void BindArea(string storageID)
|
|||
|
|
{
|
|||
|
|
//绑定库区数据
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
|
|||
|
|
storageAreaModel = new StorageAreaModel();
|
|||
|
|
storageAreaModel.STORAGE_ID = storageID;
|
|||
|
|
List<AreaGoodsTypeModel> areaGoodsTypeList = new List<AreaGoodsTypeModel>();
|
|||
|
|
List<StorageAreaModel> nodeArea = IBussFactory<BussStorageArea>.Instance().GetAreaInfoDS(storageAreaModel, ref areaGoodsTypeList);
|
|||
|
|
|
|||
|
|
//如果有数据
|
|||
|
|
if (listStorageAreaModel.Count > 0)
|
|||
|
|
{
|
|||
|
|
//绑定数据
|
|||
|
|
listStorageAreaModel.AddRange(nodeArea);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
#region 刷新按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Refresh()
|
|||
|
|
{
|
|||
|
|
BindLoadStorage();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
#region 批量编辑库位
|
|||
|
|
/// </summary>
|
|||
|
|
public void EditLoc()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<StorageAreaLocationModel> listLoc = new List<StorageAreaLocationModel>();
|
|||
|
|
|
|||
|
|
foreach (int handle in GVStorageAreaLocation.GetSelectedRows())
|
|||
|
|
{
|
|||
|
|
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);
|
|||
|
|
|
|||
|
|
if (listLoc.Count == 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择库位");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string letter = listLoc[0].LOCATION_ID;
|
|||
|
|
int length = letter.Length;//库位编号长度
|
|||
|
|
SystemCommon.GetNumber(ref letter);
|
|||
|
|
int min = int.MaxValue;
|
|||
|
|
int max = int.MinValue;
|
|||
|
|
foreach (StorageAreaLocationModel loc in listLoc)
|
|||
|
|
{
|
|||
|
|
string t = loc.LOCATION_ID;
|
|||
|
|
if (t.Length != length)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("所选库位编号长度不完全相同,不能批量修改");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
int i = Convert.ToInt32(SystemCommon.GetNumber(ref t));
|
|||
|
|
if (letter != t)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("所选库位字母标识不完全相同,不能批量修改");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (i < min)
|
|||
|
|
{
|
|||
|
|
min = i;
|
|||
|
|
}
|
|||
|
|
if (i > max)
|
|||
|
|
{
|
|||
|
|
max = i;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
FrmStorageAreaLocationHandle frmStorageAreaLocationHandle = new FrmStorageAreaLocationHandle(listLoc);
|
|||
|
|
frmStorageAreaLocationHandle.userData = this.userData;
|
|||
|
|
frmStorageAreaLocationHandle.ShowDialog();
|
|||
|
|
BindLocation("","");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 库区发生变化时
|
|||
|
|
private void treeListStorageArea_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.Node != null)//如果有选中行
|
|||
|
|
{
|
|||
|
|
//如果是库区 绑定库位
|
|||
|
|
//编辑区域数据绑定
|
|||
|
|
|
|||
|
|
storageAreaModel = new StorageAreaModel();
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//通过编号查询记录
|
|||
|
|
|
|||
|
|
t_ckbh.Tag = e.Node.GetValue("STORAGE_ID").ToString();
|
|||
|
|
if (t_ckbh.Tag.ToString()=="0")
|
|||
|
|
{
|
|||
|
|
storageAreaModel.STORAGE_ID = e.Node.GetValue("STORAGE_AREA_ID").ToString();
|
|||
|
|
storageAreaModel.STATUS = e.Node.GetValue("STATUS").ToString();
|
|||
|
|
storageAreaModel.REMARK = e.Node.GetValue("REMARK").ToString();
|
|||
|
|
t_ckbh.Text = e.Node.GetValue("STORAGE_AREA_NAME").ToString();
|
|||
|
|
t_kq.Tag = "";
|
|||
|
|
t_kq.Text = "";
|
|||
|
|
t_ckbh.Tag = "0";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
storageAreaModel.STORAGE_AREA_ID = e.Node.GetValue("STORAGE_AREA_ID").ToString();
|
|||
|
|
storageAreaModel.STORAGE_ID = e.Node.GetValue("STORAGE_ID").ToString();
|
|||
|
|
storageAreaModel.STORAGE_AREA_NAME = e.Node.GetValue("STORAGE_AREA_NAME").ToString();
|
|||
|
|
storageAreaModel.STORAGE_AREA_SHORT_NAME = e.Node.GetValue("STORAGE_AREA_SHORT_NAME").ToString();
|
|||
|
|
t_ckbh.Text = e.Node.GetValue("STORAGE_NAME").ToString();
|
|||
|
|
t_ckbh.Tag = e.Node.GetValue("STORAGE_ID").ToString();
|
|||
|
|
t_kq.Tag = storageAreaModel.STORAGE_AREA_ID;
|
|||
|
|
t_kq.Text = e.Node.GetValue("STORAGE_AREA_NAME").ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
BindLocation(e.Node.GetValue("STORAGE_AREA_ID").ToString(), t_kq.Tag.ToString());
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
SystemCommon.ShowInfoMessageBox("库区查询错误:" + ex.Message);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{ //是仓库
|
|||
|
|
// // string storageId = e.Node.GetValue("STORAGE_AREA_ID").ToString();
|
|||
|
|
// // BindLocation(storageId,"");
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 绑定库位
|
|||
|
|
private void BindLocation(string storageId,string STORAGE_AREA_ID)
|
|||
|
|
{
|
|||
|
|
//绑定库位数据
|
|||
|
|
StorageAreaLocationModel temp = new StorageAreaLocationModel();
|
|||
|
|
temp.STORAGE_AREA_ID = STORAGE_AREA_ID;
|
|||
|
|
temp.STORAGE_ID = storageId;
|
|||
|
|
List<LocAreaModel> locAreas = new List<LocAreaModel>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
listStorageAreaLocationModel = IBussFactory<BussStorageAreaLocation>.Instance().GetLocationInfoDS(temp);//查询
|
|||
|
|
if (listStorageAreaLocationModel != null)
|
|||
|
|
{
|
|||
|
|
bsStorageAreaLocation.DataSource = listStorageAreaLocationModel;
|
|||
|
|
GVStorageAreaLocation.RefreshData();
|
|||
|
|
GVStorageAreaLocation.FocusedRowHandle = 0;//选中第一行
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("获得库位出错了:" + ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 编辑仓库
|
|||
|
|
public void EditStorage()
|
|||
|
|
{
|
|||
|
|
if(treeListStorageArea.FocusedNode.GetValue("STORAGE_ID").ToString()!="0")
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
StorageInfoModel storageInfoModel = new StorageInfoModel();
|
|||
|
|
storageInfoModel.STORAGE_ID = treeListStorageArea.FocusedNode.GetValue("STORAGE_AREA_ID").ToString();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<StorageInfoModel> tempList = new List<StorageInfoModel>();
|
|||
|
|
List<StorageOrderModel> storOrderList = new List<StorageOrderModel>();
|
|||
|
|
tempList = IBussFactory<BussStorageInfo>.Instance().GetStorageInfoDS(storageInfoModel, ref storOrderList);
|
|||
|
|
|
|||
|
|
if (tempList.Count > 0)
|
|||
|
|
{
|
|||
|
|
storageInfoModel = tempList[0];
|
|||
|
|
FrmStorageInfoHandle frmStorageInfoHandle = new FrmStorageInfoHandle(storageInfoModel, storOrderList);
|
|||
|
|
frmStorageInfoHandle.userData = this.userData;
|
|||
|
|
frmStorageInfoHandle.ShowDialog();
|
|||
|
|
// BindArea();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("没有仓库");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("EditStorage出错了" + ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
#region 双击库位 单个编辑
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void GCStorageAreaLocation_DoubleClick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
StorageAreaLocationModel storageAreaLocationModel = new StorageAreaLocationModel();
|
|||
|
|
storageAreaLocationModel = GVStorageAreaLocation.GetFocusedRow() as StorageAreaLocationModel;
|
|||
|
|
List<StorageAreaLocationModel> tempList = new List<StorageAreaLocationModel>();
|
|||
|
|
List<LocAreaModel> laList = new List<LocAreaModel>();
|
|||
|
|
tempList = IBussFactory<BussStorageAreaLocation>.Instance().GetLocationInfoDS(storageAreaLocationModel, ref laList);
|
|||
|
|
if (tempList.Count > 0)
|
|||
|
|
{
|
|||
|
|
storageAreaLocationModel = tempList[0];
|
|||
|
|
FrmStorageAreaLocationHandle frmStorageAreaLocationHandle = new FrmStorageAreaLocationHandle(storageAreaLocationModel.row1, storageAreaLocationModel.cln, storageAreaLocationModel.cln,
|
|||
|
|
storageAreaLocationModel.layer1, storageAreaLocationModel.layer1, storageAreaLocationModel.LOCATION_ID, storageAreaLocationModel.LOCATION_ID, storageAreaLocationModel,1);
|
|||
|
|
frmStorageAreaLocationHandle.userData = this.userData;
|
|||
|
|
frmStorageAreaLocationHandle.ShowDialog();
|
|||
|
|
// BindLocation(storageAreaModel.STORAGE_ID,"");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("没有仓库");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
public void SetLoc()
|
|||
|
|
{
|
|||
|
|
if (treeListStorageArea.Nodes.Count == 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (treeListStorageArea.FocusedNode.GetValue("STORAGE_ID").ToString() == "0")
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ( storageAreaModel.EDIT == "0")//如果不可编辑
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("该库区不可被编辑");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// storageAreaModel = treeListStorageArea.FocusedNode as StorageAreaModel;
|
|||
|
|
FrmStorageAreaHandle frmStorageAreaHandle = new FrmStorageAreaHandle(storageAreaModel);
|
|||
|
|
frmStorageAreaHandle.userData = this.userData;
|
|||
|
|
frmStorageAreaHandle.ShowDialog();
|
|||
|
|
BindLoadStorage();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
#region 新增库区
|
|||
|
|
/// </summary>
|
|||
|
|
public void AddArea()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
FrmStorageAreaHandle frmStorageAreaHandle = new FrmStorageAreaHandle();
|
|||
|
|
frmStorageAreaHandle.userData = this.userData;
|
|||
|
|
if (treeListStorageArea.FocusedNode.GetValue("STORAGE_ID") != null && treeListStorageArea.FocusedNode.GetValue("STORAGE_ID").ToString() != "0")
|
|||
|
|
{
|
|||
|
|
frmStorageAreaHandle.storageAreaModel.STORAGE_ID = storageAreaModel.STORAGE_ID;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
frmStorageAreaHandle.storageAreaModel.STORAGE_ID = storageAreaModel.STORAGE_AREA_ID;
|
|||
|
|
}
|
|||
|
|
frmStorageAreaHandle.ShowDialog();
|
|||
|
|
// BindArea();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
#region 新增库位
|
|||
|
|
/// </summary>
|
|||
|
|
public void AddLocation()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
FrmStorageAreaLocationHandle frmStorageAreaLocationHandle = new FrmStorageAreaLocationHandle();
|
|||
|
|
frmStorageAreaLocationHandle.userData = this.userData;
|
|||
|
|
if (treeListStorageArea.FocusedNode.GetValue("STORAGE_ID") != null && treeListStorageArea.FocusedNode.GetValue("STORAGE_ID").ToString()!="0")
|
|||
|
|
{ //库区
|
|||
|
|
|
|||
|
|
frmStorageAreaLocationHandle.storageAreaLocationModel.STORAGE_ID = storageAreaModel.STORAGE_AREA_ID;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
frmStorageAreaLocationHandle.storageAreaLocationModel.STORAGE_ID = storageAreaModel.STORAGE_ID;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
frmStorageAreaLocationHandle.ShowDialog();
|
|||
|
|
BindLocation(storageAreaModel.STORAGE_ID,"");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
#region 删除
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Del()
|
|||
|
|
{
|
|||
|
|
if (delFlag == 0)
|
|||
|
|
{
|
|||
|
|
if (treeListStorageArea.FocusedNode.GetValue("STORAGE_ID") != null && treeListStorageArea.FocusedNode.GetValue("STORAGE_ID").ToString() != "0")
|
|||
|
|
{ //库区
|
|||
|
|
if (userData.ROLE_ID != "001" && storageAreaModel.EDIT == "0")//如果不可删除
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("该库区不可被删除");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
|
|||
|
|
string str = storageAreaModel.STORAGE_AREA_ID;
|
|||
|
|
if (!string.IsNullOrEmpty(str))
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("确定删除库区"))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
/*检测该库区下是否存在子库区,若有提示用户不能删除*/
|
|||
|
|
storageAreaModel = new StorageAreaModel();
|
|||
|
|
storageAreaModel.PARENT_ID = str;
|
|||
|
|
List<AreaGoodsTypeModel> areaGoodsTypeModels = new List<AreaGoodsTypeModel>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
listStorageAreaModel = IBussFactory<BussStorageArea>.Instance().GetAreaInfoDS(storageAreaModel, ref areaGoodsTypeModels);
|
|||
|
|
//如果有数据
|
|||
|
|
if (listStorageAreaModel.Count > 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("该库区下存在子库区,不能删除");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
/*检测该库区下是否存在库位,若有提示用户是否一并删除*/
|
|||
|
|
StorageAreaLocationModel storageAreaLocationModel = new StorageAreaLocationModel();
|
|||
|
|
storageAreaLocationModel.STORAGE_AREA_ID = str;
|
|||
|
|
List<LocAreaModel> locAreaModels = new List<LocAreaModel>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
List<StorageAreaLocationModel> modelList = new List<StorageAreaLocationModel>();
|
|||
|
|
//IBussFactory<BussStorageAreaLocation>.Instance().GetLocationInfoDS(storageAreaLocationModel, ref locAreaModels);
|
|||
|
|
|
|||
|
|
if (modelList.Count > 0)
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("该库区下存在库位,是否删除?(点击是将一并删除,点击否不进行任何操作)"))
|
|||
|
|
{
|
|||
|
|
errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
errText = IBussFactory<BussStorageArea>.Instance().DeleteAreaAndLocation(str);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if (string.IsNullOrEmpty(errText))
|
|||
|
|
//{
|
|||
|
|
// BindArea();
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{
|
|||
|
|
// SystemCommon.ShowInfoMessageBox("删除失败:" + errText);
|
|||
|
|
// return;
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//删除库区
|
|||
|
|
errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
errText = IBussFactory<BussStorageArea>.Instance().DeleteAreaInfo(str);//删除
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if (string.IsNullOrEmpty(errText))//如果成功
|
|||
|
|
//{
|
|||
|
|
// BindArea();
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{
|
|||
|
|
// SystemCommon.ShowInfoMessageBox("删除失败" + errText);
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("出错了" + ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择一条记录");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{//仓库
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
|
|||
|
|
string str = treeListStorageArea.FocusedNode.GetValue("STORAGE_AREA_ID").ToString();
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrEmpty(str))
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("确定删除仓库"))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
/*检测该仓库下是否存在库区(其中可能包含库位),若有提示用户是否一并删除*/
|
|||
|
|
/*得到该仓库下库区*/
|
|||
|
|
StorageAreaModel storageAreaModel = new StorageAreaModel();
|
|||
|
|
storageAreaModel.STORAGE_ID = str;
|
|||
|
|
List<AreaGoodsTypeModel> areaGoodsTypeModels = new List<AreaGoodsTypeModel>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
List<StorageAreaModel> storageAreaList = IBussFactory<BussStorageArea>.Instance().GetAreaInfoDS(storageAreaModel, ref areaGoodsTypeModels);
|
|||
|
|
|
|||
|
|
/*检测该仓库下是否存在库区*/
|
|||
|
|
if (storageAreaList.Count > 0)
|
|||
|
|
{
|
|||
|
|
//判断该仓库下库区是否允许被删除
|
|||
|
|
bool canDel = true;
|
|||
|
|
foreach (StorageAreaModel item in storageAreaList)
|
|||
|
|
{
|
|||
|
|
if (item.EDIT == "0")
|
|||
|
|
{
|
|||
|
|
canDel = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (canDel)
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("该仓库下存在库区(其中可能包含库位),是否删除?(点击是将一并删除,点击否不进行任何操作)"))
|
|||
|
|
{
|
|||
|
|
errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
errText = IBussFactory<BussStorageInfo>.Instance().DeleteStorageAndAreaAndLocation(str);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("该仓库下存在不可删除的库区,不可删除该仓库");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//删除仓库
|
|||
|
|
errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
errText = IBussFactory<BussStorageInfo>.Instance().DeleteStorageInfo(str);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择一条记录");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (delFlag == 1)
|
|||
|
|
{
|
|||
|
|
if (GVStorageAreaLocation.SelectedRowsCount > 0)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
|
|||
|
|
StorageAreaLocationModel storageAreaLocationModel = new StorageAreaLocationModel();
|
|||
|
|
storageAreaLocationModel = GVStorageAreaLocation.GetFocusedRow() as StorageAreaLocationModel;
|
|||
|
|
string str = storageAreaLocationModel.LOCATION_ID;
|
|||
|
|
if (!string.IsNullOrEmpty(str))
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("确定删除库位"))
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
errText = IBussFactory<BussStorageAreaLocation>.Instance().DeleteLocationInfo(storageAreaLocationModel.LOCATION_ID, storageAreaLocationModel.STORAGE_ID);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(errText))
|
|||
|
|
{
|
|||
|
|
BindLocation(storageAreaModel.STORAGE_ID,"");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("删除失败" + errText);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择一条记录");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("您未选择入库明细");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 库区进入
|
|||
|
|
private void treeListStorageArea_Enter(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
delFlag = 0;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 库位进入
|
|||
|
|
|
|||
|
|
private void GCStorageAreaLocation_Enter(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
delFlag = 1;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 自定义列显示事件
|
|||
|
|
/// <summary>
|
|||
|
|
/// 自定义列显示事件
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void GVStorageAreaLocation_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.Column.FieldName == "ABC_ID")
|
|||
|
|
{
|
|||
|
|
if (e.Value != null)
|
|||
|
|
{
|
|||
|
|
switch (e.Value.ToString().Trim())
|
|||
|
|
{
|
|||
|
|
case "0":
|
|||
|
|
e.DisplayText = "A级别";
|
|||
|
|
break;
|
|||
|
|
case "1":
|
|||
|
|
e.DisplayText = "B级别";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
e.DisplayText = "C级别";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 批量打印选中的库位的条码
|
|||
|
|
public void PrintBarCode()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (DialogResult.No == SystemCommon.ShowMessageBoxResult("是否打印选中的库位条码"))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
List<StorageAreaLocationModel> listLoc = new List<StorageAreaLocationModel>();
|
|||
|
|
|
|||
|
|
foreach (int handle in GVStorageAreaLocation.GetSelectedRows())
|
|||
|
|
{
|
|||
|
|
StorageAreaLocationModel loc = new StorageAreaLocationModel();
|
|||
|
|
loc = GVStorageAreaLocation.GetRow(handle) as StorageAreaLocationModel;
|
|||
|
|
listLoc.Add(loc);
|
|||
|
|
}
|
|||
|
|
if (listLoc.Count == 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择库位");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int count = 0;
|
|||
|
|
foreach (var item in listLoc)
|
|||
|
|
{
|
|||
|
|
//BarCodeReport.GetInstance(item.LOCATION_ID, 7).Print();
|
|||
|
|
count++;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SystemCommon.ShowInfoMessageBox("您选择了" + listLoc.Count + "条库位," + count + "条打印成功");
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void btnConfirm_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if(t_kq.Text.Trim().Length==0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("选择库区");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if(listStorageAreaLocationModel.Count==0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("选择库位");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string areaId = t_kq.Tag.ToString();
|
|||
|
|
LoadForm load = new LoadForm();
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 0);
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在导入请稍候....");
|
|||
|
|
LocAreaModel m = new LocAreaModel();
|
|||
|
|
|
|||
|
|
foreach (StorageAreaLocationModel modleLoc in listStorageAreaLocationModel)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
m.LOCATION_ID = modleLoc.LOCATION_ID;
|
|||
|
|
m.STORAGE_AREA_ID = areaId;
|
|||
|
|
IBussFactory<BussStorageAreaLocation>.Instance().InsertLocArea(m);
|
|||
|
|
}
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|||
|
|
SystemCommon.ShowInfoMessageBox("更新完成");
|
|||
|
|
BindLocation(storageAreaModel.STORAGE_ID,"");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ctrlButtons1_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void GVStorageAreaLocation_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
|
|||
|
|
{
|
|||
|
|
DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
|
|||
|
|
if (e.RowHandle >= 0)
|
|||
|
|
{
|
|||
|
|
string category = view.GetRowCellDisplayText(e.RowHandle, "STATUS");
|
|||
|
|
if (category == "有货")
|
|||
|
|
{
|
|||
|
|
e.Appearance.BackColor = Color.Blue;
|
|||
|
|
}
|
|||
|
|
else if (category == "正常")
|
|||
|
|
{
|
|||
|
|
e.Appearance.BackColor = Color.YellowGreen;
|
|||
|
|
}
|
|||
|
|
//else if (category == "1")
|
|||
|
|
//{
|
|||
|
|
// e.Appearance.BackColor = Color.MediumSlateBlue;
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|