From 64a6c4193199d15d7ac5aa67a9677df01a37a50d Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期四, 12 六月 2025 08:04:31 +0800 Subject: [PATCH] bug --- DevApp/Gs.DevApp/DevFrm/WW/WwBlcl.cs | 594 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 588 insertions(+), 6 deletions(-) diff --git a/DevApp/Gs.DevApp/DevFrm/WW/WwBlcl.cs b/DevApp/Gs.DevApp/DevFrm/WW/WwBlcl.cs index b731258..81d4769 100644 --- a/DevApp/Gs.DevApp/DevFrm/WW/WwBlcl.cs +++ b/DevApp/Gs.DevApp/DevFrm/WW/WwBlcl.cs @@ -1,11 +1,12 @@ 锘縰sing 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.ComponentModel; using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -13,9 +14,590 @@ { public partial class WwBlcl : DevExpress.XtraEditors.XtraUserControl { - public WwBlcl() + string _ucCk = "";//浠撳簱 + string _webServiceName = "WWBlManager/"; + List<FilterEntity> _filterList = new List<FilterEntity>(); + public string strType = ""; + public WwBlcl(string _strType) { InitializeComponent(); + strType = _strType; + txt_bl017.Text = _strType; + txt_bl017.Tag = "moren." + _strType; } + protected override void OnCreateControl() + { + base.OnCreateControl(); + if (Parent == null) return; + 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; + toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick; + toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick; + toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick; + this.toolBarMenu1.getXmlConfig(); + Form parentForm = this.FindForm(); + Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1); + Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, parentForm, "bl018", "", (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; + //璁剧疆缁勭粐 + this.txt_orgId.EditChanged += (s, e) => + { + string orgdId = txt_orgId.GetId(); + if (string.IsNullOrEmpty(orgdId)) return; + txt_bl010.getSuppler(orgdId, _ucCk); + }; + //閫夋嫨濮斿宸ュ崟 + this.txt_aboutGuid.EditChanged += (s, e) => + { + string strGdId = txt_aboutGuid.GetId(); + if (string.IsNullOrEmpty(strGdId)) return; + txt_bl002.Text = txt_aboutGuid.GetPrdNo(); + txt_bl014.Text = txt_aboutGuid.GetPrdName(); + txt_bl015.Text = txt_aboutGuid.GetPrdModel(); + txt_bl013.Text = txt_aboutGuid.GetRwd(); + var _obj = new + { + currentPage = 1, + everyPageSize = 999999, + sortName = "", + keyWhere = "", + inP1 = strGdId + }; + var json = JsonConvert.SerializeObject(_obj); + try + { + var strReturn = UtilityHelper.HttpPost("", "WWBlManager/SelectFormMx", json); + var rtn = UtilityHelper.ReturnToTablePage(strReturn); + var dt = rtn.rtnData.list; + this.repositoryItemSearchLookUpEdit1.DataSource = dt; + } + catch (Exception ex) + { + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + }; + } + private void GridView1_ColumnFilterChanged(object sender, EventArgs e) + { + _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1); + Task.Delay(100); + getPageList(1); + } + /// <summary> + /// 鏃ュ織 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ToolBarMenu1_btnLogClick(object sender, EventArgs e) + { + toolBarMenu1.guidKey = ""; + string rowGuid, rowName; + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, + lbGuid, txt_blNo, gridView1); + toolBarMenu1.guidKey = rowGuid; + } + + /// <summary> + /// 鍒嗛〉浜嬩欢 + /// </summary> + /// <param name="curPage"></param> + /// <param name="pageSize"></param> + private void PageBar1_PagerEvent(int curPage, int pageSize) + { + getPageList(curPage); + } + /// <summary> + /// 鏌ヨ浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e) + { + Form parentForm; + if (this.Parent is Form) + parentForm = this.Parent as Form; + else + parentForm = this.Parent.Parent as Form; + + gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged; + gridView1.ActiveFilter.Clear(); + gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged; + var frm = new ShowFilter(gridView1.Columns, _filterList, parentForm.GetType().FullName); + frm.UpdateParent += Frm_UpdateParent; + frm.ShowDialog(); + } + /// <summary> + /// 鏌ヨ鍥炶皟 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void Frm_UpdateParent(object sender, UpdateParentEventArgs e) + { + _filterList = e.FilterList; + getPageList(1); + } + + /// <summary> + /// 鍙栨秷浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ToolBarMenu1_btnEscClick(object sender, EventArgs e) + { + Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 1); + } + + /// <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_blNo, gridView1, "blNo"); + if (string.IsNullOrEmpty(rowGuid)) + { + MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); + return; + } + if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵")) + return; + var _obj = new + { + guid = rowGuid, + mxGuid = Guid.Empty.ToString(), + }; + try + { + var strJson = UtilityHelper.HttpPost("", + _webServiceName + "DeleteModelOrMx", + JsonConvert.SerializeObject(_obj)); + var _rtn = UtilityHelper.ReturnToDynamic(strJson); + if (_rtn.rtnCode > 0) + { + if (xtraTabControl1.SelectedTabPageIndex == 0) + { } + else + Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 2); + getPageList(this.pageBar1.CurrentPage); + } + + MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); + } + catch (Exception ex) + { + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + + } + + /// <summary> + /// 鍒锋柊浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) + { + if (xtraTabControl1.SelectedTabPageIndex == 1) + getModel(lbGuid.Text.Trim()); + else + { + //_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="sender"></param> + /// <param name="e"></param> + private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e) + { + string rowGuid = "", rowName = ""; + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_blNo, gridView1, "blNo"); + if (string.IsNullOrEmpty(rowGuid)) + { + ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); + return; + } + Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3); + if (xtraTabControl1.SelectedTabPageIndex == 1) + { + getModel(rowGuid); + } + else + { + List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>(); + gvList.Add(gvMx1); + UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, true, gvList); + } + } + /// <summary> + /// 鏂板浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ToolBarMenu1_btnAddClick(object sender, EventArgs e) + { + lbGuid.Text = ""; + Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 4); + List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>(); + gridViews.Add(gvMx1); + UtilityHelper.CleanValueByControl(this.layoutMx1.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; + string inGdId = txt_aboutGuid.GetId();//宸ュ崟鍙� + string inCkId = txt_bl010.GetId();//鍙戞枡浠� + string inFlOrg = txt_orgId.GetId();//鍙戞枡缁勭粐 + if (string.IsNullOrEmpty(inFlOrg)) + { + Gs.DevApp.ToolBox.MsgHelper.Warning("璇烽�夋嫨鍙戞枡缁勭粐锛�"); + txt_orgId.Focus(); + return; + } + if (string.IsNullOrEmpty(inGdId)) + { + Gs.DevApp.ToolBox.MsgHelper.Warning("璇烽�夋嫨宸ュ崟锛�"); + txt_aboutGuid.Focus(); + return; + } + if (string.IsNullOrEmpty(inCkId)) + { + Gs.DevApp.ToolBox.MsgHelper.Warning("璇烽�夋嫨浠撳簱锛�"); + txt_bl010.Focus(); + return; + } + if (string.IsNullOrEmpty(txt_bl017.Text.Trim())) + { + Gs.DevApp.ToolBox.MsgHelper.Warning("璇烽�夋嫨鍗曟嵁绫诲瀷锛�"); + txt_bl017.Focus(); + return; + } + var _obj = new + { + guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //涓诲缓 + inOrgId = inFlOrg,//鍙戞枡缁勭粐 + inGdId = inGdId,//宸ュ崟鍙� + inCkId = inCkId,//浠撳簱 + inYy = txt_bl007.Text.Trim(),//鍘熷洜 + inType = txt_bl017.Text.Trim(),//鍑哄簱绫诲埆 + list = new List<dynamic>(), + }; + gvMx1.CloseEditor(); + gvMx1.PostEditor(); + gvMx1.UpdateCurrentRow(); + if (gvMx1.DataRowCount <= 0) + { + MsgHelper.ShowError("鏄庣粏涓嶈兘涓虹┖锛岃閫夋嫨浣犵殑鐢宠鏄庣粏锛�"); + return; + } + for (var i = 0; i < gvMx1.DataRowCount; i++) + { + var row = gvMx1.GetDataRow(i); + if (row != null) + { + Guid? _guid = UtilityHelper.ToGuid(row["guid"].ToString()); + string _msl = row["bld007"].ToString(); + if (string.IsNullOrEmpty(_msl)) + { + MsgHelper.ShowError("鏁伴噺涓嶈兘涓虹┖锛�"); + return; + } + _obj.list.Add(new + { + Guid = _guid, + DabGuid = (row["dabGuid"].ToString()), + ItemId = (row["bld012"].ToString()), + Sqsl = (row["bld007"].ToString()), + Bz = (row["bld010"].ToString()), + }); + } + } + 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.outGuid; + txt_blNo.Text = _rtn.rtnData.outNo; + toolBarMenu1.isSetBtn = true; + List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>(); + gvList.Add(gvMx1); + UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false, gvList); + toolBarMenu1.currentAction = ""; + Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6); + } + } + catch (Exception ex) + { + ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + + /// <summary> + /// + /// </summary> + /// <param name="curPage">绗嚑椤�</param> + /// <param name="pageSize">姣忛〉鍑犳潯</param> + private void getPageList(int curPage) + { + gcMain1.DataSource = null;var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList); + _sbSqlWhere += " and a.bl008='" + strType + "'"; + PageQueryModel pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "create_date", "asc", "", _sbSqlWhere.ToString()); + string json = JsonConvert.SerializeObject(pgq); + try + { + var strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetListPage", json); + ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn); + if (dd.rtnCode > 0) + { + 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.ShowError("鎻愮ず锛�" + ex.Message); + } + + } + private void getModel(string strGuid) + { + bool isEdit = false; + if (toolBarMenu1.currentAction == "add") return; + if (toolBarMenu1.currentAction == "edit") isEdit = true; + if (string.IsNullOrEmpty(strGuid)) + { + ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); + return; + } + var _obj = new + { + guid = strGuid,//涓诲缓 + }; + try + { + string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); + ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); + if (_rtn.rtnCode > 0) + { + dynamic dy = _rtn.rtnData; + _ucCk = dy.bl010; + lbGuid.Text = strGuid; + 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); + _ucCk = ""; + JObject _job = JObject.Parse(strJson); + JArray array = new 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(); + } + else + { + Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1); + } + } + else + ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); + } + catch (Exception ex) + { + ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + + + /// <summary> + /// 瀹℃牳浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ToolBarMenu1_btnChkClick(object sender, EventArgs e) + { + _toolCk(1); + } + + /// <summary> + /// 鍙嶅鏍� + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + /// <exception cref="NotImplementedException"></exception> + private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e) + { + _toolCk(0); + } + + /// <summary> + /// 宸ュ叿鏉′簨浠� + /// </summary> + /// <param name="inFieldValue"></param> + private void _toolCk(int _inFieldValue) + { + string strMsg = ""; + switch (_inFieldValue) + { + case 1: + strMsg = "瀹℃牳"; + break; + case 0: + strMsg = "鍙嶅鏍�"; + break; + }; + toolBarMenu1.guidKey = ""; + string rowGuid, rowName; + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_blNo, gridView1, "blNo"); + if (string.IsNullOrEmpty(rowGuid)) + { + MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); + return; + } + if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾" + strMsg + "鍚楋紵")) + return; + var _obj = new + { + guid = rowGuid, + inFieldValue = _inFieldValue, + }; + try + { + var strJson = UtilityHelper.HttpPost("", + _webServiceName + "EditModelSubmit", + JsonConvert.SerializeObject(_obj)); + var _rtn = UtilityHelper.ReturnToDynamic(strJson); + MsgHelper.Warning(_rtn.rtnData.outMsg.ToString()); + if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0) + { + if (xtraTabControl1.SelectedTabPageIndex == 1) + { + getModel(lbGuid.Text.Trim()); + } + int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid); + gridView1.FocusedRowHandle = rowHandle; + Form parentForm = this.FindForm(); + UtilityHelper.SetCheckIco(gridView1, "bl018", "bl016", "bl006", picCheckBox, parentForm, _inFieldValue.ToString()); + } + } + catch (Exception ex) + { + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + + private void repositoryItemSearchLookUpEdit1_EditValueChanged(object sender, EventArgs e) + { + SearchLookUpEdit LookupEdit = sender as SearchLookUpEdit; + DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow(); + gvMx1.SetFocusedRowCellValue("bld002", SelectedDataRow["itemNo"]); + gvMx1.SetFocusedRowCellValue("bld003", SelectedDataRow["itemName"]); + gvMx1.SetFocusedRowCellValue("bld004", SelectedDataRow["itemModel"]); + gvMx1.SetFocusedRowCellValue("dabGuid", SelectedDataRow["dabGuid"]); + gvMx1.SetFocusedRowCellValue("bld008", SelectedDataRow["dab007"]);//宸查鐢ㄩ噺 + gvMx1.SetFocusedRowCellValue("bld009", SelectedDataRow["dwName"]);//鍗曚綅 + } + + private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) + { + var rowhandle = gvMx1.FocusedRowHandle; + if (rowhandle < 0) + return; + if (e.Button.Index == 0) + { + var dr = gvMx1.GetDataRow(rowhandle); + var mxGuid = dr["guid"].ToString(); + if (!MsgHelper.AskQuestion("浣犻�夋嫨浜�1鏉℃暟鎹紝纭畾鍒犻櫎鍚楋紵")) + return; + if (string.IsNullOrEmpty(mxGuid)) + { + gvMx1.DeleteRow(rowhandle); + return; + } + var _obj = new + { + guid = lbGuid.Text.Trim(), + mxGuid = mxGuid, + }; + try + { + var strJson = UtilityHelper.HttpPost("", + _webServiceName + "DeleteModelOrMx", + 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