443 lines
14 KiB
C#
443 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.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using WMS.Business;
|
|
using WMS.Model.CK;
|
|
using WMS.Business.CK;
|
|
using WMS.Frm.Base;
|
|
using WMS.Common;
|
|
using WMS.Model.Stock;
|
|
using WMS.Model.Base;
|
|
using WMS.Ctrl;
|
|
using WMS.Business.Base;
|
|
|
|
namespace WMS.FrmSC
|
|
{
|
|
public partial class FrmCgPlan : FormBase
|
|
{
|
|
public FrmCgPlan()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询物料
|
|
/// </summary>
|
|
List<OrderDetailModel> checkGoodsInfo = new List<OrderDetailModel>();
|
|
/// <summary>
|
|
/// 查询单号
|
|
/// </summary>
|
|
void BindOrder()
|
|
{
|
|
string benDate = D_begDate.Value.ToShortDateString();
|
|
string endDate = D_endDate.Value.ToShortDateString();
|
|
List<OrdersModel> orderData= IBussFactory<BussOrders>.Instance().GetOrderDate(benDate, endDate);
|
|
if(orderData!=null)
|
|
{
|
|
bindingSource1.DataSource = orderData;
|
|
if(orderData.Count>0)
|
|
{
|
|
bussOrderID = orderData[0].ORDER_ID;
|
|
BindOrderData(bussOrderID);
|
|
}
|
|
}
|
|
xtraTabControl1.SelectedTabPageIndex = 0;
|
|
tabPane1.SelectedPageIndex = 0;
|
|
}
|
|
void BindOrderData(string orderID)
|
|
{
|
|
OrderDetailModel detail = new OrderDetailModel();
|
|
detail.ORDER_ID = orderID;
|
|
List<OrderDetailModel> orderDetailData = IBussFactory<BussOrderDetail>.Instance().GetOrderDetail(detail);
|
|
if (orderDetailData != null)
|
|
{
|
|
bindingSource2.DataSource = orderDetailData;
|
|
|
|
|
|
}
|
|
}
|
|
private void ctrlButtons1_Click(object sender, EventArgs e)
|
|
{
|
|
BindOrder();
|
|
|
|
}
|
|
string bussOrderID = "";
|
|
private void gridView4_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
|
{
|
|
if(gridView4.RowCount==0)
|
|
{
|
|
return;
|
|
}
|
|
bussOrderID = gridView4.GetFocusedRowCellValue("ORDER_ID").ToString();
|
|
|
|
BindOrderData(bussOrderID);
|
|
}
|
|
|
|
private void FrmCgPlan_Load(object sender, EventArgs e)
|
|
{
|
|
D_begDate.Value = D_begDate.Value.AddDays( - 30);
|
|
BindOrder();
|
|
PlanOrderData();
|
|
tabPane1.SelectedPageIndex = 0;
|
|
xtraTabControl1.SelectedTabPageIndex = 1;
|
|
}
|
|
/// <summary>
|
|
/// 计划任务查询
|
|
/// </summary>
|
|
void PlanOrderData()
|
|
{
|
|
List<CgOrderPlan> listCg = IBussFactory<BussOrders>.Instance().GetOrderPlanData();
|
|
if(listCg!=null)
|
|
{
|
|
bindingSource4.DataSource = listCg;
|
|
if(listCg.Count>0)
|
|
{
|
|
tabPane1.SelectedPageIndex = 2;
|
|
gridView2.ExpandAllGroups();
|
|
gridView2.FocusedRowHandle = 0;
|
|
}
|
|
}
|
|
}
|
|
private void gridView5_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
|
{
|
|
if(e.Column.Name== "colNOWNUM")
|
|
{
|
|
decimal vl = decimal.Parse(e.Value.ToString());
|
|
decimal nowvl = decimal.Parse( gridView5.GetFocusedRowCellValue("BUY_NUM").ToString());
|
|
if(vl>nowvl)
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("本次的采购数量不能大于剩余数量");
|
|
gridView5.SetRowCellValue(gridView5.FocusedRowHandle, "NOWNUM", 0);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 查询库存
|
|
/// </summary>
|
|
void BindMiStock(string goodsId)
|
|
{
|
|
bool sTrue = checkBox4.Checked;
|
|
List<MIStockModel> orderData = IBussFactory<BussOrders>.Instance().GetGoodsData(goodsId, sTrue);
|
|
if (orderData != null)
|
|
{
|
|
bgc.DataSource = orderData;
|
|
}
|
|
}
|
|
private void checkBox4_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if(checkBox4.Checked)
|
|
{
|
|
ct_Import.Visible = false;
|
|
ct_Edit.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
ct_Import.Visible =true;
|
|
ct_Edit.Visible = true;
|
|
|
|
}
|
|
}
|
|
void BindTreeList()
|
|
{
|
|
this.treeListCustom1.Nodes.Clear();
|
|
|
|
}
|
|
private void ctrlButtons6_Click(object sender, EventArgs e)
|
|
{
|
|
if(checkGoodsInfo.Count==0)
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("没有选择物料,请选择要采购的物料");
|
|
return;
|
|
}
|
|
|
|
LoadForm load = new LoadForm();
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 50);
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在处理数据,请等待....");
|
|
Dictionary<string, decimal> goodsId = new Dictionary<string, decimal>();
|
|
foreach (OrderDetailModel model in checkGoodsInfo)
|
|
{
|
|
goodsId.Add(model.GOOD_ID, model.NOWNUM);
|
|
|
|
}
|
|
|
|
List<CgOrderPlan> listCg = IBussFactory<BussOrders>.Instance().GetPlanExce(goodsId, bussOrderID);
|
|
if(listCg!=null)
|
|
{
|
|
bindingSource3.DataSource = listCg;
|
|
if (listCg.Count > 0)
|
|
xtraTabControl1.SelectedTabPageIndex = 1;
|
|
treeListCustom1.ExpandAll();
|
|
}
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|
}
|
|
|
|
private void gridView5_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
|
{
|
|
if(e.Column.Name== "colIsCheck1")
|
|
{
|
|
bool a = bool.Parse(e.Value.ToString());
|
|
if(a)
|
|
{
|
|
OrderDetailModel detail = new OrderDetailModel();
|
|
detail = gridView5.GetFocusedRow() as OrderDetailModel;
|
|
checkGoodsInfo.Add(detail);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void ctrlButtons5_Click(object sender, EventArgs e)
|
|
{
|
|
if (treeListCustom1.Nodes.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (selectdetail!=null)
|
|
{
|
|
treeListCustom1.Nodes.Remove(selectdetail);
|
|
if(selectdetail.Nodes.Count>0)
|
|
{
|
|
foreach (DevExpress.XtraTreeList.Nodes.TreeListNode noDe in selectdetail.Nodes)
|
|
{
|
|
treeListCustom1.Nodes.Remove(noDe);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
DevExpress.XtraTreeList.Nodes.TreeListNode selectdetail = null;
|
|
|
|
|
|
private void xtraTabControl1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
void AddListData(DevExpress.XtraTreeList.Nodes.TreeListNode tree)
|
|
{
|
|
|
|
|
|
if (tree.Nodes.Count > 0)
|
|
{
|
|
|
|
foreach (DevExpress.XtraTreeList.Nodes.TreeListNode tre in tree.Nodes)
|
|
AddListData(tre);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
CgOrderPlan order = new CgOrderPlan();
|
|
|
|
order.GOODS_ID = tree[treeListColumn1].ToString();
|
|
|
|
order.CGNUM = decimal.Parse(tree[colCGNUM].ToString());
|
|
|
|
order.FGOODSID = tree[colFGOODSID].ToString();
|
|
|
|
order.XQNUM = decimal.Parse(tree[colXQNUM].ToString());
|
|
|
|
order.TASKID = tree[colTASKID].ToString();
|
|
order.CREATEMEN = userData.USER_ID;
|
|
if (order.CGNUM==0)
|
|
{
|
|
listOrder.Clear();
|
|
SystemCommon.ShowInfoMessageBox("数量不能为0");
|
|
return;
|
|
}
|
|
|
|
listOrder.Add(order);
|
|
|
|
}
|
|
|
|
}
|
|
List<CgOrderPlan> listOrder = new List<CgOrderPlan>();
|
|
private void ctrlButtons2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (treeListCustom1.Nodes.Count==0)
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("没有要选择采购的物料");
|
|
return;
|
|
}
|
|
foreach (DevExpress.XtraTreeList.Nodes.TreeListNode tre in treeListCustom1.Nodes)
|
|
{
|
|
|
|
AddListData(tre);
|
|
}
|
|
if(listOrder.Count>0)
|
|
{
|
|
|
|
string errText= IBussFactory<BussOrders>.Instance().ExcePlanOrder(listOrder);
|
|
if(errText.Trim().Length>0)
|
|
{
|
|
|
|
SystemCommon.ShowInfoMessageBox(errText);
|
|
return;
|
|
}
|
|
PlanOrderData();
|
|
}
|
|
|
|
}
|
|
|
|
private void treeListCustom1_Click(object sender, EventArgs e)
|
|
{
|
|
if (treeListCustom1.Nodes.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
selectdetail = treeListCustom1.FocusedNode;
|
|
|
|
}
|
|
|
|
private void ctrlButtons9_Click(object sender, EventArgs e)
|
|
{
|
|
if(gridView2.RowCount==0)
|
|
{
|
|
return;
|
|
}
|
|
if(gridView2.FocusedRowHandle<0)
|
|
{ return; }
|
|
if(DialogResult.OK == SystemCommon.ShowMessageBoxResult("确定要关闭单据"))
|
|
{
|
|
string orderID = gridView2.GetFocusedRowCellValue("ORDERID").ToString();
|
|
IBussFactory<BussOrders>.Instance().UpdatePlanClose(orderID, userData.USER_ID);
|
|
PlanOrderData();
|
|
}
|
|
|
|
}
|
|
|
|
private void ctrlButtons3_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
void BindProviderData(string goodsId)
|
|
{
|
|
List<GoodsProviderModel> providerGoods = IBussFactory<BussProvider>.Instance().GetProviderGoodsData(goodsId);
|
|
if (providerGoods != null)
|
|
{
|
|
bindingSource5.DataSource = providerGoods;
|
|
|
|
}
|
|
}
|
|
private void gridView2_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
|
{
|
|
if(gridView2.RowCount<0)
|
|
{
|
|
return;
|
|
}
|
|
if(gridView2.FocusedRowHandle<0)
|
|
{
|
|
return;
|
|
}
|
|
string goodsId = gridView2.GetFocusedRowCellValue("GOODS_ID").ToString();
|
|
BindProviderData(goodsId);
|
|
}
|
|
|
|
private void ctrlButtons4_Click(object sender, EventArgs e)
|
|
{
|
|
//if (provider == "")
|
|
//{
|
|
// SystemCommon.ShowInfoMessageBox("供应商没有选择");
|
|
// return;
|
|
//}
|
|
if (gridView2.RowCount == 0)
|
|
{
|
|
return;
|
|
}
|
|
if (gridView2.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
if (DialogResult.OK == SystemCommon.ShowMessageBoxResult("确定要清除供应商"))
|
|
{
|
|
string order = gridView2.GetFocusedRowCellValue("ORDERID").ToString();
|
|
IBussFactory<BussOrders>.Instance().UpdatePlanProvider(order, "");
|
|
provider = "";
|
|
|
|
PlanOrderData();
|
|
}
|
|
|
|
}
|
|
|
|
private void ctrlButtons7_Click(object sender, EventArgs e)
|
|
{
|
|
if(provider=="")
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("供应商没有选择");
|
|
return;
|
|
}
|
|
if(gridView2.RowCount==0)
|
|
{
|
|
return;
|
|
}
|
|
if(gridView2.FocusedRowHandle<0)
|
|
{
|
|
return;
|
|
}
|
|
string order = gridView2.GetFocusedRowCellValue("ORDERID").ToString();
|
|
IBussFactory<BussOrders>.Instance().UpdatePlanProvider(order, provider);
|
|
provider = "";
|
|
PlanOrderData();
|
|
|
|
}
|
|
string provider = "";
|
|
|
|
private void gridView3_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
|
{
|
|
if(gridView3.RowCount==0)
|
|
{
|
|
return;
|
|
}
|
|
provider = gridView3.GetFocusedRowCellValue("PROVIDER_ID").ToString();
|
|
}
|
|
|
|
private void ctrlDictonary1_Button_Click(object sender, EventArgs e)
|
|
{
|
|
if (ctr_goods.SelectTable.Rows.Count == 0)
|
|
{
|
|
|
|
return;
|
|
}
|
|
List<CgOrderPlan> listCg = new List<CgOrderPlan>();
|
|
//商品集合
|
|
List< GoodsInfoModel> listGoodsInfoModel = ConvertHelper<GoodsInfoModel>.ConvertToList(ctr_goods.SelectTable);
|
|
|
|
foreach (GoodsInfoModel good in listGoodsInfoModel)
|
|
{
|
|
CgOrderPlan cgGoodData = new CgOrderPlan();
|
|
cgGoodData.GOODS_ID = good.GOODS_ID;
|
|
cgGoodData.GOODS_NAME = good.GOODS_NAME;
|
|
cgGoodData.CGNUM =0;
|
|
cgGoodData.FGOODSID = "";
|
|
cgGoodData.XQNUM = 0;
|
|
cgGoodData.TASKID = "";
|
|
cgGoodData.SEMISTS = false;
|
|
cgGoodData.BUY_NUM = 0;
|
|
cgGoodData.OCCUPY =0;
|
|
cgGoodData.FGOODSNAMAE ="";
|
|
listCg.Add(cgGoodData);
|
|
|
|
|
|
}
|
|
if (listCg != null)
|
|
{
|
|
bindingSource3.DataSource = listCg;
|
|
treeListCustom1.Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|