423 lines
13 KiB
C#
423 lines
13 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.Model.SystemManage;
|
|||
|
|
using WMS.Base.WebService;
|
|||
|
|
using WMS.Common;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmBaseData
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
public partial class FrmUpStrategyDet : FormBase
|
|||
|
|
{
|
|||
|
|
#region 变量
|
|||
|
|
/// <summary>
|
|||
|
|
/// 上架策略编号
|
|||
|
|
/// </summary>
|
|||
|
|
static string strategyID = string.Empty;
|
|||
|
|
|
|||
|
|
public static string StrategyID
|
|||
|
|
{
|
|||
|
|
get { return strategyID; }
|
|||
|
|
set { strategyID = value; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 仓库实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
List<StorageInfoModel> listStorageInfoModel = new List<StorageInfoModel>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 地区实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
List<StorageAreaModel> listStorageAreaModel = new List<StorageAreaModel>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 字典信息
|
|||
|
|
/// </summary>
|
|||
|
|
List<DictionaryTabModel> listDictionaryTabModel = new List<DictionaryTabModel>();
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 构造方法
|
|||
|
|
public FrmUpStrategyDet()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 窗体实例化
|
|||
|
|
private static FrmUpStrategyDet Frm;
|
|||
|
|
//窗体标记 0新增 1修改 2查看
|
|||
|
|
private static int iFlag;
|
|||
|
|
|
|||
|
|
private static int IFlag
|
|||
|
|
{
|
|||
|
|
get { return FrmUpStrategyDet.iFlag; }
|
|||
|
|
set { FrmUpStrategyDet.iFlag = value; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static FrmUpStrategyDet Instance(int iflag)
|
|||
|
|
{
|
|||
|
|
if (Frm == null || Frm.IsDisposed)
|
|||
|
|
{
|
|||
|
|
IFlag = iflag;
|
|||
|
|
Frm = new FrmUpStrategyDet();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Frm;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 窗体加载
|
|||
|
|
/// <summary>
|
|||
|
|
/// 窗体加载
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void FrmUpStrategyDet_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
DataLoad();
|
|||
|
|
|
|||
|
|
//1修改 2查看
|
|||
|
|
if (IFlag == 1 || IFlag == 2)
|
|||
|
|
{
|
|||
|
|
GetUpStrategy();
|
|||
|
|
|
|||
|
|
if (IFlag == 2)
|
|||
|
|
{
|
|||
|
|
ctrlButtons1.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据加载
|
|||
|
|
/// <summary>
|
|||
|
|
/// 数据加载
|
|||
|
|
/// </summary>
|
|||
|
|
private void DataLoad()
|
|||
|
|
{
|
|||
|
|
string errText = "";
|
|||
|
|
string strStorageInfo = WebLockConfig.Instance.StorageInfo.GetStorageInfoDS("", ref errText);
|
|||
|
|
listStorageInfoModel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StorageInfoModel>>(strStorageInfo);
|
|||
|
|
storageInfoModelBindingSource.DataSource = listStorageInfoModel;
|
|||
|
|
|
|||
|
|
string strDictionaryTabModel = WebLockConfig.Instance.DictionaryTab.GetDictionaryTab("strategy_status", ref errText);
|
|||
|
|
listDictionaryTabModel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DictionaryTabModel>>(strDictionaryTabModel);
|
|||
|
|
dictionaryTabModelBindingSource.DataSource = listDictionaryTabModel;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 获取上架策略信息
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取上架策略信息
|
|||
|
|
/// </summary>
|
|||
|
|
private void GetUpStrategy()
|
|||
|
|
{
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
string strUpStrategy = WebLockConfig.Instance.WebUpStrategy.GetUpStrategy("", "", StrategyID, ref errText);
|
|||
|
|
DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(strUpStrategy);
|
|||
|
|
if (dt != null && dt.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
//上架策略名称
|
|||
|
|
if (dt.Rows[0]["UPSTRATEGY_NAME"] != null && dt.Rows[0]["UPSTRATEGY_NAME"].ToString() != "")
|
|||
|
|
{
|
|||
|
|
txtStartegyName.Text = dt.Rows[0]["UPSTRATEGY_NAME"].ToString();
|
|||
|
|
}
|
|||
|
|
//上架策略状态
|
|||
|
|
if (dt.Rows[0]["UPSTRATEGY_STATE"] != null && dt.Rows[0]["UPSTRATEGY_STATE"].ToString() != "")
|
|||
|
|
{
|
|||
|
|
LueState.EditValue = dt.Rows[0]["UPSTRATEGY_STATE"].ToString();
|
|||
|
|
}
|
|||
|
|
//仓库
|
|||
|
|
if (dt.Rows[0]["STORAGE_ID"] != null && dt.Rows[0]["STORAGE_ID"].ToString() != "")
|
|||
|
|
{
|
|||
|
|
// LueStorage.EditValue = dt.Rows[0]["STORAGE_ID"].ToString();
|
|||
|
|
if (dt.Rows[0]["STORAGE_ID"] != null && dt.Rows[0]["STORAGE_ID"].ToString() != "")
|
|||
|
|
{
|
|||
|
|
GetStorageArea(dt.Rows[0]["STORAGE_ID"].ToString());
|
|||
|
|
}
|
|||
|
|
//库区
|
|||
|
|
if (dt.Rows[0]["STORAGE_AREA_ID"] != null && dt.Rows[0]["STORAGE_AREA_ID"].ToString() != "")
|
|||
|
|
{
|
|||
|
|
// LueArea.EditValue = dt.Rows[0]["STORAGE_AREA_ID"].ToString();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//种类
|
|||
|
|
if (dt.Rows[0]["KINDS_FLAG"].ToString() == "1")
|
|||
|
|
{
|
|||
|
|
rbZLTrue.Checked = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
rbZLFlase.Checked = true;
|
|||
|
|
}
|
|||
|
|
//批次
|
|||
|
|
if (dt.Rows[0]["BATCH_FLAG"].ToString() == "1")
|
|||
|
|
{
|
|||
|
|
rbPCTrue.Checked = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
rbPCFlase.Checked = true;
|
|||
|
|
}
|
|||
|
|
//容积
|
|||
|
|
if (dt.Rows[0]["VOLUME_FLAG"].ToString() == "1")
|
|||
|
|
{
|
|||
|
|
rbRJTrue.Checked = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
rbRJFlase.Checked = true;
|
|||
|
|
}
|
|||
|
|
//承重
|
|||
|
|
if (dt.Rows[0]["WEIGHT_FLAG"].ToString() == "1")
|
|||
|
|
{
|
|||
|
|
rbCZTrue.Checked = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
rbCZFlase.Checked = true;
|
|||
|
|
}
|
|||
|
|
//库位
|
|||
|
|
if (dt.Rows[0]["LOCATION_FLAG"].ToString() == "1")
|
|||
|
|
{
|
|||
|
|
rbKWTrue.Checked = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
rbKWFlase.Checked = true;
|
|||
|
|
}
|
|||
|
|
//备注
|
|||
|
|
if (dt.Rows[0]["REMARK"]!=null && dt.Rows[0]["REMARK"].ToString() != "")
|
|||
|
|
{
|
|||
|
|
txtRemark.Text = dt.Rows[0]["REMARK"].ToString();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 按钮事件
|
|||
|
|
/// <summary>
|
|||
|
|
/// 确定
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void ctrlButtons1_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (Validation())
|
|||
|
|
{
|
|||
|
|
AddOrUpdateUpStrategy();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 关闭
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void ctrlButtons2_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
FrmClose();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 验证
|
|||
|
|
/// <summary>
|
|||
|
|
/// 验证
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private bool Validation()
|
|||
|
|
{
|
|||
|
|
if (txtStartegyName.Text.Trim() == "")
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox("请输入上架策略名称!");
|
|||
|
|
txtStartegyName.Focus();
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (LueState.Text == "")
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox("请选择上架策略状态!");
|
|||
|
|
LueState.Focus();
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if (LueStorage.Text == "")
|
|||
|
|
//{
|
|||
|
|
// SystemCommon.ShowErrorMessageBox("请选择仓库!");
|
|||
|
|
// LueStorage.Focus();
|
|||
|
|
// return false;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//if (LueArea.Text == "")
|
|||
|
|
//{
|
|||
|
|
// SystemCommon.ShowErrorMessageBox("请选择库区!");
|
|||
|
|
// LueArea.Focus();
|
|||
|
|
// return false;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 新增修改上架策略
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新增修改上架策略
|
|||
|
|
/// </summary>
|
|||
|
|
private void AddOrUpdateUpStrategy()
|
|||
|
|
{
|
|||
|
|
UpStrategyModel model = SetUpStrategyModel();
|
|||
|
|
string strUpStrategyModel = Newtonsoft.Json.JsonConvert.SerializeObject(model);
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
if (IFlag == 0)
|
|||
|
|
{
|
|||
|
|
WebLockConfig.Instance.WebUpStrategy.AddUpStrategy(strUpStrategyModel, ref errText);
|
|||
|
|
}
|
|||
|
|
else if (IFlag == 1)
|
|||
|
|
{
|
|||
|
|
WebLockConfig.Instance.WebUpStrategy.UpdateUpStrategy(strUpStrategyModel, ref errText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (errText != "")
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox(errText);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|||
|
|
Close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 设置实体
|
|||
|
|
/// <summary>
|
|||
|
|
/// 设置实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private UpStrategyModel SetUpStrategyModel()
|
|||
|
|
{
|
|||
|
|
UpStrategyModel model = new UpStrategyModel();
|
|||
|
|
//上架策略编号
|
|||
|
|
if (IFlag == 1)
|
|||
|
|
{
|
|||
|
|
model.UPSTRATEGY_ID = StrategyID;
|
|||
|
|
model.UPDATE_MAN = userData.USERNAME;
|
|||
|
|
model.UPDATE_DATE = DateTime.Now;
|
|||
|
|
}
|
|||
|
|
//上架策略名称
|
|||
|
|
model.UPSTRATEGY_NAME = txtStartegyName.Text;
|
|||
|
|
//上架策略状态
|
|||
|
|
model.UPSTRATEGY_STATE = LueState.EditValue.ToString();
|
|||
|
|
//model.STORAGE_ID = LueStorage.EditValue.ToString();
|
|||
|
|
//model.STORAGE_AREA_ID = LueArea.EditValue.ToString();
|
|||
|
|
//承重
|
|||
|
|
if (rbCZTrue.Checked)
|
|||
|
|
{
|
|||
|
|
model.WEIGHT_FLAG = "1";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
model.WEIGHT_FLAG = "0";
|
|||
|
|
}
|
|||
|
|
//库位
|
|||
|
|
if (rbKWTrue.Checked)
|
|||
|
|
{
|
|||
|
|
model.LOCATION_FLAG = "1";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
model.LOCATION_FLAG = "0";
|
|||
|
|
}
|
|||
|
|
//容积
|
|||
|
|
if (rbRJTrue.Checked)
|
|||
|
|
{
|
|||
|
|
model.VOLUME_FLAG = "1";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
model.VOLUME_FLAG = "0";
|
|||
|
|
}
|
|||
|
|
//种类
|
|||
|
|
if (rbZLTrue.Checked)
|
|||
|
|
{
|
|||
|
|
model.KINDS_FLAG = "1";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
model.KINDS_FLAG = "0";
|
|||
|
|
}
|
|||
|
|
//批次
|
|||
|
|
if (rbPCTrue.Checked)
|
|||
|
|
{
|
|||
|
|
model.BATCH_FLAG = "1";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
model.BATCH_FLAG = "0";
|
|||
|
|
}
|
|||
|
|
model.REMARK = txtRemark.Text;
|
|||
|
|
|
|||
|
|
if (IFlag == 0)
|
|||
|
|
{
|
|||
|
|
model.CREATE_MAN = userData.USERNAME;
|
|||
|
|
model.CREATE_DATE = DateTime.Now;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return model;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 选择仓库事件
|
|||
|
|
/// <summary>
|
|||
|
|
/// 仓库变化后关联库区
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void LueStorage_EditValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
// GetStorageArea(LueStorage.EditValue.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据仓库编号获取库区
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="strStorageId"></param>
|
|||
|
|
private void GetStorageArea(string strStorageId)
|
|||
|
|
{
|
|||
|
|
StorageAreaModel model = new StorageAreaModel();
|
|||
|
|
model.STORAGE_ID = strStorageId;
|
|||
|
|
string AreaInfo = Newtonsoft.Json.JsonConvert.SerializeObject(model);
|
|||
|
|
string errText = "";
|
|||
|
|
string strAreaInfo = WebLockConfig.Instance.StorageArea.GetAreaInfoDS(AreaInfo, ref errText);
|
|||
|
|
listStorageAreaModel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StorageAreaModel>>(strAreaInfo);
|
|||
|
|
storageAreaModelBindingSource.DataSource = listStorageAreaModel;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 关闭
|
|||
|
|
/// <summary>
|
|||
|
|
/// 关闭
|
|||
|
|
/// </summary>
|
|||
|
|
private void FrmClose()
|
|||
|
|
{
|
|||
|
|
this.Close();
|
|||
|
|
this.Dispose();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
private void gridControlCustom1_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|