| | |
| | | using DevExpress.Pdf.Native.BouncyCastle.Asn1.X509; |
| | | using DevExpress.Utils.DirectXPaint; |
| | | using DevExpress.XtraBars; |
| | | using DevExpress.XtraLayout.Customization; |
| | | using DevExpress.XtraReports.Design; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Security.Policy; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using DevExpress.XtraBars; |
| | | using DevExpress.XtraEditors; |
| | | using Gs.DevApp.DevFrm.Rpt; |
| | | using Gs.DevApp.DevFrm.Sys; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | |
| | | namespace Gs.DevApp.UserControl |
| | | { |
| | | public partial class UcToolBarMenu : DevExpress.XtraEditors.XtraUserControl |
| | | public partial class UcToolBarMenu : XtraUserControl |
| | | { |
| | | public UcToolBarMenu() |
| | | { |
| | | InitializeComponent(); |
| | | btnAdd.ItemClick += BtnAdd_ItemClick; |
| | | btnDel.ItemClick += BtnDel_ItemClick; |
| | | btnEdit.ItemClick += BtnEdit_ItemClick; |
| | | btnLoad.ItemClick += BtnLoad_ItemClick; |
| | | btnSave.ItemClick += BtnSave_ItemClick; |
| | | btnKG.ItemClick += BtnKG_ItemClick; |
| | | btnEsc.ItemClick += BtnEsc_ItemClick; |
| | | btnRole.ItemClick += BtnRole_ItemClick; |
| | | btnQuery.ItemClick += BtnQuery_ItemClick; |
| | | btnReport.ItemClick += BtnReport_ItemClick; |
| | | btnDesign.ItemClick += BtnDesign_ItemClick; |
| | | btnOut.ItemClick += BtnOut_ItemClick; |
| | | btnIn.ItemClick += BtnIn_ItemClick; |
| | | btnChk.ItemClick += BtnChk_ItemClick; |
| | | btnFchk.ItemClick += BtnFchk_ItemClick; |
| | | btnJianYan.ItemClick += BtnJianYan_ItemClick; |
| | | btnFjianYan.ItemClick += BtnFjianYan_ItemClick; |
| | | var lst = new List<string>(); |
| | | foreach (BarItem item in barManager1.Items) |
| | | if (item is BarLargeButtonItem largeButtonItem) |
| | | if (!string.IsNullOrEmpty(item.Caption)) |
| | | lst.Add(item.Caption); |
| | | actions = lst; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 初始化按钮状态 |
| | | /// </summary> |
| | | protected override void OnCreateControl() |
| | | { |
| | | base.OnCreateControl(); |
| | | if (Parent != null) getNamespace(); |
| | | } |
| | | |
| | | private void BtnFchk_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnFChkClick != null) |
| | | btnFChkClick(this, e); |
| | | else |
| | | return; |
| | | |
| | | if (string.IsNullOrEmpty(guidKey)) |
| | | { |
| | | MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(chkParameter)) |
| | | { |
| | | MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定反审核吗?")) |
| | | return; |
| | | _ckService(0.ToString()); |
| | | } |
| | | |
| | | private void BtnChk_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnChkClick != null) |
| | | btnChkClick(this, e); |
| | | else |
| | | return; |
| | | |
| | | if (string.IsNullOrEmpty(guidKey)) |
| | | { |
| | | MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(chkParameter)) |
| | | { |
| | | MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定审核吗?")) |
| | | return; |
| | | _ckService(1.ToString()); |
| | | } |
| | | |
| | | private void BtnFjianYan_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnFjianYanClick != null) |
| | | btnFjianYanClick(this, e); |
| | | else |
| | | return; |
| | | |
| | | if (string.IsNullOrEmpty(guidKey)) |
| | | { |
| | | MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(chkParameter)) |
| | | { |
| | | MsgHelper.ShowError("没有指定检验参数,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定反检验吗?")) |
| | | return; |
| | | _ckService(0.ToString()); |
| | | } |
| | | |
| | | private void BtnJianYan_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnJianYanClick != null) |
| | | btnJianYanClick(this, e); |
| | | else |
| | | return; |
| | | |
| | | if (string.IsNullOrEmpty(guidKey)) |
| | | { |
| | | MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(chkParameter)) |
| | | { |
| | | MsgHelper.ShowError("没有指定检验参数,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定提交检验吗?")) |
| | | return; |
| | | var _obj = new |
| | | { |
| | | guid = guidKey, |
| | | parameter = chkParameter |
| | | }; |
| | | _ckService(1.ToString()); |
| | | } |
| | | |
| | | private async void BtnIn_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (string.IsNullOrEmpty(xlsInService)) |
| | | { |
| | | MsgHelper.ShowError("没有指定导入服务,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | |
| | | var openFileDialog = new OpenFileDialog(); |
| | | //openFileDialog.InitialDirectory = "c:\\"; |
| | | openFileDialog.Filter = "文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*"; |
| | | openFileDialog.Title = "选择文件"; |
| | | var result = openFileDialog.ShowDialog(); |
| | | if (result == DialogResult.OK) |
| | | { |
| | | var WebApiUrl = ConfigurationManager.AppSettings["WebApiUrl"] + |
| | | "Upload/UploadFile"; |
| | | var strJson = |
| | | await UtilityHelper.UploadFileAsync(openFileDialog |
| | | .FileName); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | string filePath = _rtn.rtnData["filePath"].ToString(); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | var _obj = filePath; |
| | | try |
| | | { |
| | | strJson = UtilityHelper.HttpPost("", |
| | | "XlsInOut/" + xlsInService, |
| | | JsonConvert.SerializeObject(_obj)); |
| | | _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void BtnOut_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | //if (string.IsNullOrEmpty(this.xlsOutView)) |
| | | //{ |
| | | // ToolBox.MsgHelper.ShowError("没有指定导出服务,请联系开发人员获取支持!"); |
| | | // return; |
| | | //} |
| | | //using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) |
| | | //{ |
| | | // folderBrowserDialog.Description = "选择导出文件的保存路径"; |
| | | // DialogResult dialogResult = folderBrowserDialog.ShowDialog(); |
| | | // if (dialogResult == DialogResult.OK) |
| | | // { |
| | | // string _folder = folderBrowserDialog.SelectedPath; |
| | | // var _obj = new Gs.DevApp.Entity.XlsOutModel(this.xlsOutView); |
| | | // try |
| | | // { |
| | | // string strJson = UtilityHelper.HttpPost("", "XlsInOut/XlsOutView", JsonConvert.SerializeObject(_obj)); |
| | | // ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | // if (_rtn.rtnCode > 0) |
| | | // { |
| | | // string _file = _rtn.rtnData.fileUrl.ToString(); |
| | | // string _folderName = _folder + "\\" + _file.Replace("down/", ""); |
| | | // string _url = ConfigurationManager.AppSettings["WebApiUrl"].ToString() + _file; |
| | | // using (WebClient client = new WebClient()) |
| | | // { |
| | | // client.DownloadFile(_url, _folderName); |
| | | // } |
| | | // ToolBox.MsgHelper.ShowInformation("导出成功!"); |
| | | // } |
| | | // else |
| | | // { |
| | | // ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | // } |
| | | // } |
| | | //} |
| | | } |
| | | |
| | | private void BtnReport_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (string.IsNullOrEmpty(rptParameter)) |
| | | { |
| | | MsgHelper.ShowError("没有指定报表参数,请联系技术开发人员!"); |
| | | return; |
| | | } |
| | | |
| | | var _bl = false; |
| | | _bl = _ckRptService(); |
| | | if (_bl) |
| | | { |
| | | var frm = new RptPreview(rptParameter); |
| | | frm.Show(); |
| | | return; |
| | | } |
| | | |
| | | MsgHelper.ShowError("没有设计模板,请先设计模板!"); |
| | | } |
| | | |
| | | private void BtnDesign_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (string.IsNullOrEmpty(rptParameter)) |
| | | { |
| | | MsgHelper.ShowError("没有指定报表参数,请联系技术开发人员!"); |
| | | return; |
| | | } |
| | | |
| | | var _bl = false; |
| | | _bl = _ckRptService(); |
| | | //如果已经有模板了,直接打开设置模板 |
| | | if (_bl) |
| | | { |
| | | var frm = new EasyRptDesign(rptParameter); |
| | | frm.Show(); |
| | | return; |
| | | } |
| | | |
| | | //否则向导设计模板 |
| | | var rptWizard = new ShowRptWizard(rptParameter); |
| | | rptWizard.ShowDialog(); |
| | | } |
| | | |
| | | private void BtnQuery_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnQueryClick != null) btnQueryClick(this, e); |
| | | } |
| | | |
| | | private void BtnEsc_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (MsgHelper.AskQuestion("确定要要取消吗?")) |
| | | { |
| | | var lst = new List<string>(); |
| | | lst.Add(btnAdd.Name); |
| | | lst.Add(btnEdit.Name); |
| | | lst.Add(btnLoad.Name); |
| | | lst.Add(btnDel.Name); |
| | | lst.Add(btnRole.Name); |
| | | lst.Add(btnQuery.Name); |
| | | lst.Add(btnReport.Name); |
| | | lst.Add(btnDesign.Name); |
| | | lst.Add(btnChk.Name); |
| | | lst.Add(btnFchk.Name); |
| | | _enabledBtn(lst); |
| | | if (btnEscClick != null) btnEscClick(this, e); |
| | | } |
| | | } |
| | | |
| | | private void BtnKG_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnKGClick != null) btnKGClick(this, e); |
| | | } |
| | | |
| | | private void BtnSave_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnSaveClick != null) |
| | | { |
| | | btnSaveClick(this, e); |
| | | if (isSetBtn) |
| | | { |
| | | var lst = new List<string>(); |
| | | lst.Add(btnAdd.Name); |
| | | lst.Add(btnEdit.Name); |
| | | lst.Add(btnEsc.Name); |
| | | _enabledBtn(lst); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void BtnLoad_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnLoadClick != null) |
| | | //List<string> lst = new List<string>(); |
| | | //lst.Add(btnRole.Name); |
| | | //setBtn(lst); |
| | | btnLoadClick(this, e); |
| | | } |
| | | |
| | | private void BtnEdit_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | var lst = new List<string>(); |
| | | lst.Add(btnSave.Name); |
| | | lst.Add(btnEsc.Name); |
| | | _enabledBtn(lst); |
| | | if (btnEdtClick != null) btnEdtClick(this, e); |
| | | } |
| | | |
| | | private void BtnDel_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnDelClick != null) btnDelClick(this, e); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void BtnAdd_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | var lst = new List<string>(); |
| | | lst.Add(btnSave.Name); |
| | | lst.Add(btnEsc.Name); |
| | | _enabledBtn(lst); |
| | | if (btnAddClick != null) btnAddClick(this, e); |
| | | } |
| | | |
| | | private void BtnRole_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | //List<string> lst = new List<string>(); |
| | | //lst.Add(btnSave.Name); |
| | | //lst.Add(btnEsc.Name); |
| | | //setBtn(lst); |
| | | if (btnRoleClick != null) btnRoleClick(this, e); |
| | | } |
| | | |
| | | private void _enabledBtn(List<string> lstBtn) |
| | | { |
| | | foreach (BarItem item in barManager1.Items) |
| | | if (item is BarLargeButtonItem largeButtonItem) |
| | | { |
| | | if (lstBtn.Contains(item.Name)) |
| | | largeButtonItem.Enabled = true; |
| | | else |
| | | largeButtonItem.Enabled = false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据命名空间和权限,读取该窗体下面的按钮集合 |
| | | /// </summary> |
| | | private void getNamespace() |
| | | { |
| | | var _formNamespace = ""; |
| | | Control parentControl = this; |
| | | while (parentControl.Parent != null) |
| | | { |
| | | if (parentControl.Parent is Form parentForm) |
| | | { |
| | | var formType = parentForm.GetType(); |
| | | _formNamespace = formType.FullName; |
| | | break; |
| | | } |
| | | |
| | | parentControl = parentControl.Parent; |
| | | } |
| | | |
| | | var _obj = new |
| | | { |
| | | userGuid = LoginInfoModel.CurrentUser.LoginUserGuid, |
| | | orgGuid = LoginInfoModel.CurrentUser.LoginOrgGuid, |
| | | formNamespace = _formNamespace |
| | | }; |
| | | var strReturn = ""; |
| | | try |
| | | { |
| | | strReturn = UtilityHelper.HttpPost("", |
| | | "Role/GetListByUserOrgSpace", |
| | | JsonConvert.SerializeObject(_obj)); |
| | | var dd = UtilityHelper.ReturnToList(strReturn); |
| | | var dt = dd.rtnData; |
| | | var _enabledList = new List<string>(); |
| | | foreach (BarItem item in barManager1.Items) |
| | | { |
| | | ///具有联动关系的按钮(增加), |
| | | if (item.Caption == "增加") |
| | | { |
| | | var ld1 = dt.AsEnumerable().Any( |
| | | row => row.Field<string>("name") == "增加" |
| | | //|| row.Field<string>("name") == "修改" |
| | | ); |
| | | if (ld1) |
| | | { |
| | | btnEsc.Visibility = btnSave.Visibility = |
| | | btnLoad.Visibility = BarItemVisibility.Always; |
| | | btnAdd.Visibility = BarItemVisibility.Always; |
| | | _enabledList.Add(item.Name); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | ///具有联动关系的按钮(修改), |
| | | if (item.Caption == "修改") |
| | | { |
| | | var ld1 = dt.AsEnumerable().Any( |
| | | row => row.Field<string>("name") == "修改" |
| | | ); |
| | | if (ld1) |
| | | { |
| | | btnEsc.Visibility = btnSave.Visibility = |
| | | btnLoad.Visibility = BarItemVisibility.Always; |
| | | btnEdit.Visibility = BarItemVisibility.Always; |
| | | _enabledList.Add(item.Name); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | ///具有联动关系的按钮(查询), |
| | | var ld2 = dt.AsEnumerable().Any( |
| | | row => row.Field<string>("name") == "查询" |
| | | ); |
| | | if (ld2) |
| | | if (item.Caption == "刷新") |
| | | { |
| | | item.Visibility = BarItemVisibility.Always; |
| | | //准备启用 |
| | | _enabledList.Add(item.Name); |
| | | continue; |
| | | } |
| | | |
| | | ///具有联动关系的按钮(提交检验), |
| | | if (item.Caption == "提交检验") |
| | | { |
| | | var ld1 = dt.AsEnumerable().Any( |
| | | row => row.Field<string>("name") == "提交检验" |
| | | ); |
| | | if (ld1) |
| | | { |
| | | btnJianYan.Visibility = btnFjianYan.Visibility = |
| | | btnLoad.Visibility = BarItemVisibility.Always; |
| | | btnJianYan.Visibility = BarItemVisibility.Always; |
| | | _enabledList.Add(item.Name); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | //按钮是否在权限表中 |
| | | var exists = dt.AsEnumerable().Any(row => |
| | | row.Field<string>("name") == item.Caption); |
| | | if (exists) |
| | | { |
| | | item.Visibility = BarItemVisibility.Always; |
| | | //准备启用 |
| | | var _btnName = |
| | | _FindBarLargeButtonItemByCaption(item.Caption); |
| | | if (!string.IsNullOrEmpty(_btnName)) |
| | | _enabledList.Add(_btnName); |
| | | } |
| | | } |
| | | |
| | | //默认启用的按钮 |
| | | // _enabledList.Add(btnDesign.Name); |
| | | _enabledBtn(_enabledList); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据文字,查找按钮name |
| | | /// </summary> |
| | | /// <param name="caption"></param> |
| | | /// <returns></returns> |
| | | private string _FindBarLargeButtonItemByCaption(string caption) |
| | | { |
| | | foreach (BarItem item in barManager1.Items) |
| | | if (item is BarLargeButtonItem largeButtonItem && |
| | | largeButtonItem.Caption == caption) |
| | | return largeButtonItem.Name; |
| | | return null; |
| | | } |
| | | |
| | | private bool _ckRptService() |
| | | { |
| | | try |
| | | { |
| | | var _obj = new |
| | | { |
| | | rptParameter |
| | | }; |
| | | var strJson = UtilityHelper.HttpPost("", "Report/GetTemplate", |
| | | JsonConvert.SerializeObject(_obj)); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) return true; |
| | | return false; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | private void _ckService(string _ckValue) |
| | | { |
| | | var _obj = new |
| | | { |
| | | guid = guidKey, |
| | | parameter = chkParameter, |
| | | ckValue = _ckValue |
| | | }; |
| | | var strJson = UtilityHelper.HttpPost("", "General/GeneralCheck", |
| | | JsonConvert.SerializeObject(_obj)); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | MsgHelper.Warning("提示:" + _rtn.rtnData["outMsg"].ToString()); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | } |
| | | } |
| | | |
| | | #region 公共事件 |
| | | |
| | | /// <summary> |
| | | /// 新增 |
| | | /// </summary> |
| | |
| | | /// 检验 |
| | | /// </summary> |
| | | public event EventHandler btnJianYanClick; |
| | | |
| | | /// <summary> |
| | | /// 反检验 |
| | | /// </summary> |
| | |
| | | #endregion |
| | | |
| | | #region 公共属性 |
| | | |
| | | |
| | | public bool isSetBtn { get; set; } |
| | | |
| | |
| | | /// 审核参数,表名,字段名,如:MES_HOLIDAY,check_date,check_status,check_by |
| | | /// </summary> |
| | | public string chkParameter { get; set; } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | public UcToolBarMenu() |
| | | { |
| | | InitializeComponent(); |
| | | this.btnAdd.ItemClick += BtnAdd_ItemClick; |
| | | this.btnDel.ItemClick += BtnDel_ItemClick; |
| | | this.btnEdit.ItemClick += BtnEdit_ItemClick; |
| | | this.btnLoad.ItemClick += BtnLoad_ItemClick; |
| | | this.btnSave.ItemClick += BtnSave_ItemClick; |
| | | this.btnKG.ItemClick += BtnKG_ItemClick; |
| | | this.btnEsc.ItemClick += BtnEsc_ItemClick; |
| | | this.btnRole.ItemClick += BtnRole_ItemClick; |
| | | this.btnQuery.ItemClick += BtnQuery_ItemClick; |
| | | this.btnReport.ItemClick += BtnReport_ItemClick; |
| | | this.btnDesign.ItemClick += BtnDesign_ItemClick; |
| | | this.btnOut.ItemClick += BtnOut_ItemClick; |
| | | this.btnIn.ItemClick += BtnIn_ItemClick; |
| | | this.btnChk.ItemClick += BtnChk_ItemClick; |
| | | this.btnFchk.ItemClick += BtnFchk_ItemClick; |
| | | this.btnJianYan.ItemClick += BtnJianYan_ItemClick; |
| | | this.btnFjianYan.ItemClick += BtnFjianYan_ItemClick; |
| | | List<string> lst = new List<string>(); |
| | | foreach (BarItem item in barManager1.Items) |
| | | { |
| | | if (item is BarLargeButtonItem largeButtonItem) |
| | | { |
| | | if (!string.IsNullOrEmpty(item.Caption)) |
| | | lst.Add(item.Caption); |
| | | } |
| | | } |
| | | this.actions = lst; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 初始化按钮状态 |
| | | /// </summary> |
| | | protected override void OnCreateControl() |
| | | { |
| | | base.OnCreateControl(); |
| | | if (this.Parent != null) |
| | | { |
| | | getNamespace(); |
| | | } |
| | | } |
| | | private void BtnFchk_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnFChkClick != null) |
| | | { |
| | | btnFChkClick(this, e); |
| | | } |
| | | else |
| | | return; |
| | | |
| | | if (string.IsNullOrEmpty(this.guidKey)) |
| | | { |
| | | ToolBox.MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(this.chkParameter)) |
| | | { |
| | | ToolBox.MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定反审核吗?")) |
| | | return; |
| | | _ckService(0.ToString()); |
| | | } |
| | | private void BtnChk_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnChkClick != null) |
| | | { |
| | | btnChkClick(this, e); |
| | | } |
| | | else |
| | | return; |
| | | |
| | | if (string.IsNullOrEmpty(this.guidKey)) |
| | | { |
| | | ToolBox.MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(this.chkParameter)) |
| | | { |
| | | ToolBox.MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定审核吗?")) |
| | | return; |
| | | _ckService(1.ToString()); |
| | | } |
| | | |
| | | private void BtnFjianYan_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnFjianYanClick != null) |
| | | { |
| | | btnFjianYanClick(this, e); |
| | | } |
| | | else |
| | | return; |
| | | |
| | | if (string.IsNullOrEmpty(this.guidKey)) |
| | | { |
| | | ToolBox.MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(this.chkParameter)) |
| | | { |
| | | ToolBox.MsgHelper.ShowError("没有指定检验参数,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定反检验吗?")) |
| | | return; |
| | | _ckService(0.ToString()); |
| | | } |
| | | |
| | | private void BtnJianYan_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnJianYanClick != null) |
| | | { |
| | | btnJianYanClick(this, e); |
| | | } |
| | | else |
| | | return; |
| | | |
| | | if (string.IsNullOrEmpty(this.guidKey)) |
| | | { |
| | | ToolBox.MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(this.chkParameter)) |
| | | { |
| | | ToolBox.MsgHelper.ShowError("没有指定检验参数,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定提交检验吗?")) |
| | | return; |
| | | var _obj = new |
| | | { |
| | | guid = this.guidKey, |
| | | parameter = this.chkParameter |
| | | }; |
| | | _ckService(1.ToString()); |
| | | } |
| | | |
| | | private async void BtnIn_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (string.IsNullOrEmpty(this.xlsInService)) |
| | | { |
| | | ToolBox.MsgHelper.ShowError("没有指定导入服务,请联系开发人员获取支持!"); |
| | | return; |
| | | } |
| | | OpenFileDialog openFileDialog = new OpenFileDialog(); |
| | | //openFileDialog.InitialDirectory = "c:\\"; |
| | | openFileDialog.Filter = "文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*"; |
| | | openFileDialog.Title = "选择文件"; |
| | | DialogResult result = openFileDialog.ShowDialog(); |
| | | if (result == DialogResult.OK) |
| | | { |
| | | string WebApiUrl = ConfigurationManager.AppSettings["WebApiUrl"].ToString() + "Upload/UploadFile"; |
| | | string strJson = await UtilityHelper.UploadFileAsync(openFileDialog.FileName); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | string filePath = _rtn.rtnData["filePath"].ToString(); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | var _obj = filePath; |
| | | try |
| | | { |
| | | strJson = UtilityHelper.HttpPost("", "XlsInOut/" + xlsInService, JsonConvert.SerializeObject(_obj)); |
| | | _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | ToolBox.MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void BtnOut_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | //if (string.IsNullOrEmpty(this.xlsOutView)) |
| | | //{ |
| | | // ToolBox.MsgHelper.ShowError("没有指定导出服务,请联系开发人员获取支持!"); |
| | | // return; |
| | | //} |
| | | //using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) |
| | | //{ |
| | | // folderBrowserDialog.Description = "选择导出文件的保存路径"; |
| | | // DialogResult dialogResult = folderBrowserDialog.ShowDialog(); |
| | | // if (dialogResult == DialogResult.OK) |
| | | // { |
| | | // string _folder = folderBrowserDialog.SelectedPath; |
| | | // var _obj = new Gs.DevApp.Entity.XlsOutModel(this.xlsOutView); |
| | | // try |
| | | // { |
| | | // string strJson = UtilityHelper.HttpPost("", "XlsInOut/XlsOutView", JsonConvert.SerializeObject(_obj)); |
| | | // ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | // if (_rtn.rtnCode > 0) |
| | | // { |
| | | // string _file = _rtn.rtnData.fileUrl.ToString(); |
| | | // string _folderName = _folder + "\\" + _file.Replace("down/", ""); |
| | | // string _url = ConfigurationManager.AppSettings["WebApiUrl"].ToString() + _file; |
| | | // using (WebClient client = new WebClient()) |
| | | // { |
| | | // client.DownloadFile(_url, _folderName); |
| | | // } |
| | | // ToolBox.MsgHelper.ShowInformation("导出成功!"); |
| | | // } |
| | | // else |
| | | // { |
| | | // ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | // } |
| | | // } |
| | | //} |
| | | } |
| | | private void BtnReport_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (string.IsNullOrEmpty(this.rptParameter)) |
| | | { |
| | | ToolBox.MsgHelper.ShowError("没有指定报表参数,请联系技术开发人员!"); |
| | | return; |
| | | } |
| | | bool _bl = false; |
| | | _bl = _ckRptService(); |
| | | if (_bl) |
| | | { |
| | | Gs.DevApp.DevFrm.Rpt.RptPreview frm = new Gs.DevApp.DevFrm.Rpt.RptPreview(this.rptParameter); |
| | | frm.Show(); |
| | | return; |
| | | } |
| | | ToolBox.MsgHelper.ShowError("没有设计模板,请先设计模板!"); |
| | | return; |
| | | } |
| | | private void BtnDesign_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (string.IsNullOrEmpty(this.rptParameter)) |
| | | { |
| | | ToolBox.MsgHelper.ShowError("没有指定报表参数,请联系技术开发人员!"); |
| | | return; |
| | | } |
| | | bool _bl = false; |
| | | _bl = _ckRptService(); |
| | | //如果已经有模板了,直接打开设置模板 |
| | | if (_bl) |
| | | { |
| | | Gs.DevApp.DevFrm.Sys.EasyRptDesign frm = new Gs.DevApp.DevFrm.Sys.EasyRptDesign(this.rptParameter); |
| | | frm.Show(); |
| | | return; |
| | | } |
| | | //否则向导设计模板 |
| | | UserControl.ShowRptWizard rptWizard = new ShowRptWizard(this.rptParameter); |
| | | rptWizard.ShowDialog(); |
| | | } |
| | | |
| | | private void BtnQuery_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (btnQueryClick != null) |
| | | { |
| | | btnQueryClick(this, e); |
| | | } |
| | | } |
| | | |
| | | private void BtnEsc_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (MsgHelper.AskQuestion("确定要要取消吗?")) |
| | | { |
| | | List<string> lst = new List<string>(); |
| | | lst.Add(btnAdd.Name); |
| | | lst.Add(btnEdit.Name); |
| | | lst.Add(btnLoad.Name); |
| | | lst.Add(btnDel.Name); |
| | | lst.Add(btnRole.Name); |
| | | lst.Add(btnQuery.Name); |
| | | lst.Add(btnReport.Name); |
| | | lst.Add(btnDesign.Name); |
| | | lst.Add(btnChk.Name); |
| | | lst.Add(btnFchk.Name); |
| | | _enabledBtn(lst); |
| | | if (btnEscClick != null) |
| | | { |
| | | btnEscClick(this, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void BtnKG_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (btnKGClick != null) |
| | | { |
| | | btnKGClick(this, e); |
| | | } |
| | | } |
| | | |
| | | private void BtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (btnSaveClick != null) |
| | | { |
| | | btnSaveClick(this, e); |
| | | if (isSetBtn == true) |
| | | { |
| | | List<string> lst = new List<string>(); |
| | | lst.Add(btnAdd.Name); |
| | | lst.Add(btnEdit.Name); |
| | | lst.Add(btnEsc.Name); |
| | | _enabledBtn(lst); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void BtnLoad_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | |
| | | if (btnLoadClick != null) |
| | | { |
| | | //List<string> lst = new List<string>(); |
| | | //lst.Add(btnRole.Name); |
| | | //setBtn(lst); |
| | | btnLoadClick(this, e); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void BtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | List<string> lst = new List<string>(); |
| | | lst.Add(btnSave.Name); |
| | | lst.Add(btnEsc.Name); |
| | | _enabledBtn(lst); |
| | | if (btnEdtClick != null) |
| | | { |
| | | btnEdtClick(this, e); |
| | | } |
| | | } |
| | | |
| | | private void BtnDel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (btnDelClick != null) |
| | | { |
| | | btnDelClick(this, e); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void BtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | List<string> lst = new List<string>(); |
| | | lst.Add(btnSave.Name); |
| | | lst.Add(btnEsc.Name); |
| | | _enabledBtn(lst); |
| | | if (btnAddClick != null) |
| | | { |
| | | btnAddClick(this, e); |
| | | } |
| | | } |
| | | |
| | | private void BtnRole_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | //List<string> lst = new List<string>(); |
| | | //lst.Add(btnSave.Name); |
| | | //lst.Add(btnEsc.Name); |
| | | //setBtn(lst); |
| | | if (btnRoleClick != null) |
| | | { |
| | | btnRoleClick(this, e); |
| | | } |
| | | } |
| | | private void _enabledBtn(List<string> lstBtn) |
| | | { |
| | | foreach (BarItem item in barManager1.Items) |
| | | { |
| | | if (item is BarLargeButtonItem largeButtonItem) |
| | | { |
| | | if (lstBtn.Contains(item.Name)) |
| | | largeButtonItem.Enabled = true; |
| | | else |
| | | largeButtonItem.Enabled = false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据命名空间和权限,读取该窗体下面的按钮集合 |
| | | /// </summary> |
| | | private void getNamespace() |
| | | { |
| | | string _formNamespace = ""; |
| | | System.Windows.Forms.Control parentControl = this; |
| | | while (parentControl.Parent != null) |
| | | { |
| | | if (parentControl.Parent is Form parentForm) |
| | | { |
| | | Type formType = parentForm.GetType(); |
| | | _formNamespace = formType.FullName; |
| | | break; |
| | | } |
| | | parentControl = parentControl.Parent; |
| | | } |
| | | var _obj = new |
| | | { |
| | | userGuid = LoginInfoModel.CurrentUser.LoginUserGuid, |
| | | orgGuid = LoginInfoModel.CurrentUser.LoginOrgGuid, |
| | | formNamespace = _formNamespace, |
| | | }; |
| | | string strReturn = ""; |
| | | try |
| | | { |
| | | strReturn = UtilityHelper.HttpPost("", "Role/GetListByUserOrgSpace", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<DataTable> dd = UtilityHelper.ReturnToList(strReturn); |
| | | DataTable dt = dd.rtnData; |
| | | List<string> _enabledList = new List<string>(); |
| | | foreach (BarItem item in barManager1.Items) |
| | | { |
| | | ///具有联动关系的按钮(增加), |
| | | if (item.Caption == "增加") |
| | | { |
| | | bool ld1 = dt.AsEnumerable().Any(row => row.Field<string>("name") == "增加" |
| | | //|| row.Field<string>("name") == "修改" |
| | | ); |
| | | if (ld1 == true) |
| | | { |
| | | |
| | | btnEsc.Visibility = btnSave.Visibility = btnLoad.Visibility = BarItemVisibility.Always; |
| | | btnAdd.Visibility = BarItemVisibility.Always; |
| | | _enabledList.Add(item.Name); |
| | | continue; |
| | | } |
| | | } |
| | | ///具有联动关系的按钮(修改), |
| | | if (item.Caption == "修改") |
| | | { |
| | | bool ld1 = dt.AsEnumerable().Any(row => row.Field<string>("name") == "修改" |
| | | ); |
| | | if (ld1 == true) |
| | | { |
| | | btnEsc.Visibility = btnSave.Visibility = btnLoad.Visibility = BarItemVisibility.Always; |
| | | btnEdit.Visibility = BarItemVisibility.Always; |
| | | _enabledList.Add(item.Name); |
| | | continue; |
| | | } |
| | | } |
| | | ///具有联动关系的按钮(查询), |
| | | bool ld2 = dt.AsEnumerable().Any(row => row.Field<string>("name") == "查询" |
| | | ); |
| | | if (ld2 == true) |
| | | { |
| | | if (item.Caption == "刷新") |
| | | { |
| | | item.Visibility = BarItemVisibility.Always; |
| | | //准备启用 |
| | | _enabledList.Add(item.Name); |
| | | continue; |
| | | } |
| | | } |
| | | ///具有联动关系的按钮(提交检验), |
| | | if (item.Caption == "提交检验") |
| | | { |
| | | bool ld1 = dt.AsEnumerable().Any(row => row.Field<string>("name") == "提交检验" |
| | | ); |
| | | if (ld1 == true) |
| | | { |
| | | btnJianYan.Visibility = btnFjianYan.Visibility = btnLoad.Visibility = BarItemVisibility.Always; |
| | | btnJianYan.Visibility = BarItemVisibility.Always; |
| | | _enabledList.Add(item.Name); |
| | | continue; |
| | | } |
| | | } |
| | | //按钮是否在权限表中 |
| | | bool exists = dt.AsEnumerable().Any(row => row.Field<string>("name") == item.Caption); |
| | | if (exists == true) |
| | | { |
| | | item.Visibility = BarItemVisibility.Always; |
| | | //准备启用 |
| | | string _btnName = _FindBarLargeButtonItemByCaption(item.Caption); |
| | | if (!string.IsNullOrEmpty(_btnName)) |
| | | _enabledList.Add(_btnName); |
| | | } |
| | | } |
| | | //默认启用的按钮 |
| | | // _enabledList.Add(btnDesign.Name); |
| | | _enabledBtn(_enabledList); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据文字,查找按钮name |
| | | /// </summary> |
| | | /// <param name="caption"></param> |
| | | /// <returns></returns> |
| | | private string _FindBarLargeButtonItemByCaption(string caption) |
| | | { |
| | | foreach (BarItem item in barManager1.Items) |
| | | { |
| | | if (item is BarLargeButtonItem largeButtonItem && largeButtonItem.Caption == caption) |
| | | { |
| | | return largeButtonItem.Name; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private bool _ckRptService() |
| | | { |
| | | try |
| | | { |
| | | var _obj = new |
| | | { |
| | | rptParameter = this.rptParameter, |
| | | }; |
| | | string strJson = UtilityHelper.HttpPost("", "Report/GetTemplate", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private void _ckService(string _ckValue) |
| | | { |
| | | var _obj = new |
| | | { |
| | | guid = this.guidKey, |
| | | parameter = this.chkParameter, |
| | | ckValue = _ckValue |
| | | }; |
| | | string strJson = UtilityHelper.HttpPost("", "General/GeneralCheck", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnData["outMsg"].ToString()); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |