BaoKai_202508_Wms_Jingwang_.../WMS.FrmStrategy/FrmUpStrategyDet.cs
2025-08-24 21:52:42 +08:00

878 lines
25 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.Common;
using WMS.Model.Strategy;
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraEditors;
using DevExpress.XtraTreeList.Nodes;
using WMS.Business;
using WMS.Business.Base;
using WMS.Business.SystemManage;
using WMS.Business.Strategy;
namespace WMS.FrmStrategy
{
public partial class FrmUpStrategyDet : FormBase
{
#region
/// <summary>
/// 上架策略编号
/// </summary>
private string strategyID = string.Empty;
public 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>();
/// <summary>
/// 上架策略明细集合
/// </summary>
List<UpStrateyCtsModel> list_upCtsModel = new List<UpStrateyCtsModel>();
/// <summary>
/// 上架策略明细
/// </summary>
UpStrateyCtsModel upCtsModel = new UpStrateyCtsModel();
/// <summary>
/// 库位编号
/// </summary>
List<StorageAreaLocationModel> storageLocation = new List<StorageAreaLocationModel>();
#endregion
/// <summary>
/// 窗体标记 0 查看 1新增 2修改
/// </summary>
string frmFlag = "0";
/// <summary>
/// 新增策略时 判断是否新增成功
/// </summary>
bool bol = false;
#region
public FrmUpStrategyDet(string flag)
{
InitializeComponent();
frmFlag = flag;
}
#endregion
#region
/// <summary>
/// 明细条件
/// </summary>
DataTable StatusStyType = new DataTable();
/// <summary>
/// 库位条件
/// </summary>
DataTable StatusSty = new DataTable();
/// <summary>
/// 窗体加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FrmUpStrategyDet_Load(object sender, EventArgs e)
{
if (frmFlag == "0")
{
foreach (Control ctr in this.splitContainerControl1.Panel1.Controls)
{
if (!ctr.Name.GetType().ToString().ToLower().Contains("label"))
{
ctr.Enabled = false;
}
}
rgtLookLogic.Enabled = false;
kqTreeList.Enabled = false;
}
if (frmFlag == "1")
{
saveStyButton.Enabled = false;
}
StatusStyType.Columns.Clear();
StatusSty.Columns.Clear();
DataLoad();
// 1新增 2修改
if (frmFlag == "2" || frmFlag == "0")
{
GetUpStrategy();
if (frmFlag == "2")
{
saveButton.Enabled = false;
}
}
bdgCtsStgy.DataSource = strateyModel;
}
private void SetCheckedChildNodes(TreeListNode node, CheckState check)
{
for (int i = 0; i < node.Nodes.Count; i++)
{
node.Nodes[i].CheckState = check;
SetCheckedChildNodes(node.Nodes[i], check);
}
}
#endregion
/// <summary>
/// 商品类型
/// </summary>
List<GoodsTypeModel> goodsType = new List<GoodsTypeModel>();
/// <summary>
/// 供应商类型
/// </summary>
List<DictionaryTabModel> provideType = new List<DictionaryTabModel>();
#region
/// <summary>
/// 数据加载
/// </summary>
private void DataLoad()
{
string errText = "";
try
{
StorageInfoModel mod = new StorageInfoModel();
#region
listStorageInfoModel = IBussFactory<BussStorageInfo>.Instance().GetStorageInfoDS(mod);
if (errText.Trim().Length > 0)
{
SystemCommon.ShowInfoMessageBox(errText);
return;
}
if (listStorageInfoModel != null)
{
storageInfoModelBindingSource.DataSource = listStorageInfoModel;
}
#endregion
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox(ex.Message.ToString());
}
}
#region
/// <summary>
/// 设置父节点
/// </summary>
/// <param name="node"></param>
private void SelectNods(TreeListNode node)
{
if (node.ParentNode != null)
{
if (node.Checked)
{
node.ParentNode.Checked = true;
if (node.ParentNode.ParentNode != null)
{
SelectNods(node.ParentNode);
}
return;
}
else
{
for (int m = 0; m < node.ParentNode.Nodes.Count; m++)
{
if (node.ParentNode.Nodes[m].Checked)
{
node.ParentNode.Checked = true;
return;
}
}
node.ParentNode.Checked = false;
if (node.ParentNode.ParentNode != null)
{
SelectNods(node.ParentNode);
}
}
}
else
{
return;
}
}
#endregion
#region
public void SetChilde(TreeListNode node)
{
if (node.Nodes.Count > 0)
{
for (int m = 0; m < node.Nodes.Count; m++)
{
node.Nodes[m].Checked = node.Checked;
if (node.Nodes[m].Nodes.Count > 0)
{
SetChilde(node.Nodes[m]);
}
}
}
else
{
return;
}
}
#endregion
#endregion
#region
/// <summary>
/// 获取上架策略信息
/// </summary>
private void GetUpStrategy()
{
string errText = string.Empty;
DataTable dt = IBussFactory<BussUpStrategy>.Instance().GetUpStrategy("", "", StrategyID);
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"].ToString() == "1")
{
rbPCTrue.Checked = true;
}
else
{
rbPCFlase.Checked = true;
}
//种类
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();
}
}
strateyModel = IBussFactory<BussUpStrategy>.Instance().GetStrategy(StrategyID);
// strateyModel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WMS.Model.Strategy.UpStrateyCtsModel>>(strStrategy);
if (errText.Trim().Length > 0 || strateyModel == null)
{
SystemCommon.ShowInfoMessageBox(errText);
return;
}
foreach (UpStrateyCtsModel model in strateyModel)
{
GetStorageArea(model.STORAGE_ID);
}
}
#endregion
#region
/// <summary>
/// 确定
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctrlButtons1_Click(object sender, EventArgs e)
{
if (Validation())
{
AddOrUpdateUpStrategy();
saveStyButton.Enabled = true;
}
}
#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 errText = string.Empty;
try
{
if (frmFlag == "1")
{
IBussFactory<BussUpStrategy>.Instance().AddUpStrategy(model);
}
else if (frmFlag == "2")
{
IBussFactory<BussUpStrategy>.Instance().UpdateUpStrategy(model);
}
if (errText != "")
{
SystemCommon.ShowErrorMessageBox(errText);
}
else
{
SystemCommon.ShowInfoMessageBox("操作成功!");
Close();
bol = true;
}
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("网络连接出现错误!");
return;
}
}
#endregion
#region
/// <summary>
/// 设置实体
/// </summary>
/// <returns></returns>
private UpStrategyModel SetUpStrategyModel()
{
UpStrategyModel model = new UpStrategyModel();
//上架策略编号
if (frmFlag == "2")
{
model.UPSTRATEGY_ID = StrategyID;
model.UPDATE_MAN = userData.NAME;
model.UPDATE_DATE = DateTime.Now;
}
//上架策略名称
model.UPSTRATEGY_NAME = txtStartegyName.Text;
if (rbCZTrue.Checked)
{
model.WEIGHT_FLAG = "1";
}
else
{
model.WEIGHT_FLAG = "0";
}
if (rbtStatus.Checked)
{
model.UPSTRATEGY_STATE = "1";
}
else
{
model.UPSTRATEGY_STATE = "0";
}
// if (batchManger.Checked)
// {
// model.BATCHMANGERFLAG = "1";
// }
// else
// {
//model.BATCHMANGERFLAG = "0";
// }
//上架策略状态
// model.UPSTRATEGY_STATE = LueState.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 (frmFlag == "1")
{
model.CREATE_MAN = userData.NAME;
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..ToString());
}
/// <summary>
/// 根据仓库编号获取库区
/// </summary>
/// <param name="strStorageId"></param>
private void GetStorageArea(string strStorageId)
{
List<AreaGoodsTypeModel> areaGoodsTypeList = new List<AreaGoodsTypeModel>();
StorageAreaModel model = new StorageAreaModel();
model.STORAGE_ID = strStorageId;
string errText = "";
listStorageAreaModel = IBussFactory<BussStorageArea>.Instance().GetAreaInfoDS(model, ref areaGoodsTypeList);
//if (add == "1")
//{
// if (strateyModel.Count > 0)
// {
// foreach (UpStrateyCtsModel smodel in strateyModel)
// {
// if (smodel.STORAGE_AREA_ID.Trim().Length > 0)
// listStorageAreaModel.RemoveAll(r => r.STORAGE_AREA_ID == smodel.STORAGE_AREA_ID);
// }
// }
//}
if(listStorageAreaModel!=null)
storageAreaModelBindingSource.DataSource = listStorageAreaModel;
//storageInfoModelBindingSource.ValueMember = "STORAGE_AREA_ID";
//storageInfoModelBindingSource.DisplayMember = "STORAGE_AREA_NAME";
}
#endregion
#region
/// <summary>
/// 关闭
/// </summary>
private void FrmClose()
{
this.Close();
this.Dispose();
}
#endregion
List<WMS.Model.Strategy.UpStrateyCtsModel> strateyModel = new List<Model.Strategy.UpStrateyCtsModel>();
List<WMS.Model.Strategy.UpStrateyCtsModel> strateyAddModel = new List<Model.Strategy.UpStrateyCtsModel>();
List<WMS.Model.Strategy.UpStrateyCtsModel> strateyDelModel = new List<Model.Strategy.UpStrateyCtsModel>();
List<WMS.Model.Strategy.UpStrateyCtsModel> strateyUPTEModel = new List<Model.Strategy.UpStrateyCtsModel>();
private void repositoryItemLookUpEdit3_EditValueChanged(object sender, EventArgs e)
{
LookUpEdit lookUpEdit = sender as LookUpEdit;
string strStorageId = lookUpEdit.EditValue.ToString();
// strateyModel= strateyModel;
// string strStorageId =gdvStgy.GetFocusedRowCellValue(colSTORAGE_AREA_ID).ToString();
GetStorageArea(strStorageId);
if (strateyModel.Count > 0)
{
strateyModel[strateyModel.Count - 1].STORAGE_ID = strStorageId;
}
kqTreeList.Focus();
}
/// <summary>
/// 保存上架策略信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctrlButtons5_Click(object sender, EventArgs e)
{
#region ##
//gdvStgy.OptionsBehavior.Editable = false;
////if (addButton.Enabled)
////{
//try
//{
// string errText = string.Empty;
// string addModel = Newtonsoft.Json.JsonConvert.SerializeObject(strateyModel);
// WebLockConfig.Instance.WebUpStrategy.AddStrategyCdtion(addModel, ref errText);
// if (errText.Trim().Length > 0)
// {
// SystemCommon.ShowInfoMessageBox(errText);
// return;
// }
//}
//catch (Exception ex)
//{
// SystemCommon.ShowInfoMessageBox(ex.Message.ToString());
//}
//saveStyButton.Enabled = false;
////addButton.Enabled = true;
////editButton.Enabled = true;
//SystemCommon.ShowInfoMessageBox("保存成功");
////}
#endregion
//UpdateUpStrategy
if (string.IsNullOrEmpty(strategyID))
{
SystemCommon.ShowInfoMessageBox("策略编号为空!");
return;
}
UpStrategyModel upStgModel = new UpStrategyModel();
upStgModel.UPSTRATEGY_ID = this.strategyID;
if (string.IsNullOrEmpty(txtStartegyName.Text.Trim()))
{
SystemCommon.ShowInfoMessageBox("策略名称不能为空!");
txtStartegyName.Focus();
}
upStgModel.UPSTRATEGY_NAME = txtStartegyName.Text;
//状态
if (rbPCTrue.Checked)
{
upStgModel.UPSTRATEGY_STATE = "1";
}
else
{
upStgModel.UPSTRATEGY_STATE = "0";
}
//种类
if (rbZLTrue.Checked)
{
upStgModel.KINDS_FLAG = "1";
}
else
{
upStgModel.KINDS_FLAG = "0";
}
//批次
if (rbPCTrue.Checked)
{
upStgModel.BATCH_FLAG = "1";
}
else
{
upStgModel.BATCH_FLAG = "0";
}
//容积
if (rbRJTrue.Checked)
{
upStgModel.VOLUME_FLAG = "1";
}
else
{
upStgModel.VOLUME_FLAG = "0";
}
//承重
if (rbCZTrue.Checked)
{
upStgModel.WEIGHT_FLAG = "1";
}
else
{
upStgModel.WEIGHT_FLAG = "0";
}
//库位
if (rbKWTrue.Checked)
{
upStgModel.LOCATION_FLAG = "1";
}
else
{
upStgModel.LOCATION_FLAG = "0";
}
//批次管理的标记
if (rbPCTrue.Checked)
{
upStgModel.BATCH_FLAG = "0";
}
else
{
upStgModel.BATCH_FLAG = "1";
}
upStgModel.REMARK = txtRemark.Text.Trim();
string errText = "";
try
{
IBussFactory<BussUpStrategy>.Instance().UpdateUpStrategy(upStgModel);
if (errText.Length > 0)
{
SystemCommon.ShowInfoMessageBox(errText);
}
else
{
SystemCommon.ShowInfoMessageBox("保存成功!");
}
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox(ex.Message);
}
}
List<string> selectGoodsType = new List<string>();
private void SelectNodesValue(TreeListNode node)
{
if (node.Nodes.Count > 0)
{
for (int i = 0; i < node.Nodes.Count; i++)
{
SelectNodesValue(node.Nodes[i]);
}
}
else
{
if (node.Checked)
{
selectGoodsType.Add(node["GOODS_TYPE_ID"].ToString());
}
}
}
/// <summary>
/// 库位条件
/// </summary>
List<UpStrateyStgModel> LocationStratey = new List<UpStrateyStgModel>();
private void rbKWTrue_CheckedChanged(object sender, EventArgs e)
{
if (rbKWTrue.Checked)
{
rbRJTrue.Checked = false;
rbRJFlase.Checked = true;
radioButton1.Checked = true;
rbZLFlase.Checked = true;
rbPCFlase.Checked = true;
rbCZFlase.Checked = true;
}
}
private void xtraTabControl1_Click(object sender, EventArgs e)
{
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
rbKWTrue.Checked = true;
rbCZTrue.Checked = false;
rbRJFlase.Checked = false;
lb_view.Visible = true;
rbRJFlase.Checked = true;
rbCZFlase.Checked = true;
}
else
{
rbKWTrue.Checked = false;
lb_view.Visible = false;
}
}
private void kqTreeList_EditValueChanged(object sender, EventArgs e)
{
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
if(radioButton4.Checked)
{
if(DialogResult.OK ==SystemCommon.ShowMessageBoxResult("是否确认存储所有物料类型"))
{
}
}
}
private void ctrlButtons1_Click_1(object sender, EventArgs e)
{
}
}
}