using CefSharp; using DevExpress.Data; using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Grid; using Gs.DevApp.Entity; using Gs.DevApp.ToolBox; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Windows.Forms; using System.Windows.Input; namespace Gs.DevApp.UserControl { public partial class SelectCgDhMx : XtraForm { private readonly string _webServiceName = "MesInvItemArnManager/"; private string suppId = ""; private string receiveOrgId = ""; /// /// /// /// 到货单号 public SelectCgDhMx(string _billNo) { InitializeComponent(); Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, null, "", null, null, false); getPageList(1, _billNo); btnIn.Click += (s, e) => { gridView1.PostEditor(); gridView1.UpdateCurrentRow(); var selectedGuids = new List(); // 存储勾选的guid集合 DataTable dt = this.gcMain.DataSource as DataTable; if (dt != null) { foreach (DataRow dr in dt.Rows) { string checkBox = dr["chkInt"].ToString(); string _guid = dr["guid"].ToString(); if (Gs.DevApp.ToolBox.UtilityHelper.ToCheck(checkBox)) { selectedGuids.Add(_guid); // 收集勾选的guid } } } // 关键:调用SelectMxBtn接口,传入勾选的guid集合 CallSelectMxBtnApi(selectedGuids); // 回传数据并关闭表单(保持原有逻辑) UpdateParent?.Invoke(this, new UpdateParentEventArgs { StringList = selectedGuids }); Close(); }; } /// /// 选择后的回调事件 /// public event EventHandler UpdateParent; /// /// /// 第几页 /// 每页几条 private void getPageList(int curPage,string billNo) { var _obj = new { currentPage = curPage, everyPageSize = 999999, sortName = "", keyWhere = "", // inBusType = (radioGroup1.SelectedIndex + 1),//1是采购,2是委外 // inReceiveOrgId = this.receiveOrgId,//组织 inBusType = "", inReceiveOrgId = "", inSupId = billNo//供应商 }; var json = JsonConvert.SerializeObject(_obj); try { var strReturn = UtilityHelper.HttpPost("",_webServiceName + "SelectMxForm", json); var dd = UtilityHelper.ReturnToTablePage(strReturn); var dt = dd.rtnData.list; gcMain.BindingContext = new BindingContext(); gcMain.DataSource = dt; gcMain.ForceInitialize(); gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1); } catch (Exception ex) { MsgHelper.Warning("提示:" + ex.Message); } } /// /// 调用SelectMxBtn接口,传递勾选的guid集合 /// /// 勾选的记录guid列表 private void CallSelectMxBtnApi(List selectedGuids) { if (selectedGuids == null || selectedGuids.Count == 0) { MsgHelper.Warning("请先勾选需要处理的明细"); return; } // 构建接口请求参数(与SelectMxForm接口格式保持一致) var requestParams = new{ guidList = selectedGuids}; try { // 序列化参数为JSON string jsonParams = JsonConvert.SerializeObject(requestParams); // 调用后端SelectMxBtn接口(与SelectMxForm同样使用HttpPost) string apiUrl = _webServiceName + "SelectMxBtn"; // 接口地址 string response = UtilityHelper.HttpPost("", apiUrl, jsonParams); var _rtn = UtilityHelper.ReturnToDynamic(response); if (_rtn.rtnCode > 0) { MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg); } else MsgHelper.ShowError("提示:" + _rtn.rtnMsg); } catch (Exception ex) { MsgHelper.ShowError("提示:" + ex.Message); } } } }