using System; using System.Collections.Generic; using System.Data; 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; namespace Gs.DevApp.DevFrm { public partial class Frm_Holidy : XtraForm { private List _filterList = new List(); private readonly string _webServiceName = "Holiday/"; public Frm_Holidy() { InitializeComponent(); getTree(); toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick; 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; Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter( gridView1); getPageList(1, UtilityHelper.GetPageSize()); pageBar1.PagerEvent += PageBar1_PagerEvent; } /// /// 反审核 /// /// /// /// private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e) { toolBarMenu1.guidKey = ""; string rowGuid, rowName; (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, gridView1); toolBarMenu1.guidKey = rowGuid; } /// /// 审核事件 /// /// /// private void ToolBarMenu1_btnChkClick(object sender, EventArgs e) { toolBarMenu1.guidKey = ""; string rowGuid, rowName; (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, gridView1); toolBarMenu1.guidKey = rowGuid; } /// /// 双击事件 /// /// /// private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e) { var rowGuid = UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid"); if (!string.IsNullOrEmpty(rowGuid)) getModel(rowGuid, false, 999); } /// /// 分页事件 /// /// /// private void PageBar1_PagerEvent(int curPage, int pageSize) { getPageList(curPage, pageSize); } /// /// 查询事件 /// /// /// private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e) { var frm = new ShowFilter(gridView1.Columns, _filterList, this.GetType().FullName); frm.UpdateParent += Frm_UpdateParent; frm.ShowDialog(); } /// /// 查询回调 /// /// /// private void Frm_UpdateParent(object sender, UpdateParentEventArgs e) { _filterList = e.FilterList; getPageList(1, pageBar1.RowsCount); } /// /// 取消事件 /// /// /// private void ToolBarMenu1_btnEscClick(object sender, EventArgs e) { UtilityHelper.JumpToTab(xtraTabControl1, 0); } /// /// 修改事件 /// /// /// private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e) { string rowGuid, rowName; (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, gridView1); if (string.IsNullOrEmpty(rowGuid)) { MsgHelper.Warning("请先选择你要操作的行!"); return; } getModel(rowGuid, true, 1); } /// /// 删除事件 /// /// /// private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e) { string rowGuid, rowName; (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, gridView1, "name"); if (string.IsNullOrEmpty(rowGuid)) { MsgHelper.Warning("请先选择你要操作的行!"); return; } if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定删除吗?")) return; var _obj = new { guidList = rowGuid //主建 }; var strJson = ""; try { 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()); } MsgHelper.Warning("提示:" + _rtn.rtnMsg); } catch (Exception ex) { MsgHelper.Warning("提示:" + ex.Message); } } /// /// 刷新事件 /// /// /// private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) { if (xtraTabControl1.SelectedTabPageIndex == 1) getModel(lbGuid.Text.Trim(), false, 999); else getPageList(1, UtilityHelper.GetPageSize()); } /// /// 新增事件 /// /// /// private void ToolBarMenu1_btnAddClick(object sender, EventArgs e) { UtilityHelper.JumpToTab(xtraTabControl1, 1); lbGuid.Text = ""; UtilityHelper.CleanValueByControl(panel1.Controls, true); } /// /// 保存事件 /// /// /// private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e) { toolBarMenu1.isSetBtn = false; if (txt_workshopNo.EditValue == null || string.IsNullOrEmpty(txt_workshopNo.EditValue.ToString())) { MsgHelper.Warning("请先选择产线!"); txt_workshopNo.Focus(); return; } if (string.IsNullOrEmpty(txt_name.Text.Trim())) { MsgHelper.Warning("名称不能为空!"); txt_name.Focus(); return; } if (txt_begTime.Value.Date > txt_endTime.Value.Date) { MsgHelper.Warning("开始时间不能大于结束时间!"); txt_begTime.Focus(); return; } var _obj = new { guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建 name = txt_name.Text.Trim(), time1 = txt_begTime.Value.Date, time2 = txt_endTime.Value.Date, workshopNo = txt_workshopNo.EditValue.ToString() }; try { 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(panel1.Controls, false); } } catch (Exception ex) { MsgHelper.Warning("提示:" + ex.Message); } } /// /// /// 第几页 /// 每页几条 private void getPageList(int curPage, int pageSize) { 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 { 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.setTxt(); } else { ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg); } } catch (Exception ex) { MsgHelper.Warning("提示:" + ex.Message); } } private void getModel(string strGuid, bool isEdit, int tabIdx) { if (string.IsNullOrEmpty(strGuid)) { MsgHelper.Warning("请先选择你要操作的行!"); return; } UtilityHelper.JumpToTab(xtraTabControl1, tabIdx); 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(panel1.Controls, dy, isEdit); } else { MsgHelper.Warning("提示:" + _rtn.rtnMsg); } } catch (Exception ex) { MsgHelper.Warning("提示:" + ex.Message); } } private void getTree() { var pgq = new PageQueryModel(1, 999999, "departmentid", "asc", "notree", " and is_Status=1"); var json = JsonConvert.SerializeObject(pgq); try { var strReturn = UtilityHelper.HttpPost("", "SysDepartmentManager/GetListPage", json); var dd = UtilityHelper.ReturnToTablePage(strReturn); var dt = dd.rtnData.list; txt_workshopNo.Properties.DataSource = dt; txt_workshopNo.Properties.DisplayMember = "departmentname"; // 显示的列 txt_workshopNo.Properties.ValueMember = "guid"; // 实际值的列 txt_workshopNo.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; } catch (Exception ex) { MsgHelper.Warning("提示:" + ex.Message); } } } }