334 lines
11 KiB
C#
334 lines
11 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 WMS.Business;
|
|||
|
|
using WMS.Business.Base;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmBaseData
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 窗体:库区信息编辑
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class FrmStorageAreaHandle : FormBase
|
|||
|
|
{
|
|||
|
|
#region 变量
|
|||
|
|
public StorageAreaModel storageAreaModel = new StorageAreaModel();
|
|||
|
|
public List<AreaGoodsTypeModel> areaGoodsTypeList = new List<AreaGoodsTypeModel>();
|
|||
|
|
private int flag = -1;//0:新增;1:修改
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 初始化
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 构造函数 用于新增
|
|||
|
|
/// </summary>
|
|||
|
|
public FrmStorageAreaHandle()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
flag = 0;
|
|||
|
|
|
|||
|
|
lueStorage.LoadData();
|
|||
|
|
lueParentId.LoadData();
|
|||
|
|
|
|||
|
|
//库区 可选择无父库区
|
|||
|
|
//DataTable dt = lueParentId.Properties.DataSource as DataTable;
|
|||
|
|
//DataRow dr = dt.NewRow();
|
|||
|
|
//dt.Rows.Add(dr);
|
|||
|
|
//lueParentId.Properties.DataSource = dt;
|
|||
|
|
|
|||
|
|
//bsStorageAreaEdit.DataSource = storageAreaModel;
|
|||
|
|
|
|||
|
|
storageAreaModel.STATUS = "正常";
|
|||
|
|
storageAreaModel.EDIT = "0";
|
|||
|
|
|
|||
|
|
bsAreaGoodsType.DataSource = areaGoodsTypeList;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 构造函数 用于修改
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="StorageArea"></param>
|
|||
|
|
public FrmStorageAreaHandle(StorageAreaModel storageArea)
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
flag = 1;
|
|||
|
|
storageAreaModel = storageArea;
|
|||
|
|
|
|||
|
|
lueStorage.LoadData();
|
|||
|
|
lueParentId.LoadData();
|
|||
|
|
//库区 可选择无父库区
|
|||
|
|
DataTable dt = lueParentId.Properties.DataSource as DataTable;
|
|||
|
|
DataRow dr = dt.NewRow();
|
|||
|
|
dt.Rows.Add(dr);
|
|||
|
|
lueParentId.Properties.DataSource = dt;
|
|||
|
|
if (storageAreaModel != null)
|
|||
|
|
{
|
|||
|
|
bsStorageAreaEdit.DataSource = storageAreaModel;
|
|||
|
|
lueStorage.EditValue = storageAreaModel.STORAGE_ID;
|
|||
|
|
}
|
|||
|
|
//查询库区商品分类关系
|
|||
|
|
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
IBussFactory<BussStorageArea>.Instance().GetAreaInfoDS(storageAreaModel, ref areaGoodsTypeList);
|
|||
|
|
if (areaGoodsTypeList != null)
|
|||
|
|
{
|
|||
|
|
bsAreaGoodsType.DataSource = areaGoodsTypeList;
|
|||
|
|
treeListGoodsType.RefreshDataSource();
|
|||
|
|
treeListGoodsType.ExpandAll();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// load
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void FrmStorageAreaHandle_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
lueStorage.EditValue = storageAreaModel.STORAGE_ID;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 按钮事件
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 确定按钮
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void ctrlButtons1_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
btnConfirm.Focus();
|
|||
|
|
|
|||
|
|
//非空验证
|
|||
|
|
if (string.IsNullOrEmpty(txtAreaName.Text.Trim()))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请输入库区名称");
|
|||
|
|
txtAreaName.Focus();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(lueStorage.Text))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择仓库");
|
|||
|
|
lueStorage.Focus();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
//if (string.IsNullOrEmpty(rgEdit.Text))
|
|||
|
|
//{
|
|||
|
|
// SystemCommon.ShowInfoMessageBox("请选择是否可编辑");
|
|||
|
|
// rgEdit.Focus();
|
|||
|
|
// return;
|
|||
|
|
//}
|
|||
|
|
//if (string.IsNullOrEmpty(rgStatus.Text))
|
|||
|
|
//{
|
|||
|
|
// SystemCommon.ShowInfoMessageBox("请选择状态");
|
|||
|
|
// rgStatus.Focus();
|
|||
|
|
// return;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
StorageAreaModel model = storageAreaModel;
|
|||
|
|
model.OPERATORID = userData.USER_ID;//操作人
|
|||
|
|
|
|||
|
|
if (rgStatus.Text == "正常")
|
|||
|
|
{
|
|||
|
|
model.STATUS = "0";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
model.STATUS = "1";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (flag == 1)//修改
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
LoadForm load = new LoadForm();
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 0);
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在处理数据....");
|
|||
|
|
errText = IBussFactory<BussStorageArea>.Instance().InsOrUpdAreaInfo(model, 1, areaGoodsTypeList);
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|||
|
|
if (string.IsNullOrEmpty(errText))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("修改成功");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("修改失败" + errText);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if (flag == 0)//新增
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
LoadForm load = new LoadForm();
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 0);
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在处理数据....");
|
|||
|
|
errText =IBussFactory<BussStorageArea>.Instance().InsOrUpdAreaInfo(model, 0, areaGoodsTypeList);
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(errText))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("新增成功");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("新增失败" + errText);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
this.Close();
|
|||
|
|
this.Dispose();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 退出按钮
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void ctrlButtons2_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes != SystemCommon.ShowMessageBoxResult("确定放弃正在编辑的数据?"))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
this.Close();
|
|||
|
|
this.Dispose();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
private void lueStorage_EditValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(lueStorage.Properties.ValueMember) && lueStorage.EditValue != null && !string.IsNullOrEmpty(lueStorage.EditValue.ToString()))
|
|||
|
|
{
|
|||
|
|
//绑定库区数据
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
|
|||
|
|
StorageAreaModel storageAreaModel = new StorageAreaModel();
|
|||
|
|
storageAreaModel.STORAGE_ID = lueStorage.EditValue.ToString();
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
List<StorageAreaModel> strResult = IBussFactory<BussStorageArea>.Instance().GetAreaInfoDS(storageAreaModel);
|
|||
|
|
if (strResult != null)
|
|||
|
|
{
|
|||
|
|
lueParentId.Properties.DataSource = strResult;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ctrlDicGoodsType_Button_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (ctrlDicGoodsType.SelectTable.Rows.Count == 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
List<GoodsTypeModel> typeList = ConvertHelper<GoodsTypeModel>.ConvertToList(ctrlDicGoodsType.SelectTable);
|
|||
|
|
|
|||
|
|
foreach (GoodsTypeModel item in typeList)
|
|||
|
|
{
|
|||
|
|
if (areaGoodsTypeList.Exists(p => p.GOODS_TYPE_ID == item.GOODS_TYPE_ID))
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AreaGoodsTypeModel areaGoodsTypeModel = new AreaGoodsTypeModel();
|
|||
|
|
areaGoodsTypeModel.PARENT_ID = item.PARENT_ID;
|
|||
|
|
areaGoodsTypeModel.AREA_ID = storageAreaModel.STORAGE_AREA_ID;
|
|||
|
|
areaGoodsTypeModel.STORAGE_AREA_NAME = storageAreaModel.STORAGE_AREA_NAME;
|
|||
|
|
areaGoodsTypeModel.GOODS_TYPE_ID = item.GOODS_TYPE_ID;
|
|||
|
|
areaGoodsTypeModel.GOODS_TYPE_NAME = item.GOODS_TYPE_NAME;
|
|||
|
|
|
|||
|
|
areaGoodsTypeList.Add(areaGoodsTypeModel);
|
|||
|
|
}
|
|||
|
|
bsAreaGoodsType.DataSource = areaGoodsTypeList;
|
|||
|
|
//treeListGoodsType.DataSource = bsAreaGoodsType;
|
|||
|
|
treeListGoodsType.RefreshDataSource();
|
|||
|
|
treeListGoodsType.ExpandAll();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string goodsTypeID = string.Empty;
|
|||
|
|
private void btnDel_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (treeListGoodsType.FocusedNode != null)
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("确定删除"))
|
|||
|
|
{
|
|||
|
|
areaGoodsTypeList.RemoveAll(p=>p.GOODS_TYPE_ID == goodsTypeID);
|
|||
|
|
|
|||
|
|
bsAreaGoodsType.DataSource = areaGoodsTypeList;
|
|||
|
|
treeListGoodsType.RefreshDataSource();
|
|||
|
|
treeListGoodsType.ExpandAll();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("您未选择要删除的商品分类");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
private void treeListGoodsType_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.Node == null)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
if (e.Node["GOODS_TYPE_ID"] != null)
|
|||
|
|
{
|
|||
|
|
goodsTypeID = e.Node["GOODS_TYPE_ID"].ToString();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ctrlDictonary1_Button_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|