| | |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.DataAccess.Native.Json; |
| | | using DevExpress.XtraEditors; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.ToolBox; |
| | | using Gs.DevApp.UserControl; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | |
| | | } |
| | | } |
| | | |
| | | //private void getModel(string strGuid) |
| | | //{ |
| | | // bool isEdit = false; |
| | | // if (toolBarMenu1.currentAction == "add") return; |
| | | // if (toolBarMenu1.currentAction == "edit") isEdit = true; |
| | | // if (string.IsNullOrEmpty(strGuid)) |
| | | // { |
| | | // MsgHelper.Warning("请先选择你要操作的行!"); |
| | | // return; |
| | | // } |
| | | // var _obj = new |
| | | // { |
| | | // guid = strGuid //主建 |
| | | // }; |
| | | // try |
| | | // { |
| | | // var strJson = UtilityHelper.HttpPost("", |
| | | // _webServiceName + "GetModel", |
| | | // JsonConvert.SerializeObject(_obj)); |
| | | // var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | // if (_rtn.rtnCode > 0) |
| | | // { |
| | | // var dy = _rtn.rtnData; |
| | | // lbGuid.Text = strGuid; |
| | | // UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit); |
| | | // } |
| | | // else |
| | | // { |
| | | // MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // MsgHelper.Warning("提示:" + ex.Message); |
| | | // } |
| | | //} |
| | | private void getModel(string strGuid) |
| | | { |
| | | bool isEdit = false; |
| | |
| | | if (toolBarMenu1.currentAction == "edit") isEdit = true; |
| | | if (string.IsNullOrEmpty(strGuid)) |
| | | { |
| | | MsgHelper.Warning("请先选择你要操作的行!"); |
| | | ToolBox.MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | |
| | | // 构造请求参数对象 |
| | | var _obj = new |
| | | { |
| | | guid = strGuid //主建 |
| | | guid = strGuid, // 主键 |
| | | }; |
| | | |
| | | try |
| | | { |
| | | var strJson = UtilityHelper.HttpPost("", |
| | | _webServiceName + "GetModel", |
| | | JsonConvert.SerializeObject(_obj)); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | // 发送HTTP请求获取数据 |
| | | string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | var dy = _rtn.rtnData; |
| | | dynamic dy = _rtn.rtnData; |
| | | lbGuid.Text = strGuid; |
| | | UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit); |
| | | |
| | | // 绑定主表数据到界面控件 |
| | | List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>(); |
| | | |
| | | gvList.Add(gvMx1); |
| | | UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList); |
| | | |
| | | // ================== 第一个明细表(list)处理逻辑 ================== |
| | | // 显式指定Newtonsoft.Json.Linq.JObject |
| | | Newtonsoft.Json.Linq.JObject _job = Newtonsoft.Json.Linq.JObject.Parse(strJson); |
| | | Newtonsoft.Json.Linq.JArray array = new Newtonsoft.Json.Linq.JArray(); |
| | | foreach (var a in _job["rtnData"]["list"]) |
| | | { |
| | | array.Add(a); |
| | | } |
| | | DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString()); |
| | | |
| | | if (dt.Rows.Count > 0) |
| | | { |
| | | gcMx1.BindingContext = new BindingContext(); |
| | | gcMx1.DataSource = dt; |
| | | gcMx1.ForceInitialize(); |
| | | gvMx1.BestFitColumns(); |
| | | Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1); |
| | | } |
| | | else |
| | | { |
| | | Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |