| | |
| | | using DevExpress.XtraBars.Navigation; |
| | | using DevExpress.XtraTab; |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Reflection; |
| | | using System.Windows.Forms; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | using DevExpress.XtraBars; |
| | | using DevExpress.XtraBars.FluentDesignSystem; |
| | | using DevExpress.XtraBars.Navigation; |
| | | using DevExpress.XtraTab; |
| | | using DevExpress.XtraTab.ViewInfo; |
| | | using Gs.DevApp.DevFrm.Sys; |
| | | using Gs.DevApp.DevFrm.User; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.ToolBox; |
| | | using Gs.DevApp.UserControl; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | |
| | | namespace Gs.DevApp.DevFrm |
| | | { |
| | | public partial class FrmMain : DevExpress.XtraBars.FluentDesignSystem.FluentDesignForm |
| | | public partial class FrmMain : FluentDesignForm |
| | | { |
| | | private static Dictionary<string, XtraTabPage> TabPageDic = new Dictionary<string, XtraTabPage>(); |
| | | private static readonly Dictionary<string, XtraTabPage> TabPageDic = |
| | | new Dictionary<string, XtraTabPage>(); |
| | | |
| | | public FrmMain() |
| | | { |
| | | InitializeComponent(); |
| | | this.Text = System.Configuration.ConfigurationSettings.AppSettings.Get("ProductName").ToString(); |
| | | Text = ConfigurationSettings.AppSettings.Get("ProductName"); |
| | | tab.CloseButtonClick += Tab_CloseButtonClick; |
| | | tooLoading.Click += TooLoading_Click; |
| | | barPwd.ItemClick += BarPwd_ItemClick; |
| | | barExit.ItemClick += BarExit_ItemClick; |
| | | this.FormClosing += FrmMain_FormClosing; |
| | | this.barEasy.ItemClick += BarEasy_ItemClick; |
| | | FormClosing += FrmMain_FormClosing; |
| | | barEasy.ItemClick += BarEasy_ItemClick; |
| | | getTree(); |
| | | } |
| | | |
| | | private void BarEasy_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | private void BarEasy_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | DevFrm.Sys.EasyCode frm = new Sys.EasyCode(); |
| | | var frm = new EasyCode(); |
| | | frm.ShowDialog(); |
| | | } |
| | | |
| | |
| | | { |
| | | if (MsgHelper.AskQuestion("确定要退出系统吗?")) |
| | | { |
| | | int i = _userOut(); |
| | | var i = _userOut(); |
| | | if (i > 0) |
| | | { |
| | | this.FormClosing -= new FormClosingEventHandler(this.FrmMain_FormClosing); |
| | | FormClosing -= FrmMain_FormClosing; |
| | | Application.Exit(); |
| | | } |
| | | else |
| | | e.Cancel = true;//取消。返回窗体 |
| | | { |
| | | e.Cancel = true; //取消。返回窗体 |
| | | } |
| | | } |
| | | else |
| | | e.Cancel = true;//取消。返回窗体 |
| | | { |
| | | e.Cancel = true; //取消。返回窗体 |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 退出 |
| | | /// 退出 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void BarExit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | private void BarExit_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | if (MsgHelper.AskQuestion("确定要退出系统吗?")) |
| | | { |
| | | int i = _userOut(); |
| | | var i = _userOut(); |
| | | if (i > 0) |
| | | { |
| | | this.FormClosing -= new FormClosingEventHandler(this.FrmMain_FormClosing); |
| | | FormClosing -= FrmMain_FormClosing; |
| | | Application.Exit(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置用户密码 |
| | | /// 设置用户密码 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void BarPwd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | private void BarPwd_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | User.UserSetPwd frm = new User.UserSetPwd(LoginInfoModel.CurrentUser.LoginUserGuid); |
| | | var frm = new UserSetPwd(LoginInfoModel.CurrentUser.LoginUserGuid); |
| | | frm.ShowDialog(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 重新加载系统 |
| | | /// 重新加载系统 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void TooLoading_Click(object sender, EventArgs e) |
| | | { |
| | | int i = 100; |
| | | Gs.DevApp.UserControl.ShowDialogForm sdf = new Gs.DevApp.UserControl.ShowDialogForm("提示", "", "请耐心等候,正在操作中!"); |
| | | for (int j = 0; j < i; j++) |
| | | { |
| | | sdf.SetCaption("执行进度(" + (j) + "/" + i.ToString() + ")"); |
| | | } |
| | | var i = 100; |
| | | var sdf = new ShowDialogForm("提示", "", "请耐心等候,正在操作中!"); |
| | | for (var j = 0; j < i; j++) |
| | | sdf.SetCaption("执行进度(" + j + "/" + i + ")"); |
| | | sdf.Close(); |
| | | getTree(); |
| | | } |
| | | |
| | | private void getTree() |
| | | { |
| | | toolTime.Text = "登录时间" + LoginInfoModel.CurrentUser.LoginTime; |
| | | var _obj = new |
| | | { |
| | | userGuid = LoginInfoModel.CurrentUser.LoginUserGuid, |
| | | orgGuid = LoginInfoModel.CurrentUser.LoginOrgGuid, |
| | | orgGuid = LoginInfoModel.CurrentUser.LoginOrgGuid |
| | | }; |
| | | try |
| | | { |
| | | string strJson = UtilityHelper.HttpPost("", "User/GetUserLoginInfo", JsonConvert.SerializeObject(_obj)); |
| | | JObject _job = JObject.Parse(strJson); |
| | | string rtnCode = _job["rtnCode"].ToString(); |
| | | var strJson = UtilityHelper.HttpPost("", |
| | | "User/GetUserLoginInfo", JsonConvert.SerializeObject(_obj)); |
| | | var _job = JObject.Parse(strJson); |
| | | var rtnCode = _job["rtnCode"].ToString(); |
| | | if (int.Parse(rtnCode) > 0) |
| | | { |
| | | this.acrd.Clear(); |
| | | acrd.Clear(); |
| | | barMsg.Caption = _job["rtnData"]["loginMsg"].ToString(); |
| | | JArray array = new JArray(); |
| | | var array = new JArray(); |
| | | var d = _job["rtnData"]["list"]; |
| | | foreach (var a in d) |
| | | { |
| | | array.Add(a); |
| | | } |
| | | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); |
| | | DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString()); |
| | | DataRow[] drGrp = dt.Select("upGuid is null"); |
| | | foreach (var a in d) array.Add(a); |
| | | var resources = |
| | | new ComponentResourceManager(typeof(FrmMain)); |
| | | var dt = |
| | | JsonConvert.DeserializeObject<DataTable>( |
| | | array.ToString()); |
| | | var drGrp = dt.Select("upGuid is null"); |
| | | int gdx = 0, idx = 0; |
| | | foreach (DataRow _dy in drGrp) |
| | | foreach (var _dy in drGrp) |
| | | { |
| | | AccordionControlElement _grp = this.acrd.AddGroup(); |
| | | _grp.ImageOptions.Image = UtilityHelper.GetImgFromResource(_dy["icon"].ToString(), 1); |
| | | var _grp = acrd.AddGroup(); |
| | | _grp.ImageOptions.Image = |
| | | UtilityHelper.GetImgFromResource( |
| | | _dy["icon"].ToString(), 1); |
| | | _grp.Name = _dy["guid"].ToString(); |
| | | _grp.Style = DevExpress.XtraBars.Navigation.ElementStyle.Group; |
| | | _grp.Style = ElementStyle.Group; |
| | | _grp.Text = _dy["name"].ToString(); |
| | | _grp.Tag = _dy["formPath"].ToString();//存路径,类名 |
| | | _grp.Tag = _dy["formPath"].ToString(); //存路径,类名 |
| | | _grp.Click += _grp_Click; |
| | | if (gdx == 0) |
| | | _grp.Expanded = true; |
| | | DataRow[] drItem = dt.Select("upGuid='" + _dy["guid"].ToString() + "'"); |
| | | foreach (DataRow _dy2 in drItem) |
| | | var drItem = dt.Select("upGuid='" + _dy["guid"] + "'"); |
| | | foreach (var _dy2 in drItem) |
| | | { |
| | | AccordionControlElement _itm = this.acrd.AddItem(); |
| | | _itm.ImageOptions.Image = UtilityHelper.GetImgFromResource(_dy2["icon"].ToString(), 2); |
| | | var _itm = acrd.AddItem(); |
| | | _itm.ImageOptions.Image = |
| | | UtilityHelper.GetImgFromResource( |
| | | _dy2["icon"].ToString(), 2); |
| | | _itm.Name = _dy2["guid"].ToString(); |
| | | _itm.Style = DevExpress.XtraBars.Navigation.ElementStyle.Item; |
| | | _itm.Style = ElementStyle.Item; |
| | | _itm.Text = _dy2["name"].ToString(); |
| | | _itm.Appearance.Normal.Font = new System.Drawing.Font("Tahoma", 10F); |
| | | _itm.Tag = _dy2["formPath"].ToString();//存路径,类名 |
| | | _itm.Appearance.Normal.Font = |
| | | new Font("Tahoma", 10F); |
| | | _itm.Tag = _dy2["formPath"].ToString(); //存路径,类名 |
| | | _itm.Click += _grp_Click; |
| | | _grp.Elements.Add(_itm); |
| | | if (idx == 0 && tab.TabPages.Count <= 0) |
| | | { |
| | | string tabPageName = _itm.Name + "_page"; |
| | | string tabText = _itm.Text;//当前选项卡页Text标题 |
| | | string newFormName = _itm.Tag.ToString();//存路径,类名 |
| | | Image imgIcon = _itm.Image; |
| | | AddTabpage(tab, tabPageName, tabText, newFormName, imgIcon); |
| | | var tabPageName = _itm.Name + "_page"; |
| | | var tabText = _itm.Text; //当前选项卡页Text标题 |
| | | var newFormName = _itm.Tag.ToString(); //存路径,类名 |
| | | var imgIcon = _itm.Image; |
| | | AddTabpage(tab, tabPageName, tabText, |
| | | newFormName, imgIcon); |
| | | } |
| | | |
| | | idx++; |
| | | }; |
| | | } |
| | | |
| | | ; |
| | | gdx++; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ToolBox.MsgHelper.ShowError("提示:初始化失败,请联系管理员!"); |
| | | MsgHelper.ShowError("提示:初始化失败,请联系管理员!"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.ShowError("提示:" + ex.Message); |
| | | MsgHelper.ShowError("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 左侧菜单点击 |
| | | /// 左侧菜单点击 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void _grp_Click(object sender, EventArgs e) |
| | | { |
| | | AccordionControlElement _acd = (AccordionControlElement)sender; |
| | | var _acd = (AccordionControlElement)sender; |
| | | if (_acd.Elements.Count > 0) return; |
| | | string tabPageName = _acd.Name + "_page"; |
| | | string tabText = _acd.Text; |
| | | string newFormName = _acd.Tag.ToString(); |
| | | Image imgIcon = _acd.Image; |
| | | var tabPageName = _acd.Name + "_page"; |
| | | var tabText = _acd.Text; |
| | | var newFormName = _acd.Tag.ToString(); |
| | | var imgIcon = _acd.Image; |
| | | AddTabpage(tab, tabPageName, tabText, newFormName, imgIcon); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 关闭选项卡 |
| | | /// 关闭选项卡 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | |
| | | { |
| | | RemoveTabPage(tab, e); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 新增选项卡页 |
| | | /// 新增选项卡页 |
| | | /// </summary> |
| | | /// <param name="tabControl">选项卡控件</param> |
| | | /// <param name="tabPageName">当期选项卡页name名称</param> |
| | | /// <param name="tabText">当前选项卡页Text标题</param> |
| | | /// <param name="newFormName">当前选项卡中的新窗体路径,类名</param> |
| | | public void AddTabpage(XtraTabControl tabControl, string tabPageName, string tabText, string newFormName, Image imgIcon) |
| | | public void AddTabpage(XtraTabControl tabControl, string tabPageName, |
| | | string tabText, string newFormName, Image imgIcon) |
| | | { |
| | | if (IsTabpageExsit(tabControl, tabPageName)) |
| | | { |
| | | return; |
| | | } |
| | | XtraTabPage newPage = new XtraTabPage(); |
| | | if (IsTabpageExsit(tabControl, tabPageName)) return; |
| | | var newPage = new XtraTabPage(); |
| | | newPage.Name = tabPageName; |
| | | newPage.Text = tabText; |
| | | newPage.Tooltip = newPage.Name; |
| | | newPage.Appearance.Header.Font = (tab.Appearance.Font); |
| | | newPage.Appearance.Header.Font = tab.Appearance.Font; |
| | | newPage.ImageOptions.Image = imgIcon; |
| | | Form fm = AddNewForm(newFormName); |
| | | var fm = AddNewForm(newFormName); |
| | | if (fm != null) |
| | | { |
| | | newPage.Controls.Add(fm); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 移除选项卡页 |
| | | /// 移除选项卡页 |
| | | /// </summary> |
| | | /// <param name="tabControl"></param> |
| | | /// <param name="tabPageName"></param> |
| | |
| | | { |
| | | if (TabPageDic.Count <= 1) |
| | | { |
| | | ToolBox.MsgHelper.Warning("请至少保留一个功能!"); |
| | | MsgHelper.Warning("请至少保留一个功能!"); |
| | | return; |
| | | } |
| | | DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs args = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs)e; |
| | | string name = args.Page.Tooltip; |
| | | |
| | | var args = (ClosePageButtonEventArgs)e; |
| | | var name = args.Page.Tooltip; |
| | | foreach (XtraTabPage item in tabControl.TabPages) |
| | | { |
| | | if (item.Name == name) |
| | | { |
| | | tabControl.TabPages.Remove(item); |
| | |
| | | TabPageDic.Remove(name); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断选项卡是否已经存在 |
| | | /// 判断选项卡是否已经存在 |
| | | /// </summary> |
| | | /// <param name="tabControl">选项卡控件</param> |
| | | /// <param name="tabPageName">选项卡名称</param> |
| | | /// <returns></returns> |
| | | private bool IsTabpageExsit(XtraTabControl tabControl, string tabPageName) |
| | | private bool IsTabpageExsit(XtraTabControl tabControl, |
| | | string tabPageName) |
| | | { |
| | | foreach (var item in TabPageDic) |
| | | { |
| | | if (item.Key == tabPageName) |
| | | { |
| | | tabControl.SelectedTabPage = item.Value; |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 在选项卡中生成窗体 |
| | | /// 在选项卡中生成窗体 |
| | | /// </summary> |
| | | /// <param name="form">窗体名称</param> |
| | | private Form AddNewForm(string formName) |
| | | { |
| | | try |
| | | { |
| | | Form newForm = (Form)Assembly.GetExecutingAssembly().CreateInstance(formName); |
| | | var newForm = (Form)Assembly.GetExecutingAssembly() |
| | | .CreateInstance(formName); |
| | | if (newForm == null) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError("请检查是否开通了该模块!"); |
| | | MsgHelper.ShowError("请检查是否开通了该模块!"); |
| | | return null; |
| | | } |
| | | |
| | | newForm.FormBorderStyle = FormBorderStyle.None; |
| | | newForm.TopLevel = false; |
| | | newForm.ControlBox = false; |
| | |
| | | } |
| | | catch (Exception) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError("请检查是否开通了该模块!"); |
| | | MsgHelper.ShowError("请检查是否开通了该模块!"); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | |
| | | { |
| | | var _obj = new |
| | | { |
| | | userGuid = LoginInfoModel.CurrentUser.LoginUserGuid, |
| | | userGuid = LoginInfoModel.CurrentUser.LoginUserGuid |
| | | }; |
| | | try |
| | | { |
| | | string strJson = UtilityHelper.HttpPost("", "User/UserOut", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | var strJson = UtilityHelper.HttpPost("", "User/UserOut", |
| | | JsonConvert.SerializeObject(_obj)); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) |
| | | return _rtn.rtnCode; |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnData.outMsg); |
| | | MsgHelper.Warning("提示:" + _rtn.rtnData.outMsg); |
| | | return _rtn.rtnCode; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | this.DialogResult = DialogResult.Cancel; |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | DialogResult = DialogResult.Cancel; |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | return -1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |