397 lines
14 KiB
C#
397 lines
14 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.Model.SC;
|
|||
|
|
using WMS.Frm.Base;
|
|||
|
|
using WMS.Common;
|
|||
|
|
using WMS.Ctrl;
|
|||
|
|
using WMS.Model.Base;
|
|||
|
|
using WMS.Business;
|
|||
|
|
using WMS.Business.Base;
|
|||
|
|
using WMS.Business.Common;
|
|||
|
|
using WMS.Business.SC;
|
|||
|
|
using System.Collections;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmSC
|
|||
|
|
{
|
|||
|
|
public partial class FrmGoodsMaterial : FormBase
|
|||
|
|
{
|
|||
|
|
#region 变量
|
|||
|
|
//public static FrmGoodsMaterial frmGoodsMaterial;
|
|||
|
|
private List<JWGoodsInfoModel> listGoods = new List<JWGoodsInfoModel>();
|
|||
|
|
private List<GoodsMaterialModel> listGoodsMaterialModel = new List<GoodsMaterialModel>();
|
|||
|
|
private List<GoodsMaterialModel> listGoodsMaterial = new List<GoodsMaterialModel>();
|
|||
|
|
private JWGoodsInfoModel model = new JWGoodsInfoModel();
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 初始化
|
|||
|
|
/// <summary>
|
|||
|
|
/// 构造函数
|
|||
|
|
/// </summary>
|
|||
|
|
public FrmGoodsMaterial()
|
|||
|
|
{
|
|||
|
|
// IBussFactory<BussGoodsMaterial>.Instance().GetGoodsSts();
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 本窗体加载的时候
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void FrmGoodsMaterial_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//单位下拉框
|
|||
|
|
lueUnit.NullText = "";
|
|||
|
|
lueUnit.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("VC_DICTIONARY_NAME", "单位"));
|
|||
|
|
lueUnit.ValueMember = "VC_CHAR_VALUE";
|
|||
|
|
lueUnit.DisplayMember = "VC_DICTIONARY_NAME";
|
|||
|
|
DataTable tabUnit = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tabUnit = IBussFactory<BussCommon>.Instance().GetCustomCtrlData("t_sys_dictionary_tab", "VC_CHAR_VALUE", "VC_DICTIONARY_NAME", " VC_DICTIONARY_TYPE = 'vc_uom' and c_flag = '1'", "");
|
|||
|
|
lueUnit.DataSource = tabUnit;
|
|||
|
|
//单位下拉框
|
|||
|
|
lueUnitTab.NullText = "";
|
|||
|
|
lueUnitTab.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("VC_DICTIONARY_NAME", "单位"));
|
|||
|
|
lueUnitTab.ValueMember = "VC_CHAR_VALUE";
|
|||
|
|
lueUnitTab.DisplayMember = "VC_DICTIONARY_NAME";
|
|||
|
|
lueUnitTab.DataSource = tabUnit;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("加载单位出错了:" + ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BindGoods();
|
|||
|
|
FrmSelectModle = new JWGoodsInfoModel();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 绑定数据
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定数据
|
|||
|
|
/// </summary>
|
|||
|
|
private void BindGoods()
|
|||
|
|
{
|
|||
|
|
listGoods = new List<JWGoodsInfoModel>();
|
|||
|
|
listGoodsMaterial = new List<GoodsMaterialModel>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
GoodsMaterialModel GoodsMaterialModel = new GoodsMaterialModel();
|
|||
|
|
listGoodsMaterial = IBussFactory<BussGoodsMaterial>.Instance().GetGoodsMaterialList(GoodsMaterialModel);
|
|||
|
|
if (listGoodsMaterial.Count > 0)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<string> goodsIDList = new List<string>();
|
|||
|
|
foreach (var item in listGoodsMaterial)
|
|||
|
|
{
|
|||
|
|
//if (goodsIDList.Exists(p => p == item.INVENTORY_ITEM_ID)) { continue; }
|
|||
|
|
//goodsIDList.Add(item.INVENTORY_ITEM_ID);
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
listGoods = IBussFactory<BussGoods>.Instance().GetGoodsListByIDList(goodsIDList);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("加载物料列表失败了:" + ex.Message);
|
|||
|
|
}
|
|||
|
|
bsGoods.DataSource = listGoods;
|
|||
|
|
GvGoods.RefreshData();
|
|||
|
|
//GvGoods_FocusedRowChanged(null, null);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
bsGoods.DataSource = listGoods;
|
|||
|
|
GvGoods.RefreshData();
|
|||
|
|
GvGoods_FocusedRowChanged(null, null);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("加载商品物料出错了:" + ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 通用查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="table"></param>
|
|||
|
|
public override void LoadListData(DataTable table)
|
|||
|
|
{
|
|||
|
|
listGoods = ConvertHelper<JWGoodsInfoModel>.ConvertToList(table);
|
|||
|
|
bsGoods.DataSource = listGoods;
|
|||
|
|
GvGoods.RefreshData();
|
|||
|
|
|
|||
|
|
//splitContainerControl1.Panel1.Height = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 按钮事件
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新增按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Add()
|
|||
|
|
{
|
|||
|
|
//FrmGoodsMaterialDet frmGoodsMaterialDet = new FrmGoodsMaterialDet(listGoods);
|
|||
|
|
//frmGoodsMaterialDet.userData = this.userData;
|
|||
|
|
//frmGoodsMaterialDet.ShowDialog();
|
|||
|
|
//BindGoods();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 编辑按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Edit()
|
|||
|
|
{
|
|||
|
|
if (!frmButtonItem.ContainsKey("Edit"))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
else if (frmButtonItem["Edit"].Enabled == false)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (listGoodsMaterialModel == null || listGoodsMaterialModel.Count == 0) { SystemCommon.ShowInfoMessageBox("请先选择要编辑的数据!"); return; }
|
|||
|
|
FrmGoodsMaterialDet frmGoodsMaterialDet = new FrmGoodsMaterialDet(listGoodsMaterialModel);
|
|||
|
|
frmGoodsMaterialDet.userData = this.userData;
|
|||
|
|
frmGoodsMaterialDet.ShowDialog();
|
|||
|
|
BindGoods();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 刷新按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Refresh()
|
|||
|
|
{
|
|||
|
|
BindGoods();
|
|||
|
|
GvGoods.FocusedRowHandle = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Del()
|
|||
|
|
{
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
model = GvGoods.GetFocusedRow() as JWGoodsInfoModel;
|
|||
|
|
if (model == null)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请先选择要删除的数据!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (DialogResult.OK == SystemCommon.ShowMessageBoxResult("确定删除当前选择的数据?"))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//string str = model.INVENTORY_ITEM_ID;
|
|||
|
|
if (!string.IsNullOrEmpty(model.INVENTORY_ITEM_ID))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
errText = IBussFactory<BussGoodsMaterial>.Instance().DeleteGoodsMaterial(model.INVENTORY_ITEM_ID);//删除
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("删除出错了:" + ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(errText))//如果成功
|
|||
|
|
{
|
|||
|
|
listGoods.Clear();
|
|||
|
|
listGoodsMaterial.Clear();
|
|||
|
|
BindGoods();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("删除失败" + errText);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择一条记录");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
//private void GVGoodsMaterial_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
|||
|
|
//{
|
|||
|
|
// if (e.Column.FieldName == "SC_STATE")
|
|||
|
|
// {
|
|||
|
|
// switch (e.Value.ToString().Trim())
|
|||
|
|
// {
|
|||
|
|
// case "0":
|
|||
|
|
// e.DisplayText = "启用";
|
|||
|
|
// break;
|
|||
|
|
// case "1":
|
|||
|
|
// e.DisplayText = "停用";
|
|||
|
|
// break;
|
|||
|
|
// default:
|
|||
|
|
// e.DisplayText = "";
|
|||
|
|
// break;
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
private void GVGoods_DoubleClick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
Edit();
|
|||
|
|
}
|
|||
|
|
List<GoodsMaterialModel> improtempList = new List<GoodsMaterialModel>();
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导入
|
|||
|
|
/// </summary>
|
|||
|
|
public void Import()
|
|||
|
|
{
|
|||
|
|
OpenFileDialog fileDialog = new OpenFileDialog();
|
|||
|
|
fileDialog.Title = "导入商品资料";
|
|||
|
|
fileDialog.Filter = "Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx";
|
|||
|
|
DialogResult dialogResult = fileDialog.ShowDialog(this);
|
|||
|
|
if (dialogResult == DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
LoadForm load = new LoadForm();
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 0);
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在导入请稍候....");
|
|||
|
|
|
|||
|
|
Hashtable ht = new Hashtable();
|
|||
|
|
ht.Add("INVENTORY_ITEM_ID", "成品编号");
|
|||
|
|
ht.Add("MATERIAL_ID", "原料编号");
|
|||
|
|
ht.Add("STAND_NUM", "标准原料数");
|
|||
|
|
ht.Add("MAX_NUM", "最大原料数");
|
|||
|
|
ht.Add("LOSS_PERCENT", "损耗百分比");
|
|||
|
|
ht.Add("UNIT", "单位");
|
|||
|
|
improtempList = NPOIHelper<GoodsMaterialModel>.Import(fileDialog, ht);
|
|||
|
|
if (DevExpress.XtraSplashScreen.SplashScreenManager.ActivateParentOnSplashFormClosing)
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|||
|
|
if (improtempList == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bsGoodsMaterial.DataSource = improtempList;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存导入
|
|||
|
|
/// </summary>
|
|||
|
|
public void SaveImport()
|
|||
|
|
{
|
|||
|
|
if(improtempList.Count==0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
LoadForm load = new LoadForm();
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 0);
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在保存请稍候....");
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
errText = IBussFactory<BussGoodsMaterial>.Instance().InsertGoodsMaterial(improtempList);
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(errText))//如果增加成功
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("增加成功");
|
|||
|
|
this.Close();
|
|||
|
|
this.Dispose();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("增加失败" + errText);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("新增出错了:" + ex.Message);
|
|||
|
|
}
|
|||
|
|
if (DevExpress.XtraSplashScreen.SplashScreenManager.ActivateParentOnSplashFormClosing)
|
|||
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void GvGoods_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
|||
|
|
{
|
|||
|
|
model = GvGoods.GetFocusedRow() as JWGoodsInfoModel;
|
|||
|
|
|
|||
|
|
if (model == null || listGoodsMaterial.Count == 0) { listGoodsMaterialModel = new List<GoodsMaterialModel>(); }
|
|||
|
|
//listGoodsMaterialModel = listGoodsMaterial.FindAll(p => p.INVENTORY_ITEM_ID == model.INVENTORY_ITEM_ID);
|
|||
|
|
bsGoodsMaterial.DataSource = listGoodsMaterialModel;//加载组合商品物料
|
|||
|
|
GVGoodsMaterial.RefreshData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//private void Unit_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;
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
}
|