From b084bd77d01a94c8f0a2d20c86a1f45ba7c8a23c Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期六, 19 四月 2025 14:08:05 +0800 Subject: [PATCH] 页面跳转 --- DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs | 390 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 199 insertions(+), 191 deletions(-) diff --git a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs index 4e298cb..f90bf5f 100644 --- a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs +++ b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs @@ -1,13 +1,12 @@ -using DevExpress.XtraGrid.Views.Grid; -using DevExpress.XtraGrid.Views.Grid.ViewInfo; 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; -using System.Drawing; +using System.Threading.Tasks; using System.Windows.Forms; namespace Gs.DevApp.DevFrm @@ -19,42 +18,104 @@ public Frm_ArrivalBarcode() { InitializeComponent(); - this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick; - this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick; - this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick; this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick; - this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1; - this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick; this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick; - gcMain.MouseDoubleClick += GcMain_MouseDoubleClick; - getPageList(1, UtilityHelper.GetPageSize()); + this.toolBarMenu1.getXmlConfig(); + Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1); + Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx2); + Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, "", "", (value) => + { + Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0); + }, tips); + Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) => + { + getModel(value); + }, (value) => + { + getPageList(this.pageBar1.CurrentPage); + }, lbGuid); + getPageList(1); pageBar1.PagerEvent += PageBar1_PagerEvent; - gridView1.CustomDrawRowIndicator += (s, e) => + this.ucBtnPrint1.btnDesignClick += (s, e) => { - if (e.Info.IsRowIndicator && e.RowHandle >= 0) - { - e.Info.DisplayText = (e.RowHandle + 1).ToString(); - } + ucBtnPrint1.rptParameter = "rpt_Arrival{}"; }; - gridView1.CustomDrawEmptyForeground += (s, e) => + this.ucBtnPrint1.btnReportClick += (s, e) => { - string str = "鏆傛湭鏌ユ壘鍒板尮閰嶇殑鏁版嵁!"; - Font f = new Font("寰蒋闆呴粦", 16); - Rectangle r = new Rectangle(gridView1.GridControl.Width / 2 - 100, e.Bounds.Top + 45, e.Bounds.Right - 5, e.Bounds.Height - 5); - e.Graphics.DrawString(str, f, Brushes.Gray, r); + string rowGuid = lbMxGuid.Text.Trim(); + ucBtnPrint1.guidKey = rowGuid; + if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_iCount_1.Text.Trim())) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("璇烽�夋嫨鎵撳嵃鏉$爜寮犳暟锛�"); + txt_iCount_1.Focus(); + this.ucBtnPrint1.rptParameter = "return false"; + return; + } + if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_psnQty_1.Text.Trim())) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("璇烽�夋嫨鎵撳嵃鏉$爜鏁伴噺锛�"); + txt_psnQty_1.Focus(); + this.ucBtnPrint1.rptParameter = "return false"; + return; + } + if (lbMxGuid.Text.Trim().Length < 10) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("璇烽�夋嫨鎵撳嵃鐨勮锛�"); + this.ucBtnPrint1.rptParameter = "return false"; + return; + } + this.ucBtnPrint1.rptParameter = "rpt_Arrival{" + lbMxGuid.Text.Trim() + + "," + "" + + "," + Gs.DevApp.ToolBox.UtilityHelper.PrintYuLiang(radOut).ToString() + + "," + txt_iCount_1.Text.Trim() + + "," + txt_psnQty_1.Text.Trim() + + "}"; + txt_iCount_1.Text = ""; + txt_psnQty_1.Text = ""; + }; + gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged; + //鑷姩璁$畻鎵撳嵃閲� + txt_psnQty_1.TextChanged += (s, e) => + { + Gs.DevApp.ToolBox.UtilityHelper.PrintJiSuan(txt_psnQty_1, txt_iCount_1, txt_kQty.Text.Trim(), radOut); + }; + radOut.SelectedIndexChanged += (s, e) => + { + Gs.DevApp.ToolBox.UtilityHelper.PrintAuto(txt_psnQty_1, txt_iCount_1, radOut); }; } - - /// <summary> - /// 鍙屽嚮浜嬩欢 - /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> - private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e) + private void GridView1_ColumnFilterChanged(object sender, EventArgs e) { - string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid"); - if (!string.IsNullOrEmpty(rowGuid)) - getModel(rowGuid, false, 999); + _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1); + Task.Delay(100); + getPageList(1); + } + private void GvMx1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) + { + if (e.FocusedRowHandle >= 0) + { + DataRow row = gvMx1.GetDataRow(e.FocusedRowHandle); + lbMxGuid.Text = row["guid"].ToString(); + txtWlid.Text = row["itemNo"].ToString(); + txtWlgg.Text = row["itemModel"].ToString(); + txtWlmc.Text = row["itemName"].ToString(); + txtQuantity.Text = row["quantity"].ToString();//鏈鏀惰揣鎬婚噺 + txt_yQty.Text = row["yQty"].ToString();//宸叉墦鍗版�婚噺 + txt_kQty.Text = row["kQty"].ToString(); //鍙墦鍗版�婚噺 + } + else + { + lbMxGuid.Text = ""; + ucBtnPrint1.guidKey = ""; + txtWlid.Text = ""; + txtWlgg.Text = ""; + txtWlmc.Text = ""; + txtQuantity.Text = ""; + txt_yQty.Text = ""; + txt_kQty.Text = ""; + txt_psnQty_1.Text = ""; + txt_iCount_1.Text = ""; + } } /// <summary> /// 鍒嗛〉浜嬩欢 @@ -63,7 +124,7 @@ /// <param name="pageSize"></param> private void PageBar1_PagerEvent(int curPage, int pageSize) { - getPageList(curPage, pageSize); + getPageList(curPage); } /// <summary> /// 鏌ヨ浜嬩欢 @@ -72,7 +133,10 @@ /// <param name="e"></param> private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e) { - Gs.DevApp.UserControl.ShowFilter frm = new Gs.DevApp.UserControl.ShowFilter(gridView1.Columns, _filterList); + gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged; + gridView1.ActiveFilter.Clear(); + gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged; + var frm = new ShowFilter(gridView1.Columns, _filterList, this.GetType().FullName); frm.UpdateParent += Frm_UpdateParent; frm.ShowDialog(); } @@ -84,53 +148,7 @@ private void Frm_UpdateParent(object sender, UpdateParentEventArgs e) { _filterList = e.FilterList; - getPageList(1, pageBar1.RowsCount); - } - - /// <summary> - /// 鍙栨秷浜嬩欢 - /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> - private void ToolBarMenu1_btnEscClick(object sender, EventArgs e) - { - UtilityHelper.JumpToTab(xtraTabControl1, 0); - } - - /// <summary> - /// 鍒犻櫎浜嬩欢 - /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> - private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e) - { - string rowGuid = "", rowName = ""; - // (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1); - if (string.IsNullOrEmpty(rowGuid)) - { - ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); - return; - } - if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵")) - return; - List<dynamic> lst = new List<dynamic>(); - lst.Add(rowGuid); - var _obj = lst; - try - { - string strJson = UtilityHelper.HttpPost("", _webServiceName + "DeleteModel", JsonConvert.SerializeObject(_obj)); - ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); - if (_rtn.rtnCode > 0) - { - UtilityHelper.JumpToTab(xtraTabControl1, 0); - getPageList(1, UtilityHelper.GetPageSize()); - } - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); - } - catch (Exception ex) - { - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); - } + getPageList(1); } /// <summary> @@ -140,131 +158,83 @@ /// <param name="e"></param> private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) { - UtilityHelper.JumpToTab(xtraTabControl1, 0); - getPageList(1, UtilityHelper.GetPageSize()); - } - /// <summary> - /// 淇敼浜嬩欢 - /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> - private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e) - { - string rowGuid = "", rowName = ""; - // (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1); - if (string.IsNullOrEmpty(rowGuid)) + if (xtraTabControl1.SelectedTabPageIndex == 1) + getModel(lbGuid.Text.Trim()); + else { - ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); - return; - } - getModel(rowGuid, true, 1); - } - /// <summary> - /// 鏂板浜嬩欢 - /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> - private void ToolBarMenu1_btnAddClick(object sender, EventArgs e) - { - UtilityHelper.JumpToTab(xtraTabControl1, 1); - lbGuid.Text = ""; - List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>(); - gridViews.Add(gvMx1); - UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews); - Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1); - } - /// <summary> - /// 淇濆瓨浜嬩欢 - /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> - private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e) - { - toolBarMenu1.isSetBtn = false; - //if (string.IsNullOrEmpty(txt_account.Text.Trim())) - { - Gs.DevApp.ToolBox.MsgHelper.Warning("鐧诲綍璐﹀彿涓嶈兘涓虹┖锛�"); - // txt_account.Focus(); - return; - } - var _obj = new - { - guid =UtilityHelper.ToGuid( lbGuid.Text.Trim()), //涓诲缓 - }; - try - { - string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj)); - ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); - if (_rtn.rtnCode > 0) - { - lbGuid.Text = _rtn.rtnData; - toolBarMenu1.isSetBtn = true; - UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false); - } - } - catch (Exception ex) - { - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + //_filterList.Clear(); + //if (gridView1.ActiveFilter.Count > 0) + //{ + // gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged; + // gridView1.ActiveFilter.Clear(); + // gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged; + //} + //getPageList(1); + getPageList(this.pageBar1.CurrentPage); } } - /// <summary> /// /// </summary> /// <param name="curPage">绗嚑椤�</param> /// <param name="pageSize">姣忛〉鍑犳潯</param> - private void getPageList(int curPage, int pageSize) + private void getPageList(int curPage) { - System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder(); - foreach (FilterEntity itm in _filterList) - { - _sbSqlWhere.Append(" and " + itm.fileId + itm.fileOper + "'" + itm.fileValue + "'"); - } - PageQueryModel pgq = new PageQueryModel(curPage, pageSize, "create_date", "asc", "", _sbSqlWhere.ToString()); - string json = JsonConvert.SerializeObject(pgq); + var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList); + var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "create_date", + "asc", "", _sbSqlWhere.ToString()); + var json = JsonConvert.SerializeObject(pgq); try { - string strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetListPage", json); - ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn); + var strReturn = UtilityHelper.HttpPost("", + _webServiceName + "GetListPage", json); + var dd = UtilityHelper.ReturnToTablePage(strReturn); if (dd.rtnCode > 0) - { - DataTable dt = dd.rtnData.list; - gcMain.BindingContext = new BindingContext(); - gcMain.DataSource = dt; - gcMain.ForceInitialize(); - int dddd = dd.rtnData.pages;//鎬婚〉 - pageBar1.TotalPages = dddd; - pageBar1.RecordCount = dd.rtnData.total;//璁板綍鎬绘暟 - pageBar1.CurrentPage = curPage;//褰撳墠椤� - pageBar1.RowsCount = pageSize;//姣忛〉鏄剧ず - pageBar1.setTxt(); - } - else - { - ToolBox.MsgHelper.ShowError("鎻愮ず锛�" + dd.rtnMsg); - } + { + DataTable dt = dd.rtnData.list; + gcMain1.BindingContext = new BindingContext(); + gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged; + if (dt.Rows.Count > 0) + { + gcMain1.DataSource = dt; + gcMain1.ForceInitialize(); + gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1); + } + else + UtilityHelper.SetDefaultTable(gcMain1, gridView1); + gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged; + pageBar1.TotalPages = dd.rtnData.pages;//鎬婚〉 + pageBar1.CurrentPage = curPage;//褰撳墠椤� + pageBar1.RecordCount = dd.rtnData.total;//鎬昏褰曟暟 + } + else + { + ToolBox.MsgHelper.ShowError("鎻愮ず锛�" + dd.rtnMsg); + } } catch (Exception ex) { - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); } } - private void getModel(string strGuid, bool isEdit, int tabIdx) + private void getModel(string strGuid) { + gcMx1.DataSource = null; + bool isEdit = false; + if (toolBarMenu1.currentAction == "add") return; + if (toolBarMenu1.currentAction == "edit") isEdit = true; if (string.IsNullOrEmpty(strGuid)) { ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); return; } - UtilityHelper.JumpToTab(xtraTabControl1, tabIdx); var _obj = new { guid = strGuid,//涓诲缓 }; try { - string strJson = UtilityHelper.HttpPost("", _webServiceName +"GetModel", JsonConvert.SerializeObject(_obj)); + string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); if (_rtn.rtnCode > 0) { @@ -272,37 +242,40 @@ lbGuid.Text = strGuid; List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>(); gvList.Add(gvMx1); - UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit, gvList); - JObject _job = JObject.Parse(strJson); - JArray array = new JArray(); - JArray list3 = new JArray(); - foreach (var a in _job["rtnData"]["list"]) + gvList.Add(gvMx2); + UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList); + JArray array1 = new JArray(); + foreach (var a in dy["list1"]) { - array.Add(a); + array1.Add(a); } - DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString()); - if (dt.Rows.Count > 0) + + DataTable dt1 = JsonConvert.DeserializeObject<DataTable>(array1.ToString()); + if (dt1.Rows.Count > 0) { gcMx1.BindingContext = new BindingContext(); - gcMx1.DataSource = dt; + gcMx1.DataSource = dt1; gcMx1.ForceInitialize(); + gvMx1.BestFitColumns(); + Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1); } else { Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1); } - - foreach (var a in _job["rtnData"]["list3"]) + JArray array2 = new JArray(); + foreach (var a in dy["list2"]) { - list3.Add(a); + array2.Add(a); } - - DataTable dt1 = JsonConvert.DeserializeObject<DataTable>(list3.ToString()); - if (dt1.Rows.Count > 0) + DataTable dt2 = JsonConvert.DeserializeObject<DataTable>(array2.ToString()); + if (dt2.Rows.Count > 0) { gcMx2.BindingContext = new BindingContext(); - gcMx2.DataSource = dt1; + gcMx2.DataSource = dt2; gcMx2.ForceInitialize(); + gvMx2.BestFitColumns(); + Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx2); } else { @@ -317,5 +290,40 @@ ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); } } + + private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) + { + var rowhandle = gvMx2.FocusedRowHandle; + if (rowhandle < 0) + return; + if (e.Button.Index == 0) + { + var dr = gvMx2.GetDataRow(rowhandle); + var mxGuid = dr["guid"].ToString(); + if (!MsgHelper.AskQuestion("浣犻�夋嫨浜�1鏉℃暟鎹紝纭畾鍒犻櫎鍚楋紵")) + return; + var _obj = new + { + mxGuid = mxGuid, + inType = "dhtm" + }; + try + { + var strJson = UtilityHelper.HttpPost("", + _webServiceName + "DeleteBarcode", + JsonConvert.SerializeObject(_obj)); + var _rtn = UtilityHelper.ReturnToDynamic(strJson); + if (_rtn.rtnCode > 0) + { + if (_rtn.rtnCode > 0) getModel(lbGuid.Text); + } + MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); + } + catch (Exception ex) + { + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + } } } \ No newline at end of file -- Gitblit v1.9.3