From cefcc903f51610846fa313a3a35bca34e129c1fe Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期五, 25 十月 2024 08:57:01 +0800 Subject: [PATCH] 代码清理以及格式化 --- DevApp/Gs.DevApp/DevFrm/BasicData/Frm_Holidy.cs | 223 ++++++++++++++++++++++++++++++++----------------------- 1 files changed, 128 insertions(+), 95 deletions(-) diff --git a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_Holidy.cs b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_Holidy.cs index 0b76db8..b5a0442 100644 --- a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_Holidy.cs +++ b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_Holidy.cs @@ -1,82 +1,92 @@ -锘縰sing DevExpress.XtraEditors.Controls; +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using DevExpress.XtraEditors; +using DevExpress.XtraEditors.Controls; using DevExpress.XtraGrid.Views.Grid; using Gs.DevApp.Entity; using Gs.DevApp.ToolBox; +using Gs.DevApp.UserControl; using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Data; -using System.Windows.Forms; namespace Gs.DevApp.DevFrm { - public partial class Frm_Holidy : DevExpress.XtraEditors.XtraForm + public partial class Frm_Holidy : XtraForm { - string _webServiceName = "Holiday/"; - List<FilterEntity> _filterList = new List<FilterEntity>(); + private List<FilterEntity> _filterList = new List<FilterEntity>(); + private readonly string _webServiceName = "Holiday/"; + public Frm_Holidy() { InitializeComponent(); getTree(); - this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick; - 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; - this.toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick; - this.toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick; + toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick; + toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick; + toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick; + toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1; + toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick; + toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick; + toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick; + toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick; gcMain.MouseDoubleClick += GcMain_MouseDoubleClick; - gridView1.CustomDrawRowIndicator += GridView1_CustomDrawRowIndicator; + gridView1.CustomDrawRowIndicator += + GridView1_CustomDrawRowIndicator; getPageList(1, UtilityHelper.GetPageSize()); pageBar1.PagerEvent += PageBar1_PagerEvent; } - private void GridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e) + private void GridView1_CustomDrawRowIndicator(object sender, + RowIndicatorCustomDrawEventArgs e) { if (e.Info.IsRowIndicator && e.RowHandle >= 0) - { e.Info.DisplayText = (e.RowHandle + 1).ToString(); - } } + /// <summary> - /// 鍙嶅鏍� + /// 鍙嶅鏍� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <exception cref="NotImplementedException"></exception> private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e) { - this.toolBarMenu1.guidKey = ""; + toolBarMenu1.guidKey = ""; string rowGuid, rowName; - (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, gridView1); - this.toolBarMenu1.guidKey = rowGuid; + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, + lbGuid, txt_name, gridView1); + toolBarMenu1.guidKey = rowGuid; } + /// <summary> - /// 瀹℃牳浜嬩欢 + /// 瀹℃牳浜嬩欢 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToolBarMenu1_btnChkClick(object sender, EventArgs e) { - this.toolBarMenu1.guidKey = ""; + toolBarMenu1.guidKey = ""; string rowGuid, rowName; - (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, gridView1); - this.toolBarMenu1.guidKey = rowGuid; + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, + lbGuid, txt_name, gridView1); + toolBarMenu1.guidKey = rowGuid; } + /// <summary> - /// 鍙屽嚮浜嬩欢 + /// 鍙屽嚮浜嬩欢 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e) { - string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid"); + var rowGuid = + UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid"); if (!string.IsNullOrEmpty(rowGuid)) getModel(rowGuid, false, 999); } + /// <summary> - /// 鍒嗛〉浜嬩欢 + /// 鍒嗛〉浜嬩欢 /// </summary> /// <param name="curPage"></param> /// <param name="pageSize"></param> @@ -84,19 +94,21 @@ { getPageList(curPage, pageSize); } + /// <summary> - /// 鏌ヨ浜嬩欢 + /// 鏌ヨ浜嬩欢 /// </summary> /// <param name="sender"></param> /// <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); + var frm = new ShowFilter(gridView1.Columns, _filterList); frm.UpdateParent += Frm_UpdateParent; frm.ShowDialog(); } + /// <summary> - /// 鏌ヨ鍥炶皟 + /// 鏌ヨ鍥炶皟 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> @@ -107,7 +119,7 @@ } /// <summary> - /// 鍙栨秷浜嬩欢 + /// 鍙栨秷浜嬩欢 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> @@ -115,45 +127,52 @@ { 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_name, gridView1); + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, + lbGuid, txt_name, gridView1); if (string.IsNullOrEmpty(rowGuid)) { - ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); + MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); return; } + if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵")) return; var _obj = new { - guidList = rowGuid,//涓诲缓 + guidList = rowGuid //涓诲缓 }; - string strJson = ""; + var strJson = ""; try { - strJson = UtilityHelper.HttpPost("", _webServiceName+"DeleteModel", JsonConvert.SerializeObject(_obj)); - ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); + strJson = UtilityHelper.HttpPost("", + _webServiceName + "DeleteModel", + JsonConvert.SerializeObject(_obj)); + var _rtn = UtilityHelper.ReturnToDynamic(strJson); if (_rtn.rtnCode > 0) { UtilityHelper.JumpToTab(xtraTabControl1, 0); getPageList(1, UtilityHelper.GetPageSize()); } - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); + + MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); } catch (Exception ex) { - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); } } + /// <summary> - /// 鍒锋柊浜嬩欢 + /// 鍒锋柊浜嬩欢 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> @@ -164,7 +183,7 @@ } /// <summary> - /// 鏂板浜嬩欢 + /// 鏂板浜嬩欢 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> @@ -172,145 +191,159 @@ { UtilityHelper.JumpToTab(xtraTabControl1, 1); lbGuid.Text = ""; - UtilityHelper.CleanValueByControl(this.panel1.Controls, true); + UtilityHelper.CleanValueByControl(panel1.Controls, true); } + /// <summary> - /// 淇濆瓨浜嬩欢 + /// 淇濆瓨浜嬩欢 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e) { toolBarMenu1.isSetBtn = false; - if (txt_workshopNo.EditValue == null || string.IsNullOrEmpty(txt_workshopNo.EditValue.ToString())) + if (txt_workshopNo.EditValue == null || + string.IsNullOrEmpty(txt_workshopNo.EditValue.ToString())) { - ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浜х嚎锛�"); + MsgHelper.Warning("璇峰厛閫夋嫨浜х嚎锛�"); txt_workshopNo.Focus(); return; } + if (string.IsNullOrEmpty(txt_name.Text.Trim())) { - Gs.DevApp.ToolBox.MsgHelper.Warning("鍚嶇О涓嶈兘涓虹┖锛�"); + MsgHelper.Warning("鍚嶇О涓嶈兘涓虹┖锛�"); txt_name.Focus(); return; } + if (txt_begTime.Value.Date > txt_endTime.Value.Date) { - Gs.DevApp.ToolBox.MsgHelper.Warning("寮�濮嬫椂闂翠笉鑳藉ぇ浜庣粨鏉熸椂闂达紒"); + MsgHelper.Warning("寮�濮嬫椂闂翠笉鑳藉ぇ浜庣粨鏉熸椂闂达紒"); txt_begTime.Focus(); return; } + var _obj = new { - guid = lbGuid.Text.Trim(),//涓诲缓 + guid = lbGuid.Text.Trim(), //涓诲缓 name = txt_name.Text.Trim(), time1 = txt_begTime.Value.Date, time2 = txt_endTime.Value.Date, - workshopNo = txt_workshopNo.EditValue.ToString(), + workshopNo = txt_workshopNo.EditValue.ToString() }; try { - string strJson = UtilityHelper.HttpPost("", _webServiceName+"EditModel", JsonConvert.SerializeObject(_obj)); - ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); + var strJson = UtilityHelper.HttpPost("", + _webServiceName + "EditModel", + JsonConvert.SerializeObject(_obj)); + var _rtn = UtilityHelper.ReturnToDynamic(strJson); + MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); if (_rtn.rtnCode > 0) { lbGuid.Text = _rtn.rtnData; toolBarMenu1.isSetBtn = true; - UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false); + UtilityHelper.ChangeEnableByControl(panel1.Controls, false); } } catch (Exception ex) { - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); } } + /// <summary> - /// /// </summary> /// <param name="curPage">绗嚑椤�</param> /// <param name="pageSize">姣忛〉鍑犳潯</param> private void getPageList(int curPage, int pageSize) { - 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, "begTime", "asc", "", _sbSqlWhere.ToString()); - string json = JsonConvert.SerializeObject(pgq); + var _sbSqlWhere = new StringBuilder(); + foreach (var itm in _filterList) + _sbSqlWhere.Append(" and " + itm.fileId + itm.fileOper + "'" + + itm.fileValue + "'"); + var pgq = new PageQueryModel(curPage, pageSize, "begTime", "asc", + "", _sbSqlWhere.ToString()); + var json = JsonConvert.SerializeObject(pgq); try { - string strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetListPage", json); - ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn); - DataTable dt = dd.rtnData.list; + var strReturn = UtilityHelper.HttpPost("", + _webServiceName + "GetListPage", json); + var dd = UtilityHelper.ReturnToTablePage(strReturn); + var dt = dd.rtnData.list; gcMain.BindingContext = new BindingContext(); gcMain.DataSource = dt; gcMain.ForceInitialize(); - int dddd = dd.rtnData.pages;//鎬婚〉 + var dddd = dd.rtnData.pages; //鎬婚〉 pageBar1.TotalPages = dddd; - pageBar1.RecordCount = dd.rtnData.total;//璁板綍鎬绘暟 - pageBar1.CurrentPage = curPage;//褰撳墠椤� - pageBar1.RowsCount = pageSize;//姣忛〉鏄剧ず + pageBar1.RecordCount = dd.rtnData.total; //璁板綍鎬绘暟 + pageBar1.CurrentPage = curPage; //褰撳墠椤� + pageBar1.RowsCount = pageSize; //姣忛〉鏄剧ず pageBar1.setTxt(); } catch (Exception ex) { - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); } } + private void getModel(string strGuid, bool isEdit, int tabIdx) { if (string.IsNullOrEmpty(strGuid)) { - ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); + MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); return; } + UtilityHelper.JumpToTab(xtraTabControl1, tabIdx); var _obj = new { - guid = strGuid,//涓诲缓 + guid = strGuid //涓诲缓 }; try { - string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); - ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); + var strJson = UtilityHelper.HttpPost("", + _webServiceName + "GetModel", + JsonConvert.SerializeObject(_obj)); + var _rtn = UtilityHelper.ReturnToDynamic(strJson); if (_rtn.rtnCode > 0) { - dynamic dy = _rtn.rtnData; + var dy = _rtn.rtnData; lbGuid.Text = strGuid; - UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit); + UtilityHelper.SetValueByObj(panel1.Controls, dy, isEdit); } else - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); + { + MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); + } } catch (Exception ex) { - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); } } private void getTree() { - PageQueryModel pgq = new PageQueryModel(1, 999999, "workshop_no", "asc", "notree", " and is_Status=1"); - string json = JsonConvert.SerializeObject(pgq); + var pgq = new PageQueryModel(1, 999999, "workshop_no", "asc", + "notree", " and is_Status=1"); + var json = JsonConvert.SerializeObject(pgq); try { - string strReturn = UtilityHelper.HttpPost("", "MesWorkshopManager/GetListPage", json); - ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn); - DataTable dt = dd.rtnData.list; + var strReturn = UtilityHelper.HttpPost("", + "MesWorkshopManager/GetListPage", json); + var dd = UtilityHelper.ReturnToTablePage(strReturn); + var dt = dd.rtnData.list; txt_workshopNo.Properties.DataSource = dt; txt_workshopNo.Properties.DisplayMember = "name"; // 鏄剧ず鐨勫垪 - txt_workshopNo.Properties.ValueMember = "itemNo"; // 瀹為檯鍊肩殑鍒� - txt_workshopNo.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; + txt_workshopNo.Properties.ValueMember = "itemNo"; // 瀹為檯鍊肩殑鍒� + txt_workshopNo.Properties.TextEditStyle = + TextEditStyles.DisableTextEditor; } catch (Exception ex) { - ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); } } } - - -} - +} \ No newline at end of file -- Gitblit v1.9.3