474 lines
16 KiB
C#
474 lines
16 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.Strategy;
|
|||
|
|
using WMS.Model.Base;
|
|||
|
|
using WMS.Common;
|
|||
|
|
using WMS.Business;
|
|||
|
|
using WMS.Business.Strategy;
|
|||
|
|
using WMS.Business.Common;
|
|||
|
|
using WMS.Business.Base;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmStrategy
|
|||
|
|
{
|
|||
|
|
public partial class FrmProRepStrategyDet : FormBase
|
|||
|
|
{
|
|||
|
|
#region 全局变量
|
|||
|
|
/// <summary>
|
|||
|
|
/// 供应商补货策略主表Model
|
|||
|
|
/// </summary>
|
|||
|
|
ProRepStrategyModel sourceModel = new ProRepStrategyModel();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 供应商补货策略明细表Model
|
|||
|
|
/// </summary>
|
|||
|
|
ProRepStrategyInfoModel proInfoModel = new ProRepStrategyInfoModel();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 供应商补货策略明细表List集合
|
|||
|
|
/// </summary>
|
|||
|
|
List<ProRepStrategyInfoModel> proInfoList = new List<ProRepStrategyInfoModel>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 用于多条数据选中操作(多条删除,改变选中多条数据值等)
|
|||
|
|
/// </summary>
|
|||
|
|
List<ProRepStrategyInfoModel> listforOpertor = new List<ProRepStrategyInfoModel>();
|
|||
|
|
|
|||
|
|
int flag = -1;
|
|||
|
|
|
|||
|
|
|
|||
|
|
string strID = string.Empty;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
#region 构造函数
|
|||
|
|
public FrmProRepStrategyDet()
|
|||
|
|
{
|
|||
|
|
flag = 0;
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public FrmProRepStrategyDet(ProRepStrategyModel promodel)
|
|||
|
|
{
|
|||
|
|
flag = 1;
|
|||
|
|
InitializeComponent();
|
|||
|
|
sourceModel = promodel;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 窗体加载
|
|||
|
|
private void FrmProRepStrategyDet_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
bgsProRepStrategyInfo.DataSource = new ProRepStrategyInfoModel();
|
|||
|
|
this.lkpStorage.LoadData();
|
|||
|
|
|
|||
|
|
if (flag == 0)
|
|||
|
|
{
|
|||
|
|
strID = IBussFactory<BussProRepStrategy>.Instance().GetNextValNum();
|
|||
|
|
sourceModel = new ProRepStrategyModel();
|
|||
|
|
sourceModel.STRATEGY_STATUS = "0";
|
|||
|
|
bgsProRepStrategy.DataSource = sourceModel;
|
|||
|
|
proInfoList = new List<ProRepStrategyInfoModel>();
|
|||
|
|
bgsProRepStrategyInfo.DataSource = proInfoList;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (flag == 1)
|
|||
|
|
{
|
|||
|
|
proInfoList = new List<ProRepStrategyInfoModel>();
|
|||
|
|
bgsProRepStrategy.DataSource = sourceModel;
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (proInfoList != null)
|
|||
|
|
{
|
|||
|
|
if (proInfoList.Count > 0)
|
|||
|
|
{
|
|||
|
|
bgsProRepStrategyInfo.DataSource = proInfoList;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
this.gVProRepStragyDet.RefreshData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
lueUnit.NullText = "";
|
|||
|
|
lueUnit.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("VC_DICTIONARY_NAME", "单位"));
|
|||
|
|
lueUnit.ValueMember = "VC_CHAR_VALUE";
|
|||
|
|
lueUnit.DisplayMember = "VC_DICTIONARY_NAME";
|
|||
|
|
DataTable strResult = new DataTable();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
strResult= IBussFactory<BussCommon>.Instance().GetCustomCtrlData("t_sys_dictionary_tab", "VC_CHAR_VALUE", "VC_DICTIONARY_NAME", " VC_DICTIONARY_TYPE = 'vc_uom' and c_flag = '1'", "");
|
|||
|
|
if (strResult != null)
|
|||
|
|
{
|
|||
|
|
lueUnit.DataSource = strResult;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
ctrlGoods_Button_Click(null, null);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 明细删除
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void btnDel_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
GetSelectData();
|
|||
|
|
for (int i = 0; i < listforOpertor.Count; i++)
|
|||
|
|
{
|
|||
|
|
proInfoList.Remove(listforOpertor[i]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bgsProRepStrategyInfo.DataSource = proInfoList;
|
|||
|
|
this.gVProRepStragyDet.RefreshData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获得选中数据行记录
|
|||
|
|
/// </summary>
|
|||
|
|
private void GetSelectData()
|
|||
|
|
{
|
|||
|
|
listforOpertor = new List<ProRepStrategyInfoModel>();
|
|||
|
|
int[] selectRows = this.gVProRepStragyDet.GetSelectedRows();
|
|||
|
|
this.labelControl1.Focus();
|
|||
|
|
foreach (int j in selectRows)
|
|||
|
|
{
|
|||
|
|
proInfoModel = new ProRepStrategyInfoModel();
|
|||
|
|
proInfoModel = this.gVProRepStragyDet.GetRow(j) as ProRepStrategyInfoModel;
|
|||
|
|
listforOpertor.Add(proInfoModel);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(this.txtName.Text))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("策略名称不能为空!");
|
|||
|
|
this.txtName.Focus();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
//新增
|
|||
|
|
if (flag == 0)
|
|||
|
|
{
|
|||
|
|
string strErr = string.Empty;
|
|||
|
|
sourceModel.STRATEGY_ID = strID;
|
|||
|
|
sourceModel.CREATE_MAN = userData.USER_ID;
|
|||
|
|
sourceModel.CREATE_DATE = DateTime.Now;
|
|||
|
|
sourceModel.OPERATORID = userData.USER_ID;
|
|||
|
|
sourceModel.OPERATEDATE = DateTime.Now;
|
|||
|
|
bgsProRepStrategy.EndEdit();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
List<ProRepStrategyInfoModel> list = (List<ProRepStrategyInfoModel>)bgsProRepStrategyInfo.DataSource;
|
|||
|
|
strErr = IBussFactory<BussProRepStrategy>.Instance().InsertStrategyDataAndInfo(sourceModel, list);
|
|||
|
|
if (!string.IsNullOrEmpty(strErr))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作失败!");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("网络连接错误,请检查当前网络环境是否可用!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//修改
|
|||
|
|
else if (flag == 1)
|
|||
|
|
{
|
|||
|
|
string strErr = string.Empty;
|
|||
|
|
sourceModel.UPDATE_MAN = userData.USER_ID;
|
|||
|
|
sourceModel.UPDATE_DATE = DateTime.Now;
|
|||
|
|
sourceModel.OPERATEDATE = DateTime.Now;
|
|||
|
|
sourceModel.OPERATORID = userData.USER_ID;
|
|||
|
|
bgsProRepStrategy.EndEdit();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
List<ProRepStrategyInfoModel> strList = (List<ProRepStrategyInfoModel>)bgsProRepStrategyInfo.DataSource;
|
|||
|
|
strErr = IBussFactory<BussProRepStrategy>.Instance().UpdateStrategyDataAndInfo(sourceModel, strList);
|
|||
|
|
if (!string.IsNullOrEmpty(strErr))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作失败!");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("网络连接错误,请检查当前网络环境是否可用!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("是否要放弃现在所做操作?"))
|
|||
|
|
{
|
|||
|
|
this.Close();
|
|||
|
|
this.Dispose();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 选商品
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void ctrlGoods_Button_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (ctrlGoods.SelectTable.Rows.Count == 0)
|
|||
|
|
{
|
|||
|
|
//SystemCommon.ShowInfoMessageBox("您未选择商品!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//商品集合
|
|||
|
|
List<GoodsInfoModel> listGoodsInfoModel = ConvertHelper<GoodsInfoModel>.ConvertToList(ctrlGoods.SelectTable);
|
|||
|
|
|
|||
|
|
|
|||
|
|
/*将选择的商品加入入库商品明细*/
|
|||
|
|
foreach (GoodsInfoModel item in listGoodsInfoModel)
|
|||
|
|
{
|
|||
|
|
ProRepStrategyInfoModel model = new ProRepStrategyInfoModel();
|
|||
|
|
ProviderModel prm = new ProviderModel();
|
|||
|
|
model.STRATEGY_ID = sourceModel.STRATEGY_ID;
|
|||
|
|
model.GOODS_ID = item.GOODS_ID;
|
|||
|
|
model.GOODS_NAME = item.GOODS_NAME;
|
|||
|
|
model.STORAGE_ID = userData.STORAGE_ID;
|
|||
|
|
model.STORAGE_NAME = userData.STORAGE_NAME;
|
|||
|
|
prm.PROVIDER_ID = item.PROVIDER_ID;
|
|||
|
|
List<ProviderModel> lisp = IBussFactory<BussProvider>.Instance().GetProviderList(prm);
|
|||
|
|
|
|||
|
|
if (lisp != null)
|
|||
|
|
{
|
|||
|
|
if (lisp.Count > 0)
|
|||
|
|
{
|
|||
|
|
model.PRO_ID = item.PROVIDER_ID;
|
|||
|
|
model.PRO_NAME = lisp[0].PROVIDER_NAME;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
model.PRO_ID = string.Empty;
|
|||
|
|
model.PRO_NAME = string.Empty;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//model.STORAGE_ID = this.lkpStorage.EditValue.ToString();
|
|||
|
|
model.GOODS_TYPE_ID = item.GOODS_TYPE_ID;
|
|||
|
|
model.COUNT_NUM = decimal.Parse(txtCountNum.Text);
|
|||
|
|
model.STOCK_NUM = decimal.Parse(txtMin.Text);
|
|||
|
|
model.UNIT = item.UNIT;
|
|||
|
|
//判断该商品是否已经在入库商品明细中后添加
|
|||
|
|
bool had = false;
|
|||
|
|
foreach (ProRepStrategyInfoModel wntModel in proInfoList)
|
|||
|
|
{
|
|||
|
|
if (wntModel.GOODS_ID == model.GOODS_ID)
|
|||
|
|
{
|
|||
|
|
had = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (!had)
|
|||
|
|
{
|
|||
|
|
proInfoList.Add(model);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (proInfoList.Count > 0)
|
|||
|
|
{
|
|||
|
|
GCProRepStrategyDet.DataSource = proInfoList;
|
|||
|
|
bgsProRepStrategyInfo.DataSource = proInfoList;
|
|||
|
|
this.gVProRepStragyDet.RefreshData();
|
|||
|
|
////焦点置于采购数量
|
|||
|
|
//GVStrAreaRepGoods.FocusedColumn = GVStrAreaRepGoods.Columns[1];
|
|||
|
|
//GVStrAreaRepGoods.FocusedRowHandle = 0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("未选择任何商品或所选择的商品已存在,请重新选择");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 仓库选择EditValueChanged
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void lkpStorage_EditValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(this.lkpStorage.EditValue.ToString()))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (ProRepStrategyInfoModel item in proInfoList)
|
|||
|
|
{
|
|||
|
|
item.STORAGE_ID = this.lkpStorage.EditValue.ToString();
|
|||
|
|
item.STORAGE_NAME = this.lkpStorage.Text;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
this.gVProRepStragyDet.RefreshData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void gVProRepStragyDet_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.Column.FieldName == "UNIT")
|
|||
|
|
{
|
|||
|
|
if (e.Value == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
switch (e.Value.ToString().Trim())
|
|||
|
|
{
|
|||
|
|
case "a":
|
|||
|
|
e.DisplayText = "盒";
|
|||
|
|
break;
|
|||
|
|
case "b":
|
|||
|
|
e.DisplayText = "罐";
|
|||
|
|
break;
|
|||
|
|
case "c":
|
|||
|
|
e.DisplayText = "袋";
|
|||
|
|
break;
|
|||
|
|
case "d":
|
|||
|
|
e.DisplayText = "瓶";
|
|||
|
|
break;
|
|||
|
|
case "e":
|
|||
|
|
e.DisplayText = "个";
|
|||
|
|
break;
|
|||
|
|
case "f":
|
|||
|
|
e.DisplayText = "包";
|
|||
|
|
break;
|
|||
|
|
case "g":
|
|||
|
|
e.DisplayText = "把";
|
|||
|
|
break;
|
|||
|
|
case "h":
|
|||
|
|
e.DisplayText = "筒";
|
|||
|
|
break;
|
|||
|
|
case "i":
|
|||
|
|
e.DisplayText = "张";
|
|||
|
|
break;
|
|||
|
|
case "j":
|
|||
|
|
e.DisplayText = "套";
|
|||
|
|
break;
|
|||
|
|
case "k":
|
|||
|
|
e.DisplayText = "克";
|
|||
|
|
break;
|
|||
|
|
case "l":
|
|||
|
|
e.DisplayText = "泡";
|
|||
|
|
break;
|
|||
|
|
case "m":
|
|||
|
|
e.DisplayText = "片";
|
|||
|
|
break;
|
|||
|
|
case "z":
|
|||
|
|
e.DisplayText = "箱";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
e.DisplayText = "";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txtMin_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
GetSelectData();
|
|||
|
|
if (Convert.ToDecimal(this.txtMin.Text) == 1)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
this.labelControl1.Focus();
|
|||
|
|
foreach (ProRepStrategyInfoModel item in listforOpertor)
|
|||
|
|
{
|
|||
|
|
item.STOCK_NUM = Convert.ToDecimal(this.txtMin.Text);
|
|||
|
|
}
|
|||
|
|
this.gVProRepStragyDet.RefreshData();
|
|||
|
|
this.txtMin.Focus();
|
|||
|
|
if (this.txtMin.Text.Length > 6)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("您输入的库存下限值过大,请重新输入!");
|
|||
|
|
this.txtMin.Text = "1";
|
|||
|
|
this.txtMin.Focus();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txtCountNum_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
GetSelectData();
|
|||
|
|
if (Convert.ToDecimal(this.txtCountNum.Text) == 1)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
this.labelControl1.Focus();
|
|||
|
|
foreach (var item in listforOpertor)
|
|||
|
|
{
|
|||
|
|
item.COUNT_NUM = Convert.ToDecimal(this.txtCountNum.Text);
|
|||
|
|
}
|
|||
|
|
this.gVProRepStragyDet.RefreshData();
|
|||
|
|
this.txtCountNum.Focus();
|
|||
|
|
if (this.txtCountNum.Text.Length > 7)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("您输入的补货量过大,请重新输入!");
|
|||
|
|
this.txtCountNum.Focus();
|
|||
|
|
this.txtCountNum.Text = "1";
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ctrlProvider_Button_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
GetSelectData();
|
|||
|
|
this.labelControl1.Focus();
|
|||
|
|
foreach (var item in listforOpertor)
|
|||
|
|
{
|
|||
|
|
item.PRO_ID = this.ctrlProvider.TextBoxFlag;
|
|||
|
|
item.PRO_NAME = this.ctrlProvider.TextBoxValue;
|
|||
|
|
}
|
|||
|
|
this.gVProRepStragyDet.RefreshData();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void gVProRepStragyDet_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
proInfoModel = this.gVProRepStragyDet.GetFocusedRow() as ProRepStrategyInfoModel;
|
|||
|
|
this.txtMin.Text = proInfoModel.STOCK_NUM.ToString();
|
|||
|
|
this.txtCountNum.Text = proInfoModel.COUNT_NUM.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|