768 lines
28 KiB
C#
768 lines
28 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.Model.SystemManage;
|
||
using WMS.Business.SystemManage;
|
||
using WMS.Business;
|
||
using WMS.Business.SC;
|
||
using WMS.Business.Stock;
|
||
using WMS.Model.Stock;
|
||
//using WMS.FrmStock;
|
||
|
||
namespace WMS.FrmSC
|
||
{
|
||
public partial class FrmPlan : FormBase
|
||
{
|
||
/// <summary>
|
||
/// 业务类型MODEL
|
||
/// </summary>
|
||
ProcessPlanModel processPlanModel = new ProcessPlanModel();
|
||
|
||
/// <summary>
|
||
/// 业务类型集合
|
||
/// </summary>
|
||
List<ProcessPlanModel> planList = new List<ProcessPlanModel>();
|
||
|
||
/// <summary>
|
||
/// 对应关系Model
|
||
/// </summary>
|
||
PlanGoodsModel infomodel = new PlanGoodsModel();
|
||
|
||
/// <summary>
|
||
/// 对应关系集合
|
||
/// </summary>
|
||
List<PlanGoodsModel> infoList = new List<PlanGoodsModel>();
|
||
|
||
List<GoodsMaterialModel> lstGoodMaterials = new List<GoodsMaterialModel>();
|
||
|
||
/// <summary>
|
||
/// 业务类型
|
||
/// </summary>
|
||
int workflag = 3;//0 增加 1 修改 2 删除 ;
|
||
|
||
public FrmPlan()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void FrmPlan_Load(object sender, EventArgs e)
|
||
{
|
||
DicGoods.selSql = "select g.*,gt.GOODS_TYPE_ID GOODS_TYPE,gt.GOODS_TYPE_NAME GOODS_TYPENAME from t_base_goods g left join T_BASE_GOODS_TYPE gt on gt.GOODS_TYPE_ID=g.GOODS_TYPE_ID where g.sc_flag = '1'";//组合商品
|
||
LEPStoID.LoadData();//计划页面仓库
|
||
LEPStoSel.LoadData();//查询页面 仓库选择
|
||
LEPTeam.LoadData();//班组
|
||
BindTeamData();
|
||
PageWork.PageEnabled = false;
|
||
BSPlanTab.DataSource = new ProcessPlanModel() { DATESTAR = DateTime.Now.AddMonths(-1), DATEEND = DateTime.Now };
|
||
Search();
|
||
try
|
||
{
|
||
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Clear")) { frmButtonItem["Clear"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Confirm")) { frmButtonItem["Confirm"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Refresh")) { frmButtonItem["Refresh"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Add")) { frmButtonItem["Add"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Edit")) { frmButtonItem["Edit"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Del")) { frmButtonItem["Del"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Search")) { frmButtonItem["Search"].Enabled = true; }
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
private void BindTeamData()
|
||
{
|
||
try
|
||
{
|
||
List<TeamModel> list = IBussFactory<BussTeam>.Instance().GetList(new TeamModel());
|
||
|
||
repositoryItemLookUpEditTeam.DataSource = list;
|
||
repositoryItemLookUpEditTeam.DisplayMember = "TEAM_NAME";
|
||
repositoryItemLookUpEditTeam.ValueMember = "TEAM_ID";
|
||
|
||
LEPTeam.Properties.DataSource = list;
|
||
LEPTeam.Properties.DisplayMember = "TEAM_NAME";
|
||
LEPTeam.Properties.ValueMember = "TEAM_ID";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("加载班组失败:BindTeamData" + ex.Message);
|
||
}
|
||
|
||
}
|
||
|
||
private void bindPlan(ProcessPlanModel model)
|
||
{
|
||
try
|
||
{
|
||
planList = IBussFactory<BussProcessPlan>.Instance().GetScPlanList(model);
|
||
GCPlan.DataSource = planList;
|
||
GVPlan.RefreshData();
|
||
|
||
if (planList.Count > 0)
|
||
{
|
||
processPlanModel = planList[0];
|
||
bindPlanGoods(new ScProcessModel() { TASK_ID = processPlanModel.PLAN_ID });
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("出错了bindPlan:" + ex.Message);
|
||
}
|
||
}
|
||
private void bindPlanGoods(PlanGoodsModel model)
|
||
{
|
||
try
|
||
{
|
||
List<PlanGoodsModel> list = IBussFactory<BussPlanGoods>.Instance().GetPlanGoodsList(model);
|
||
GCPlanGoods.DataSource = list;
|
||
GVPlanGoods.RefreshData();
|
||
}
|
||
catch (Exception)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("获取数据失败,请检查网络连接!");
|
||
}
|
||
}
|
||
private void bindPlanGoods(ScProcessModel model)
|
||
{
|
||
try
|
||
{
|
||
|
||
List<ScProcessModel> list = IBussFactory<BussProcess>.Instance().GetProcess(model);
|
||
GCPlanGoods.DataSource = list;
|
||
GVPlanGoods.RefreshData();
|
||
}
|
||
catch (Exception)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("获取数据失败,请检查网络连接!");
|
||
}
|
||
}
|
||
|
||
private void GVPlan_Click(object sender, EventArgs e)
|
||
{
|
||
if (GVPlan.FocusedRowHandle >= 0)
|
||
{
|
||
processPlanModel = GVPlan.GetFocusedRow() as ProcessPlanModel;
|
||
bindPlanGoods(new ScProcessModel() { TASK_ID = processPlanModel.PLAN_ID });
|
||
}
|
||
}
|
||
|
||
private void GVPlan_DoubleClick(object sender, EventArgs e)
|
||
{
|
||
Edit();
|
||
//if (GVPlan.FocusedRowHandle < 0)
|
||
//{
|
||
// return;
|
||
//}
|
||
//PageWork.PageEnabled = true;
|
||
//xtraTabControl1.SelectedTabPage = PageWork;
|
||
|
||
//processPlanModel = GVPlan.GetFocusedRow() as ProcessPlanModel;
|
||
//BSPlan.DataSource = processPlanModel;
|
||
//BSPlan.ResetBindings(true);
|
||
//txtPlanID.Enabled = false;
|
||
|
||
//DicPlanMan.TextBoxFlag = processPlanModel.PLAN_USERID;
|
||
//DicPlanMan.TextBoxValue = processPlanModel.PLAN_USERNAME;
|
||
}
|
||
#region 以下是继承的按钮事件
|
||
/// <summary>
|
||
/// 新增按钮
|
||
/// </summary>
|
||
public override void Add()
|
||
{
|
||
try
|
||
{
|
||
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Clear")) { frmButtonItem["Clear"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Confirm")) { frmButtonItem["Confirm"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Refresh")) { frmButtonItem["Refresh"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Add")) { frmButtonItem["Add"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Edit")) { frmButtonItem["Edit"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Del")) { frmButtonItem["Del"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Search")) { frmButtonItem["Search"].Enabled = false; }
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
|
||
PageWork.PageEnabled = true;
|
||
xtraTabControl1.SelectedTabPage = PageWork;
|
||
workflag = 0;
|
||
processPlanModel = new ProcessPlanModel()
|
||
{
|
||
PLAN_CREATETIME = DateTime.Now,
|
||
PLAN_STARTDATE = DateTime.Now.AddDays(1),
|
||
PLAN_USERID = userData.USER_ID,
|
||
STORAGE_ID = userData.STORAGE_ID,
|
||
PLAN_ENDDATE = DateTime.Now.AddDays(8),
|
||
};
|
||
BSPlan.DataSource = processPlanModel;
|
||
BSPlan.ResetBindings(true);
|
||
DicPlanMan.TextBoxFlag = userData.USER_ID;
|
||
DicPlanMan.TextBoxValue = userData.NAME;
|
||
lstGoodMaterials = new List<GoodsMaterialModel>();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存按钮
|
||
/// </summary>
|
||
public override void Save()
|
||
{
|
||
FrmOperator(workflag);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 作废按钮
|
||
/// </summary>
|
||
public override void Del()
|
||
{
|
||
workflag = 2;
|
||
if (GVPlan.FocusedRowHandle > -1)
|
||
{
|
||
if (SystemCommon.ShowMessageBoxResult("确定作废次计划:" + GVPlan.GetFocusedRowCellValue("PLAN_NAME").ToString()) == System.Windows.Forms.DialogResult.OK)
|
||
{
|
||
ObsoletePlan();
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改按钮
|
||
/// </summary>
|
||
public override void Edit()
|
||
{
|
||
if (GVPlan.FocusedRowHandle < 0)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("请先选择要编辑的数据");
|
||
return;
|
||
}
|
||
try
|
||
{
|
||
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Clear")) { frmButtonItem["Clear"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Confirm")) { frmButtonItem["Confirm"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Refresh")) { frmButtonItem["Refresh"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Add")) { frmButtonItem["Add"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Edit")) { frmButtonItem["Edit"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Del")) { frmButtonItem["Del"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Search")) { frmButtonItem["Search"].Enabled = false; }
|
||
}
|
||
catch (Exception)
|
||
{
|
||
}
|
||
|
||
workflag = 1;
|
||
PageWork.PageEnabled = true;
|
||
PageSel.PageEnabled = false;
|
||
xtraTabControl1.SelectedTabPage = PageWork;
|
||
|
||
processPlanModel = GVPlan.GetFocusedRow() as ProcessPlanModel;
|
||
BSPlan.DataSource = processPlanModel;
|
||
BSPlan.ResetBindings(true);
|
||
|
||
DicPlanMan.TextBoxFlag = processPlanModel.PLAN_USERID;
|
||
DicPlanMan.TextBoxValue = processPlanModel.PLAN_USERNAME;
|
||
PlanGoodsModel planGoodsModel = new PlanGoodsModel()
|
||
{
|
||
PLAN_ID = processPlanModel.PLAN_ID,
|
||
|
||
};
|
||
infoList = IBussFactory<BussPlanGoods>.Instance().GetPlanGoodsList(planGoodsModel);
|
||
GCPlanGoodsWork.DataSource = infoList;
|
||
GCPlanGoodsWork.RefreshDataSource();
|
||
lstGoodMaterials = new List<GoodsMaterialModel>();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 刷新按钮
|
||
/// </summary>
|
||
public override void Refresh()
|
||
{
|
||
xtraTabControl1.SelectedTabPage = PageSel;
|
||
PageWork.PageEnabled = false;
|
||
PageSel.PageEnabled = true;
|
||
Search();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 商品选择
|
||
/// </summary>
|
||
public void Confirm()
|
||
{
|
||
if (workflag == 3)
|
||
{
|
||
return;
|
||
}
|
||
DicGoods.t_dictonary_ButtonClick(null, null);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 明细删除
|
||
/// </summary>
|
||
public override void Clear()
|
||
{
|
||
if (workflag == 3)
|
||
{
|
||
return;
|
||
}
|
||
if (GVPlanGoodsWork.FocusedRowHandle >= 0)
|
||
{
|
||
PlanGoodsModel model = GVPlanGoodsWork.GetFocusedRow() as PlanGoodsModel;
|
||
infoList.Remove(model);
|
||
GCPlanGoodsWork.DataSource = infoList;
|
||
GVPlanGoodsWork.RefreshData();
|
||
lstGoodMaterials.RemoveAll(r => r.GOODS_ID == model.GOODS_ID);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询按钮
|
||
/// </summary>
|
||
public override void Search()
|
||
{
|
||
if (xtraTabControl1.SelectedTabPage == PageSel)
|
||
{
|
||
PageSel.PageEnabled = true;
|
||
PageWork.PageEnabled = false;
|
||
BSPlanTab.EndEdit();
|
||
processPlanModel = BSPlanTab.DataSource as ProcessPlanModel;
|
||
bindPlan(processPlanModel);
|
||
}
|
||
else
|
||
{
|
||
xtraTabControl1.SelectedTabPage = PageSel;
|
||
PageSel.PageEnabled = true;
|
||
PageWork.PageEnabled = false;
|
||
}
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
#region 操作(增、改、删)
|
||
|
||
public bool CheckData(ProcessPlanModel processPlanModel)
|
||
{
|
||
|
||
if (string.IsNullOrEmpty(processPlanModel.PLAN_NAME))
|
||
{
|
||
SystemCommon.ShowErrorMessageBox("请填写计划名称!");
|
||
return false;
|
||
}
|
||
if (string.IsNullOrEmpty(processPlanModel.STORAGE_ID))
|
||
{
|
||
SystemCommon.ShowErrorMessageBox("请选择计划仓库!");
|
||
return false;
|
||
}
|
||
if (infoList == null || infoList.Count == 0)
|
||
{
|
||
SystemCommon.ShowErrorMessageBox("请完善计划生产的成品!");
|
||
return false;
|
||
}
|
||
foreach (var item in infoList)
|
||
{
|
||
if (item.GOODS_NUM <= 0)
|
||
{
|
||
SystemCommon.ShowErrorMessageBox(string.Format("【{0}】产品数量必须大于0", item.GOODS_NAME));
|
||
GVPlanGoodsWork.Focus();
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public void AddPlan(ProcessPlanModel processPlanModel)
|
||
{
|
||
|
||
if (CheckData(processPlanModel))
|
||
{
|
||
string errText = string.Empty;
|
||
processPlanModel.STATUS = "0";
|
||
foreach (PlanGoodsModel pmodel in infoList)
|
||
{
|
||
if (pmodel.GOODS_NUM == 0)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("产品数量不能为0!");
|
||
return;
|
||
}
|
||
}
|
||
bool r = CheckStock();//库存检查
|
||
if (r)
|
||
{
|
||
processPlanModel.PLAN_ID = "SC" + DateCreateTime.DateTime.ToString("yyyyMMdd") + IBussFactory<BussProcessPlan>.Instance().GetSerialNum();
|
||
foreach (PlanGoodsModel pmodel in infoList)
|
||
{
|
||
pmodel.PLAN_ID = processPlanModel.PLAN_ID;
|
||
if (LEPTeam.EditValue != null)
|
||
{
|
||
pmodel.TEAM_ID = LEPTeam.EditValue.ToString();
|
||
}
|
||
}
|
||
errText = IBussFactory<BussProcessPlan>.Instance().AddList(processPlanModel, infoList);
|
||
if (string.IsNullOrEmpty(errText))
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作成功!");
|
||
ChangeState();
|
||
}
|
||
else
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作失败:" + errText);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
public void UpdatePlan(ProcessPlanModel processPlanModel)
|
||
{
|
||
|
||
if (CheckData(processPlanModel))
|
||
{
|
||
bool r = CheckStock();//检查库存
|
||
//r = true;
|
||
if (r)
|
||
{
|
||
string errText = IBussFactory<BussProcessPlan>.Instance().UpdateAndList(processPlanModel, infoList);
|
||
if (string.IsNullOrEmpty(errText))
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作成功!");
|
||
ChangeState();
|
||
}
|
||
else
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作失败:" + errText);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
public void ObsoletePlan()
|
||
{
|
||
string planID = GVPlan.GetFocusedRowCellValue("PLAN_ID").ToString();
|
||
string errText = IBussFactory<BussProcessPlan>.Instance().Obsolete(planID,"3");
|
||
if (string.IsNullOrEmpty(errText))
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作成功!");
|
||
ChangeState();
|
||
Search();
|
||
}
|
||
else
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作失败:" + errText);
|
||
}
|
||
}
|
||
|
||
public void ChangeState()
|
||
{
|
||
BSPlanGoods.Clear();
|
||
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Clear")) { frmButtonItem["Clear"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Confirm")) { frmButtonItem["Confirm"].Enabled = false; }
|
||
if (frmButtonItem.ContainsKey("Refresh")) { frmButtonItem["Refresh"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Add")) { frmButtonItem["Add"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Edit")) { frmButtonItem["Edit"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Del")) { frmButtonItem["Del"].Enabled = true; }
|
||
if (frmButtonItem.ContainsKey("Search")) { frmButtonItem["Search"].Enabled = true; }
|
||
workflag = 3;
|
||
xtraTabControl1.SelectedTabPage = PageSel;
|
||
PageWork.PageEnabled = false;
|
||
}
|
||
/// <summary>
|
||
/// 操作(增、改、删)
|
||
/// </summary>
|
||
/// <param name="flag">0 新增 1修改 2删除 3停用 4启用/param>
|
||
private void FrmOperator(int flag)
|
||
{
|
||
BSPlan.EndEdit();
|
||
string errtxt = string.Empty;
|
||
processPlanModel = BSPlan.DataSource as ProcessPlanModel;
|
||
try
|
||
{
|
||
switch (flag)
|
||
{
|
||
case 0:
|
||
AddPlan(processPlanModel);
|
||
break;
|
||
case 1:
|
||
UpdatePlan(processPlanModel);
|
||
break;
|
||
case 3:
|
||
ObsoletePlan();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
Search();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作失败:" + ex.Message);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 检查库存
|
||
private bool CheckStock()
|
||
{
|
||
string errtxt = string.Empty;
|
||
;
|
||
List<Model.Stock.MIStockModel> miList = IBussFactory<BussMIStock>.Instance().GetMIStockList(new Model.Stock.MIStockModel() { STORAGE_ID = LEPStoID.EditValue.ToString() });
|
||
if (miList.Count == 0)
|
||
{
|
||
return false;//没有库存
|
||
}
|
||
List<PlanGoodsModel> lost = new List<PlanGoodsModel>();
|
||
foreach (GoodsMaterialModel goodsMaterialModel in lstGoodMaterials)
|
||
{
|
||
Model.Stock.MIStockModel mimodel = miList.Find(r => r.GOODS_ID == goodsMaterialModel.MATERIAL_ID);
|
||
if (mimodel == null)
|
||
{
|
||
return false;//没有库存
|
||
}
|
||
decimal stonum = isnum(mimodel.SHELVES_NUM);//库存剩余量
|
||
decimal neednum = infoList.Find(r => r.GOODS_ID == goodsMaterialModel.GOODS_ID).GOODS_NUM * goodsMaterialModel.STAND_NUM;//需要库存量
|
||
|
||
mimodel.SHELVES_NUM = stonum - neednum;
|
||
|
||
if (stonum - neednum < 0)//库存不足
|
||
{
|
||
if (lost.Count(r => r.GOODS_ID == goodsMaterialModel.MATERIAL_ID) > 0)
|
||
{
|
||
lost.Find(r => r.GOODS_ID == goodsMaterialModel.MATERIAL_ID).GOODS_NUM += stonum - neednum;//相同物料
|
||
}
|
||
else
|
||
{
|
||
lost.Add(new PlanGoodsModel() { GOODS_ID = goodsMaterialModel.MATERIAL_ID, GOODS_NUM = stonum - neednum });
|
||
}
|
||
}
|
||
}
|
||
if (lost.Count > 0)
|
||
{
|
||
string mess = "";
|
||
List<AreaRepModel> lstAreaModel = new List<AreaRepModel>();
|
||
foreach (PlanGoodsModel model in lost)
|
||
{
|
||
AreaRepModel areaRepModel = new AreaRepModel()
|
||
{
|
||
AREA_REP_ID = "",
|
||
CREATE_METHOD = "",
|
||
CREATE_PERSON = userData.USER_ID,
|
||
CREATE_PERSON_NAME = userData.NAME,
|
||
CREATE_TIME = DateTime.Now,
|
||
STORAGE_ID = "CK246",
|
||
GOODS_ID = model.GOODS_ID,
|
||
GOODS_NAME = model.GOODS_NAME,
|
||
DOCUMENT_PERSON = userData.NAME,
|
||
DOCUMENT_PERSON_ID = userData.USER_ID,
|
||
DOCUMENT_TIME = DateTime.Now,
|
||
REASON = "制定生产计划,因物料库存不足补做调拨单",
|
||
OUT_AREA_ID = "",
|
||
IN_AREA_ID = "",
|
||
REMARK = "制定生产计划,因物料库存不足补做调拨单",
|
||
TOTAL_PLAN_NUM = model.GOODS_NUM,
|
||
STATE = "未审核"
|
||
};
|
||
lstAreaModel.Add(areaRepModel);
|
||
mess += ("原材料:" + model.GOODS_NAME + "不足,暂缺数量:" + Math.Abs(model.GOODS_NUM) + Environment.NewLine);
|
||
}
|
||
mess += "是否补做调拨单?";
|
||
if (SystemCommon.ShowMessageBoxResult(mess) == System.Windows.Forms.DialogResult.OK)
|
||
{
|
||
InsertAreaRep(lstAreaModel);//此处设计有问题
|
||
////暂时注释 2018 - 12 - 10 16:19:53
|
||
//FormBase formBase = OpenFrmTable("WMS.FrmStock", "FrmStorageREP");//创建窗体
|
||
//if (formBase != null)
|
||
//{
|
||
|
||
// FrmStorageREP frmStorage = formBase as FrmStorageREP;
|
||
|
||
// if (!OpenTabAddFrm("1010", "FrmStorageREP", "仓库调拨"))
|
||
// {
|
||
// frmStorage.FrmStorageREP_Load(null, null);//如果已经被打开,执行一下窗体加载方法
|
||
// }
|
||
//}
|
||
}
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
#region 插入库区间调拨单
|
||
/// <summary>
|
||
/// 插入库区间调拨单
|
||
/// </summary>
|
||
public void InsertAreaRep(List<AreaRepModel> lstAreaModel)
|
||
{
|
||
string errtext = "";
|
||
try
|
||
{
|
||
errtext= IBussFactory<BussProcessPlan>.Instance().InsertAreaRep(lstAreaModel);
|
||
if (!string.IsNullOrEmpty(errtext))
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作失败!" + errtext);
|
||
}
|
||
else
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作成功!");
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("插入库区间调拨单出错了" + ex.Message);
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
#region 选择要加工的组合商品
|
||
private void DicGoods_Button_Click(object sender, EventArgs e)
|
||
{
|
||
if (DicGoods.SelectTable.Rows.Count > 0)
|
||
{
|
||
string err = string.Empty;
|
||
foreach (DataRow row in DicGoods.SelectTable.Rows)
|
||
{
|
||
if (infoList.FindAll(r => r.GOODS_ID == isnull(row["Goods_ID"])).Count > 0)//去掉重复的成品
|
||
{
|
||
continue;
|
||
}
|
||
List<GoodsMaterialModel> list = IBussFactory<BussGoodsMaterial>.Instance().GetGoodsMaterialList((new GoodsMaterialModel() { GOODS_ID = row["Goods_ID"].ToString() }));
|
||
if (list != null && list.Count > 0)
|
||
{
|
||
lstGoodMaterials.AddRange(list);//获得物料
|
||
}
|
||
//不区分大小写
|
||
infoList.Add(new PlanGoodsModel() { GOODS_ID = isnull(row["Goods_ID"]), GOODS_NAME = isnull(row["Goods_Name"]), GOODS_TYPE = isnull(row["Goods_TYPE"]), GOODS_TYPENAME = isnull(row["Goods_TYPENAME"]) });
|
||
}
|
||
}
|
||
GCPlanGoodsWork.DataSource = infoList;
|
||
GVPlanGoodsWork.RefreshData();
|
||
}
|
||
#endregion
|
||
private void txtPlanID_Leave(object sender, EventArgs e)
|
||
{
|
||
//if (!string.IsNullOrEmpty(txtPlanID.Text))
|
||
//{
|
||
// try
|
||
// {
|
||
// string strPlan = Newtonsoft.Json.JsonConvert.SerializeObject(new ProcessPlanModel() { PLAN_ID = txtPlanID.Text });
|
||
// string strPlanList = WebLockConfig.Instance.WebProcessPlan.execProcessPlanGetList(strPlan);
|
||
// List<ProcessPlanModel> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProcessPlanModel>>(strPlanList);
|
||
|
||
// if (list.Count > 0)
|
||
// {
|
||
// SystemCommon.ShowErrorMessageBox("该计划编号已存在!");
|
||
// txtPlanID.Text = "";
|
||
// txtPlanID.Focus();
|
||
// txtPlanID.Select();
|
||
// }
|
||
// }
|
||
// catch (Exception)
|
||
// {
|
||
|
||
// }
|
||
//}
|
||
}
|
||
private decimal isnum(object obj)
|
||
{
|
||
if (obj == null || obj == DBNull.Value)
|
||
{
|
||
return 0;
|
||
}
|
||
else
|
||
{
|
||
return Convert.ToDecimal(obj);
|
||
}
|
||
}
|
||
|
||
private void GVPlan_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
||
{
|
||
if (e.Column.FieldName == "STATUS")
|
||
{
|
||
if (e.Value != null && e.Value != DBNull.Value)
|
||
{
|
||
switch (e.Value.ToString().Trim())
|
||
{
|
||
case "0":
|
||
e.DisplayText = "未领取";
|
||
break;
|
||
case "1":
|
||
e.DisplayText = "已领取";
|
||
break;
|
||
case "2":
|
||
e.DisplayText = "已完成";
|
||
break;
|
||
case "3":
|
||
e.DisplayText = "作废";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void GVPlanGoods_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
||
{
|
||
if (e.Column.FieldName == "STATUS")
|
||
{
|
||
if (e.Value != null && e.Value != DBNull.Value)
|
||
{
|
||
switch (e.Value.ToString().Trim())
|
||
{
|
||
case "0":
|
||
e.DisplayText = "未完成";
|
||
break;
|
||
case "1":
|
||
e.DisplayText = "已完成";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private string isnull(object obj)
|
||
{
|
||
if (obj != null && obj != DBNull.Value)
|
||
{
|
||
return obj.ToString();
|
||
}
|
||
else
|
||
return "";
|
||
}
|
||
|
||
private void repositoryItemHyperLinkEdit1_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|