From c115ac388af5a6928716f0146a75a2a42fb27d8e Mon Sep 17 00:00:00 2001 From: lg <999544862qq.com> Date: 星期日, 22 九月 2024 20:52:16 +0800 Subject: [PATCH] 仓库管理 --- DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs | 94 ++++++++++++++++++++++++++++++++--------------- 1 files changed, 64 insertions(+), 30 deletions(-) diff --git a/DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs b/DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs index 2056e48..bb2ac9a 100644 --- a/DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs +++ b/DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs @@ -1,4 +1,5 @@ 锘縰sing DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid.Views.Grid.ViewInfo; using DevExpress.XtraTreeList; using DevExpress.XtraTreeList.Nodes; using Gs.DevApp.Entity; @@ -8,6 +9,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Windows.Controls; using System.Windows.Forms; namespace Gs.DevApp.DevFrm.Warehouse @@ -107,7 +109,7 @@ /// <param name="e"></param> private void ToolBarMenu1_btnEscClick(object sender, EventArgs e) { - UtilityHelper.ChangeTab(xtraTabControl1, 0); + UtilityHelper.JumpToTab(xtraTabControl1, 0); } /// <summary> /// 鍒犻櫎浜嬩欢 @@ -116,13 +118,14 @@ /// <param name="e"></param> private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e) { - String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid")); + string rowGuid, rowName; + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, tlMenu); if (string.IsNullOrEmpty(rowGuid)) { - ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鍒犻櫎鐨勮锛�"); + ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); return; } - if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + tlMenu.FocusedNode.GetValue("name") + "銆戯紝纭畾鍒犻櫎鍚楋紵")) + if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵")) { return; } @@ -130,14 +133,13 @@ { guidList = rowGuid,//涓诲缓 }; - string strJson = ""; try { - strJson = UtilityHelper.HttpPost("", "Depot/DeleteModel", JsonConvert.SerializeObject(_obj)); - ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); + string strJson = UtilityHelper.HttpPost("", "Depot/DeleteModel", JsonConvert.SerializeObject(_obj)); + ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); if (_rtn.rtnCode > 0) { - UtilityHelper.ChangeTab(xtraTabControl1, 0); + UtilityHelper.JumpToTab(xtraTabControl1, 0); getPageList(1, UtilityHelper.GetPageSize()); } ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); @@ -154,7 +156,7 @@ /// <param name="e"></param> private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) { - UtilityHelper.ChangeTab(xtraTabControl1, 0); + UtilityHelper.JumpToTab(xtraTabControl1, 0); getPageList(1, UtilityHelper.GetPageSize()); } /// <summary> @@ -164,8 +166,11 @@ /// <param name="e"></param> private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e) { - String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid")); - string depotGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("upGuid")); + string rowGuid, rowName; + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, tlMenu); + string depotGuid = ""; + if (tlMenu.FocusedNode != null) + depotGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("upGuid")); if (!string.IsNullOrEmpty(depotGuid)) rowGuid = depotGuid; if (string.IsNullOrEmpty(rowGuid)) @@ -182,19 +187,12 @@ /// <param name="e"></param> private void ToolBarMenu1_btnAddClick(object sender, EventArgs e) { - UtilityHelper.ChangeTab(xtraTabControl1, 1); + UtilityHelper.JumpToTab(xtraTabControl1, 1); lbGuid.Text = ""; List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>(); gridViews.Add(gvMx1); - UtilityHelper.CleanValue(this.panel1.Controls, true, gridViews); - DataTable dt = new DataTable(); - foreach (GridColumn col in gvMx1.Columns) - { - dt.Columns.Add(col.FieldName, typeof(string)); - } - gridControl1.BindingContext = new BindingContext(); - gridControl1.DataSource = dt; - gridControl1.ForceInitialize(); + UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews); + _setTable(); } /// <summary> /// 淇濆瓨浜嬩欢 @@ -206,7 +204,7 @@ toolBarMenu1.isSetBtn = false; if (string.IsNullOrEmpty(txt_itemNo.Text.Trim())) { - Gs.DevApp.ToolBox.MsgHelper.Warning("缂栧彿鍙蜂笉鑳戒负绌猴紒"); + Gs.DevApp.ToolBox.MsgHelper.Warning("缂栧彿涓嶈兘涓虹┖锛�"); txt_itemNo.Focus(); return; } @@ -234,6 +232,23 @@ txt_isStatus.Focus(); return; } + gvMx1.UpdateCurrentRow(); + List<dynamic> lst = new List<dynamic>(); + for (int i = 0; i < gvMx1.DataRowCount; i++) + { + DataRow row = gvMx1.GetDataRow(i); + if (row != null) + { + lst.Add(new + { + guid = row["guid"].ToString(), + sectionCode = row["sectionCode"].ToString(), + sectionName = row["sectionName"].ToString(), + remark = row["remark"].ToString(), + isStatus = row["isStatusTxt"].ToString(), + }); + } + } var _obj = new { guid = lbGuid.Text.Trim(),//涓诲缓 @@ -243,11 +258,12 @@ category = txt_category.SelectedIndex, isWy = txt_isWy.SelectedIndex, isStatus = txt_isStatus.SelectedIndex, + list = lst }; try { string strJson = UtilityHelper.HttpPost("", "Depot/EditModel", JsonConvert.SerializeObject(_obj)); - ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); + ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); if (_rtn.rtnCode > 0) { @@ -255,7 +271,7 @@ toolBarMenu1.isSetBtn = true; List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>(); gridViews.Add(gvMx1); - UtilityHelper.ChangeEnable(this.panel1.Controls, false, gridViews); + UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false, gridViews); } } catch (Exception ex) @@ -275,7 +291,7 @@ try { string strReturn = UtilityHelper.HttpPost("", "Depot/GetListPage", json); - ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn); + ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn); DataTable dt = dd.rtnData.list; this.tlMenu.DataSource = dt; this.tlMenu.KeyFieldName = "guid"; @@ -303,7 +319,7 @@ ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); return; } - UtilityHelper.ChangeTab(xtraTabControl1, tabIdx); + UtilityHelper.JumpToTab(xtraTabControl1, tabIdx); var _obj = new { guid = strGuid,//涓诲缓 @@ -311,7 +327,7 @@ try { string strJson = UtilityHelper.HttpPost("", "Depot/GetModel", JsonConvert.SerializeObject(_obj)); - ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); + ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); if (_rtn.rtnCode > 0) { dynamic dy = _rtn.rtnData; @@ -327,9 +343,16 @@ array.Add(a); } DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString()); - gridControl1.BindingContext = new BindingContext(); - gridControl1.DataSource = dt; - gridControl1.ForceInitialize(); + if (dt.Rows.Count > 0) + { + gridControl1.BindingContext = new BindingContext(); + gridControl1.DataSource = dt; + gridControl1.ForceInitialize(); + } + else + { + _setTable(); + } } else ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); @@ -340,6 +363,17 @@ } } + private void _setTable() + { + DataTable dt = new DataTable(); + foreach (GridColumn col in gvMx1.Columns) + { + dt.Columns.Add(col.FieldName, typeof(string)); + } + gridControl1.BindingContext = new BindingContext(); + gridControl1.DataSource = dt; + gridControl1.ForceInitialize(); + } } } -- Gitblit v1.9.3