using System; using System.Collections.Generic; using System.Data; using WMS.Business; using WMS.Business.Base; using WMS.Business.CK; using WMS.Common; using WMS.Frm.Base; using WMS.Model.Base; using WMS.Model.CK; namespace WMS.FrmSC { public partial class FrmCgOrder : FormBase { public FrmCgOrder() { InitializeComponent(); } /// /// 绑定订单任务 /// void BindOrder(string sts) { CgOrder order = new CgOrder(); //order.ENDDATE =dateEdit1.DateTime; //order.LATEDATE = dateEdit2.DateTime; order.PROVIDER_ID = ct_provider.TextBoxValue; order.STS = sts; List listOrder= IBussFactory.Instance().GetTableOrder(order); if(listOrder!=null) { bindingSource2.Clear(); bindingSource1.DataSource = listOrder; if(listOrder.Count>0) { string orderID = listOrder[0].CGORDERID; BindOrderInfo(orderID); if (listOrder[0].STS == "0") { if (frmButtonItem.ContainsKey("Check")) { frmButtonItem["Check"].Enabled = true; } else { frmButtonItem["Check"].Enabled = false; } } if (listOrder[0].STS == "1") { if (frmButtonItem.ContainsKey("NoCheck")) { frmButtonItem["NoCheck"].Enabled = true; } else { frmButtonItem["NoCheck"].Enabled = false; } } } } } void BindOrderInfo(string orderId) { List listOrder = IBussFactory.Instance().GetCgOrderInfo(orderId); if(listOrder!=null) { bindingSource2.DataSource = listOrder; } } /// /// 计划任务查询 /// void PlanOrderData() { listCg = IBussFactory.Instance().GetOrderPlanData(); if (listCg != null) { bindingSource4.DataSource = listCg; if (listCg.Count > 0) { //tabPane1.SelectedPageIndex = 2; gridView2.ExpandAllGroups(); gridView2.FocusedRowHandle = 0; frmButtonItem["AddNewDataSource"].Enabled = true; } } } public override void Add() { xtraTabPage2.PageEnabled = true; xtr_Task.SelectedTabPageIndex = 1; PlanOrderData(); frmButtonItem["Save"].Enabled = false; ctrlButtons2.Visible = true; } public override void Save() { if (listCginfo.Count == 0) { return; } foreach (CgOrderInfo info in listCginfo) { if (info.CGNUM == 0) { SystemCommon.ShowInfoMessageBox("采购数量不能为零"); return; } if (info.PROVIDER_ID == "") { SystemCommon.ShowInfoMessageBox("没有选择供应商,请选择供应商"); return; } } if (SystemCommon.ShowMessageBoxResult("确定要保存修改") == System.Windows.Forms.DialogResult.OK) { string err = IBussFactory.Instance().EditOrderInfo(listCginfo); if (err.Trim().Length > 0) { SystemCommon.ShowInfoMessageBox("任务生成失败"); return; } BindOrder("0"); SystemCommon.ShowInfoMessageBox("任务生成成功"); xtraTabPage2.PageEnabled = false; xtr_Task.SelectedTabPageIndex = 0; listCginfo.Clear(); } } List selecPlan = new List(); List listCg = new List(); List listCginfo = new List(); public void AddNewDataSource() { if(gridView2.RowCount==0) { return; } if (gridView2.FocusedRowHandle < 0) { return; } string orderID = gridView2.GetFocusedRowCellValue("ORDERID").ToString(); selecPlan = listCg.FindAll(r => r.ORDERID == orderID); if(selecPlan!=null) { if(selecPlan.Count>0) { foreach (CgOrderPlan plan in selecPlan) { CgOrderInfo info = new CgOrderInfo(); info.GOODS_ID = plan.GOODS_ID; info.GOODS_NAME = plan.GOODS_NAME; info.CGNUM = plan.CGNUM; info.ORDERID = plan.ORDERID; if (listCginfo.Exists(r => r.GOODS_ID == plan.GOODS_ID)) { CgOrderInfo oldData = listCginfo.Find(r => r.GOODS_ID == plan.GOODS_ID); if(oldData!=null) { oldData.CGNUM = plan.CGNUM + oldData.CGNUM; } } else { listCginfo.Add(info); } } if (listCginfo != null) { if (listCginfo.Count > 0) { bindingSource3.DataSource = listCginfo; tabPane1.SelectedPageIndex = 0; } } } } } private void FrmCgOrder_Load(object sender, EventArgs e) { dateEdit1.DateTime = DateTime.Now.Date.AddDays(-30); dateEdit2.DateTime = DateTime.Now.Date; BindOrder("0"); } public void Close() { if (gdv_order.RowCount == 0) { return; } if (gdv_order.FocusedRowHandle < 0) { SystemCommon.ShowInfoMessageBox("选择要关闭的数据"); return; } if (SystemCommon.ShowMessageBoxResult("确定要关闭单据") == System.Windows.Forms.DialogResult.OK) { string orderId = gdv_order.GetFocusedRowCellValue("CGORDERID").ToString(); string errtext = IBussFactory.Instance().CheckData(orderId, "10"); if (errtext.Trim().Length > 0) { SystemCommon.ShowInfoMessageBox("关闭失败" + errtext); return; } BindOrder("0"); //ch_sh.Checked = false; } } private void gridView2_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { if (gridView2.RowCount == 0) { return; } } private void ctrlButtons1_Click(object sender, EventArgs e) { if (infoSelectD == null) { SystemCommon.ShowInfoMessageBox("没有选采购的物料"); return; } if (gridView6.RowCount==0) { SystemCommon.ShowInfoMessageBox("请选配置该物料的供应商"); return; } string provider = gridView6.GetFocusedRowCellValue("PROVIDER_ID").ToString(); string providerName = gridView6.GetFocusedRowCellValue("PROVIDER_NAME").ToString(); infoSelectD.PROVIDER_ID = provider; infoSelectD.PROVIDER_NAME = providerName; infoSelectD.CGJG =decimal.Parse(gridView6.GetFocusedRowCellValue("GOODS_PRICE").ToString()); infoSelectD.ORDER_PRICE = infoSelectD.CGJG * infoSelectD.CGNUM; gdv_info.RefreshData(); } /// ///选择物料 /// /// /// private void ctrlDictonary1_Button_Click(object sender, EventArgs e) { if (ctr_goods.SelectTable.Rows.Count == 0) { return; } //商品集合 List listGoodsInfoModel = ConvertHelper.ConvertToList(ctr_goods.SelectTable); foreach (GoodsInfoModel good in listGoodsInfoModel) { CgOrderInfo info = new CgOrderInfo(); info.GOODS_ID = good.GOODS_ID; info.GOODS_NAME = good.GOODS_NAME; info.CGNUM = 0; info.CGORDERID =""; if (!listCginfo.Exists(r => r.GOODS_ID == good.GOODS_ID)) { listCginfo.Add(info); } } if (listCginfo != null) { bindingSource3.DataSource = listCginfo; // gridControlCustom5.Refresh(); gdv_info.RefreshData(); } } //void BindProviderData(string goodsId) //{ // List providerGoods = IBussFactory.Instance().GetGoodsPrividerDataTale(goodsId); // if (providerGoods != null) // { // bindingSource5.DataSource = providerGoods; // } //} void BindProviderData(string goodsId) { List providerGoods = IBussFactory.Instance().GetProviderGoodsData(goodsId); if (providerGoods != null) { bindingSource5.DataSource = providerGoods; } } CgOrderInfo infoSelectD = new CgOrderInfo(); private void gridView5_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { if (gdv_info.RowCount < 0) { return; } if (gdv_info.FocusedRowHandle < 0) { return; } infoSelectD = gdv_info.GetFocusedRow() as CgOrderInfo; string goodsId = gdv_info.GetFocusedRowCellValue("GOODS_ID").ToString(); // infoSelectD = listCginfo.Find(r => r.GOODS_ID == goodsId); BindProviderData(goodsId); } public void NoCheck() { if (gdv_order.RowCount == 0) { return; } if (gdv_order.FocusedRowHandle < 0) { SystemCommon.ShowInfoMessageBox("选择要审核的数据"); return; } if (SystemCommon.ShowMessageBoxResult("确定要反审核") == System.Windows.Forms.DialogResult.OK) { string orderId = gdv_order.GetFocusedRowCellValue("CGORDERID").ToString(); string errtext = IBussFactory.Instance().CheckData(orderId, "0"); if (errtext.Trim().Length > 0) { SystemCommon.ShowInfoMessageBox("审核失败" + errtext); return; } BindOrder("0"); ch_sh.Checked = false; } } public void Edit() { if (gdv_order.RowCount == 0) { return; } if (gdv_order.FocusedRowHandle < 0) { SystemCommon.ShowInfoMessageBox("选择要编辑的数据"); return; } string sts = gdv_order.GetFocusedRowCellValue("STS").ToString(); if(sts!="0") { SystemCommon.ShowInfoMessageBox("只能对未审核的单据进行编辑"); return; } listCginfo=(List)bindingSource2.DataSource; if(listCginfo!=null) { bindingSource3.DataSource = listCginfo; } xtr_Task.SelectedTabPageIndex = 1; xtraTabPage2.PageEnabled = true; ctrlButtons2.Visible = false; frmButtonItem["Save"].Enabled = true; } public void Check() { if(gdv_order.RowCount==0) { return; } if(gdv_order.FocusedRowHandle<0) { SystemCommon.ShowInfoMessageBox("选择要审核的数据"); return; } string orderId = gdv_order.GetFocusedRowCellValue("CGORDERID").ToString();// GetRowCellValue() string errtext = IBussFactory.Instance().CheckData(orderId,"1"); if(errtext.Trim().Length>0) { SystemCommon.ShowInfoMessageBox("审核失败" + errtext); return ; } BindOrder("0"); } private void ctrlButtons2_Click(object sender, EventArgs e) { if (listCginfo.Count == 0) { return; } foreach (CgOrderInfo info in listCginfo) { if (info.CGNUM == 0) { SystemCommon.ShowInfoMessageBox("采购数量不能为零"); return; } if (info.PROVIDER_ID == "") { SystemCommon.ShowInfoMessageBox("没有选择供应商,请选择供应商"); return; } } if (SystemCommon.ShowMessageBoxResult("确认生成采购单") == System.Windows.Forms.DialogResult.OK) { string err= IBussFactory.Instance().AddOrderPlanData(listCginfo, userData.USER_ID); if(err.Trim().Length>0) { SystemCommon.ShowInfoMessageBox("任务生成失败"); return; } BindOrder("0"); SystemCommon.ShowInfoMessageBox("任务生成成功"); xtraTabPage2.PageEnabled = false; xtr_Task.SelectedTabPageIndex = 0; listCginfo.Clear(); } } private void ctrlButtons7_Click(object sender, EventArgs e) { if (listCginfo == null) { return; } if (infoSelectD == null) { SystemCommon.ShowInfoMessageBox("没有选采购的物料"); return; } gdv_info.CloseEditor(); gdv_info.UpdateCurrentRow(); listCginfo.Remove(infoSelectD); //if (listCginfo!=null) //bindingSource3.DataSource = listCginfo; bindingSource5.Clear(); gdv_info.RefreshData(); } private void ctrlButtons4_Click_1(object sender, EventArgs e) { } private void gdv_order_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { if(gdv_order.RowCount==0) { return; } if(gdv_order.FocusedRowHandle<0) { return; } string orderID = gdv_order.GetFocusedRowCellValue("CGORDERID").ToString(); BindOrderInfo(orderID); string sts = gdv_order.GetFocusedRowCellValue("STS").ToString(); if (sts=="0") { if (frmButtonItem.ContainsKey("Check")) { frmButtonItem["Check"].Enabled = true; } else { frmButtonItem["Check"].Enabled = false; ; } // if (frmButtonItem["Save"]. ) //{ //} } } private void gdv_order_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { if (e.Column.FieldName == "STS") { 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; case "5": e.DisplayText = "已关闭"; break; } } } } private void ch_sh_CheckedChanged(object sender, EventArgs e) { if(ch_sh.Checked) { BindOrder("1"); } else { BindOrder("0"); } } private void ck_end_CheckedChanged(object sender, EventArgs e) { if (ck_end.Checked) { BindOrder("2"); } else { BindOrder("0"); } } private void ctr_goods_Load(object sender, EventArgs e) { } } }