310 lines
11 KiB
C#
310 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.SystemManage;
|
||
using WMS.Business.Base;
|
||
|
||
namespace WMS.FrmBaseData
|
||
{
|
||
/// <summary>
|
||
/// 窗体:库位编辑
|
||
/// </summary>
|
||
public partial class FrmStorageAreaLocationHandle : FormBase
|
||
{
|
||
#region 变量
|
||
public StorageAreaLocationModel storageAreaLocationModel = new StorageAreaLocationModel();
|
||
|
||
public List<string> compareLocAreaList = new List<string>();
|
||
/// <summary>
|
||
/// 0:新增;1:修改;2:批量修改;3:批量新增
|
||
/// </summary>
|
||
private int flag = -1;
|
||
private int len = 0;
|
||
#endregion
|
||
|
||
#region 初始化
|
||
public FrmStorageAreaLocationHandle()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
List<StorageAreaLocationModel> listLocData = new List<StorageAreaLocationModel>();
|
||
public FrmStorageAreaLocationHandle(List<StorageAreaLocationModel> listLoc)
|
||
{
|
||
InitializeComponent();
|
||
txtStartID.Text = listLoc[0].LOCATION_ID;
|
||
txtEndID.Text= listLoc[listLoc.Count-1].LOCATION_ID;
|
||
listLocData = listLoc;
|
||
}
|
||
/// <summary>
|
||
/// 带五参构造,批量修改
|
||
/// </summary>
|
||
/// <param name="storageAreaLocation"></param>
|
||
public FrmStorageAreaLocationHandle(string row, string ls, string lend, string cs, string cend, string start, string end, StorageAreaLocationModel locData,int flage)
|
||
{
|
||
InitializeComponent();
|
||
storageAreaLocationModel.STATUS = "正常";
|
||
storageAreaLocationModel.ISLOCK = "否";
|
||
flag = flage;
|
||
txtPai.Text = row.ToString();
|
||
txtEndID.Text = end.ToString();
|
||
txtStartID.Text = start.ToString();
|
||
txtCengEnd.Text = cend;
|
||
t_lieEnd.Text = lend;
|
||
txtEndID.Text = end;
|
||
txtLie.Text = ls;
|
||
txtCeng.Text = cs;
|
||
txtEndID.Text = end;
|
||
storageAreaLocationModel = locData;
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// load
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void FrmStorageAreaLocationHandle_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
lueAbc_id.LoadData();
|
||
lueStorage.LoadData();
|
||
if (storageAreaLocationModel != null)
|
||
{
|
||
lueStorage.EditValue = storageAreaLocationModel.STORAGE_ID;
|
||
bsStorageAreaLocation.DataSource = storageAreaLocationModel;
|
||
ctrlDicArea.TextBoxValue = storageAreaLocationModel.STORAGE_AREA_ID;
|
||
ctrlDicArea.SqlStr = " where STORAGE_ID='" + storageAreaLocationModel.STORAGE_ID + "' ";
|
||
}
|
||
// bsLocArea.DataSource = locAreaList;
|
||
GVLocArea.RefreshData();
|
||
}
|
||
#endregion
|
||
|
||
#region 按钮事件
|
||
|
||
/// <summary>
|
||
/// 确定 保存
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void ctrlButtons1_Click(object sender, EventArgs e)
|
||
{
|
||
btnConfirm.Focus();//切换焦点,确保 正在编辑的控件(如TextBox)的值为编辑后的
|
||
|
||
StorageAreaLocationModel model = storageAreaLocationModel;
|
||
if (rgIsLock.Text == "否")
|
||
{
|
||
model.ISLOCK = "0";
|
||
}
|
||
else
|
||
{
|
||
model.ISLOCK = "1";
|
||
}
|
||
if (rgStatus.Text == "正常")
|
||
{
|
||
model.STATUS = "0";
|
||
}
|
||
else
|
||
{
|
||
model.STATUS = "1";
|
||
}
|
||
model.OPERATORID = userData.USER_ID;//操作人
|
||
if (flag == 1)//修改
|
||
{
|
||
|
||
string errText = string.Empty;
|
||
try
|
||
{
|
||
for (int i = int.Parse(txtLie.Text); i <= int.Parse(t_lieEnd.Text); i++)
|
||
{
|
||
for (int j = int.Parse(txtCeng.Text); j <= int.Parse(txtCengEnd.Text); j++)
|
||
{
|
||
string locTxt = txtPai.Text.PadLeft(2, '0') + i.ToString().PadLeft(3, '0') + j.ToString().PadLeft(2, '0');
|
||
StorageAreaLocationModel loc = new StorageAreaLocationModel();
|
||
loc.LOCATION_ID = locTxt;
|
||
loc.STORAGE_ID = lueStorage.EditValue.ToString();
|
||
loc.LOCATION_HEIGHT =decimal.Parse( txtLong.Text);
|
||
loc.LOCATION_LONG= decimal.Parse(txtLong.Text);
|
||
loc.LOCATION_WIDTH = decimal.Parse(txtWitdh.Text);
|
||
loc.VOLUME = decimal.Parse(txtVolume.Text);
|
||
loc.BEARWEIGHT = decimal.Parse(txtBearWeight.Text);
|
||
IBussFactory<BussStorageAreaLocation>.Instance().UpdateLoc(loc);
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
catch (Exception)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
/// <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
|
||
|
||
|
||
|
||
#region 改变仓库后 库区只显示该仓库的所有库区
|
||
/// <summary>
|
||
/// 改变仓库后 库区只显示该仓库的所有库区
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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();
|
||
|
||
List<AreaGoodsTypeModel> areaGoodsTypeModels = new List<AreaGoodsTypeModel>();
|
||
|
||
string strResult = string.Empty;
|
||
try
|
||
{
|
||
IBussFactory<BussStorageArea>.Instance().GetAreaInfoDS(storageAreaModel, ref areaGoodsTypeModels);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
||
}
|
||
|
||
////如果查询库区数据成功
|
||
//if (errText == string.Empty)
|
||
//{
|
||
// ctrlDicArea.SqlStr = "where storage_id = '" + lueStorage.Properties.KeyValue.ToString() + "'";
|
||
//}
|
||
//else
|
||
//{
|
||
// SystemCommon.ShowInfoMessageBox(errText);
|
||
//}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
private void ctrlDicArea_Button_Click(object sender, EventArgs e)
|
||
{
|
||
if (ctrlDicArea.SelectTable.Rows.Count == 0)
|
||
{
|
||
//SystemCommon.ShowInfoMessageBox("您未选择库区!");
|
||
return;
|
||
}
|
||
//库区集合
|
||
List<StorageAreaModel> areaList = ConvertHelper<StorageAreaModel>.ConvertToList(ctrlDicArea.SelectTable);
|
||
|
||
foreach (StorageAreaModel item in areaList)
|
||
{
|
||
LocAreaModel locAreaModel = new LocAreaModel();
|
||
locAreaModel.LOCATION_ID = storageAreaLocationModel.LOCATION_ID;
|
||
locAreaModel.STORAGE_AREA_ID = item.STORAGE_AREA_ID;
|
||
locAreaModel.STORAGE_AREA_NAME = item.STORAGE_AREA_NAME;
|
||
locAreaModel.STORAGE_ID = item.STORAGE_ID;
|
||
locAreaList.Add(locAreaModel);
|
||
}
|
||
bsLocArea.DataSource = locAreaList;
|
||
GVLocArea.RefreshData();
|
||
}
|
||
|
||
private void btnDel_Click(object sender, EventArgs e)
|
||
{
|
||
if (GVLocArea.SelectedRowsCount > 0)
|
||
{
|
||
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("确定删除"))
|
||
{
|
||
LocAreaModel locAreaModel = new LocAreaModel();
|
||
locAreaModel = GVLocArea.GetFocusedRow() as LocAreaModel;
|
||
locAreaList.Remove(locAreaModel);
|
||
GVLocArea.RefreshData();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("您未选择要删除的库区");
|
||
}
|
||
}
|
||
|
||
List<LocAreaModel> locAreaList = new List<LocAreaModel>();
|
||
private void ctrlButtons1_Click_1(object sender, EventArgs e)
|
||
{
|
||
if(lueStorage.EditValue.ToString()=="")
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("选择仓库");
|
||
return;
|
||
}
|
||
if(GVLocArea.RowCount==0)
|
||
{
|
||
return;
|
||
}
|
||
List<LocAreaModel> addData = new List<LocAreaModel>();
|
||
if (listLocData.Count>0)
|
||
{
|
||
foreach (StorageAreaLocationModel locID in listLocData)
|
||
{
|
||
foreach (LocAreaModel locM in locAreaList)
|
||
{
|
||
LocAreaModel loc = new LocAreaModel();
|
||
loc.LOCATION_ID = locID.LOCATION_ID;
|
||
loc.STORAGE_AREA_ID = locM.STORAGE_AREA_ID;
|
||
loc.STORAGE_ID = lueStorage.EditValue.ToString();// locM.STORAGE_ID;
|
||
addData.Add(loc);
|
||
}
|
||
}
|
||
}
|
||
|
||
else
|
||
{
|
||
for (int i = int.Parse(txtLie.Text); i <= int.Parse(t_lieEnd.Text); i++)
|
||
{
|
||
for (int j = int.Parse(txtCeng.Text); j <= int.Parse(txtCengEnd.Text); j++)
|
||
{
|
||
|
||
string locTxt = txtPai.Text.PadLeft(2, '0') + i.ToString().PadLeft(3, '0') + j.ToString().PadLeft(2, '0');
|
||
foreach (LocAreaModel locM in locAreaList)
|
||
{
|
||
LocAreaModel loc = new LocAreaModel();
|
||
loc.LOCATION_ID = locTxt;
|
||
loc.STORAGE_AREA_ID = locM.STORAGE_AREA_ID;
|
||
loc.STORAGE_ID = lueStorage.EditValue.ToString();// locM.STORAGE_ID;
|
||
addData.Add(loc);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
IBussFactory<BussStorageAreaLocation>.Instance().InsertLocAreaList(addData);
|
||
}
|
||
}
|
||
}
|