一、Dev
一、获取选中的表格
// MessageBox.Show(gridview_Parent.GetFocusedDataRow()["series"].ToString());//获取焦点的数据行
var s = GridParentView.GetFocusedDataRow()?["group_num_id"].ToString();//无数据焦点行不存在的 ?处理写法
private void Btn_DelchildNode_Click(object sender, EventArgs e) { //var selectedItems = gridview_ChildNode.GetSelectedRows().ToList().Select(i => gridview_ChildNode.GetRow(i).ToSpecObject<IntelligentAllotChildNode>()).ToList(); //gridview_ChildNode.DeleteSelectedRows(); int[] rows = gridview_Child.GetSelectedRows(); //获取GridView 选中的数据行信息 if (rows.Length == 0) { MessageHelper.InfoMsg("请勾选一行记录。"); return; } else { List<int> selectRows; selectRows = this.gridview_Child.GetSelectedRows().ToList(); Newtonsoft.Json.Linq.JArray JsonArray = new Newtonsoft.Json.Linq.JArray(); string series_id = null; foreach (int i in selectRows) { var ss = this.gridview_Child.GetDataRow(i)["series_id"].ToString(); JsonArray.Add(new JObject() { new JProperty("series",this.gridview_Child.GetDataRow(i)["series_id"].ToString()), new JProperty("group_num_id",this.gridview_Child.GetDataRow(i)["group_num_id_"].ToString()), new JProperty("sub_unit_num_id",this.gridview_Child.GetDataRow(i)["sub_unit_num_id"].ToString()), }); series_id = this.gridview_Child.GetDataRow(i)["group_num_id_"].ToString(); } bool res = UnitOfWork<DAL_AllocationMgt>.Resolve.ChildNodedel(JsonArray, out string errors); if (res) { MessageHelper.InfoMsg("删除成功"); ChildNodeDataPage.ClearQueryField(); ChildNodeDataPage.IN_SQLID = "XDLERP-SCM-0043"; ChildNodeDataPage.IN_GRID_CONTROL = ChildNodeData; if (series_id != null) ChildNodeDataPage.AddQueryField("group_num_id", series_id); ChildNodeDataPage.InitPages(); } else { MessageHelper.InfoMsg(errors); } } }
private void Btn_Del_Click(object sender, EventArgs e) { int[] rows = gridView.GetSelectedRows(); //获取GridView 选中的数据行信息 if (rows.Length == 0) { MessageHelper.InfoMsg("请勾选一行记录。"); return; } else { List<int> selectRows; List<int> custcode = new List<int>(); selectRows = this.gridView.GetSelectedRows().ToList(); foreach (int i in selectRows) { custcode.Add(int.Parse(this.gridView.GetDataRow(i)["series"].ToString())); } //string depaid = string.Join(",", custcode); System.Int32[] str = custcode.ToArray(); bool result = UnitOfWork<DAL>.Resolve.SupplierOrderDel(str, out string error); if (result) { MessageHelper.InfoMsg("删除成功。"); SearchData(); } } }
点到为止