123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using DevExpress.XtraEditors;
- namespace ProjectBase.Controls
- {
- public partial class BaseDock : DevExpress.XtraEditors.XtraForm
- {
- /// <summary>
- /// 子窗体数据保存的触发
- /// </summary>
- public event EventHandler OnDataSaved;
- /// <summary>
- /// 进行数据过滤的Sql条件,默认通过 Cache.Instance["DataFilterCondition"]获取
- /// </summary>
- public string DataFilterCondition { get; set; }
- /// <summary>
- /// 选择查看的公司ID
- /// </summary>
- public string SelectedCompanyID { get; set; }
- public BaseDock()
- {
- InitializeComponent();
- //为了保证一些界面控件的权限控制和身份确认,以及简化操作,在界面初始化的时候,从缓存里面内容(如果存在的话)
- //继承的子模块,也可以通过InitFunction()进行指定用户相关信息
- //this.LoginUserInfo = Cache.Instance["LoginUserInfo"] as LoginUserInfo;
- //this.FunctionDict = Cache.Instance["FunctionDict"] as Dictionary<string, string>;
- //// 进行数据过滤的Sql条件
- //this.DataFilterCondition = Cache.Instance["DataFilterCondition"] as string;
- //this.SelectedCompanyID = Cache.Instance["SelectedCompanyID"] as string;
- }
- /// <summary>
- /// 处理数据保存后的事件触发
- /// </summary>
- public virtual void ProcessDataSaved(object sender, EventArgs e)
- {
- if (OnDataSaved != null)
- {
- OnDataSaved(sender, e);
- }
- }
- /// <summary>
- /// 记录异常
- /// </summary>
- /// <param name="ex"></param>
- public void WriteException(Exception ex)
- {
- // 在本地记录异常
- //LogTextHelper.Error(ex);
- //MessageDxUtil.ShowError(ex.Message);
- }
- /// <summary>
- /// 处理异常信息
- /// </summary>
- /// <param name="ex">异常</param>
- public void ProcessException(Exception ex)
- {
- this.WriteException(ex);
- // 显示异常页面
- //FrmException frmException = new FrmException(this.UserInfo, ex);
- //frmException.ShowDialog();
- MessageBox.Show(ex.Message);//临时处理
- }
- /// <summary>
- /// 可供重写的窗体加载函数,子窗体特殊处理只需重写该函数
- /// </summary>
- public virtual void FormOnLoad()
- {
- }
- protected override void OnControlAdded(ControlEventArgs e)
- {
- if (!this.DesignMode)
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BaseDock));
- //this.Icon = WHC.WareHouseMis.DotUI.Properties.Resources.app;
- //this.StartPosition = FormStartPosition.CenterScreen;
- base.OnControlAdded(e);
- }
- }
- protected override void OnLoad(EventArgs e)
- {
- if (!this.DesignMode)
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BaseDock));
- this.StartPosition = FormStartPosition.CenterScreen;
- base.OnLoad(e);
- }
- }
- private void BaseForm_Load(object sender, EventArgs e)
- {
- if (!this.DesignMode)
- {
- // 设置鼠标繁忙状态
- this.Cursor = Cursors.WaitCursor;
- try
- {
- this.FormOnLoad();
- }
- catch (Exception ex)
- {
- this.ProcessException(ex);
- }
- finally
- {
- // 设置鼠标默认状态
- this.Cursor = Cursors.Default;
- }
- }
- }
- private void BaseForm_KeyUp(object sender, KeyEventArgs e)
- {
- switch (e.KeyCode)
- {
- case Keys.F5://刷新
- this.FormOnLoad();
- break;
- }
- }
- /// <summary>
- /// 初始化权限控制信息
- /// </summary>
- //public void InitFunction(LoginUserInfo userInfo, Dictionary<string, string> functionDict)
- //{
- // if (userInfo != null)
- // {
- // this.LoginUserInfo = userInfo;
- // }
- // if (functionDict != null && functionDict.Count > 0)
- // {
- // this.FunctionDict = functionDict;
- // }
- //}
- /// <summary>
- /// 是否具有访问指定控制ID的权限
- /// </summary>
- /// <param name="controlId">功能控制ID</param>
- /// <returns></returns>
- public bool HasFunction(string controlId)
- {
- bool result = false;
- if (string.IsNullOrEmpty(controlId))
- {
- result = true;
- }
- else if (FunctionDict != null && FunctionDict.ContainsKey(controlId))
- {
- result = true;
- }
- return result;
- }
- /// <summary>
- /// 登陆用户基础信息
- /// </summary>
- //public LoginUserInfo LoginUserInfo { get; set; }
- /// <summary>
- /// 登录用户具有的功能字典集合
- /// </summary>
- public Dictionary<string, string> FunctionDict { get; set; }
- //private AppInfo m_AppInfo = new AppInfo();
- /// <summary>
- /// 应用程序基础信息
- /// </summary>
- //public AppInfo AppInfo
- //{
- // get { return m_AppInfo; }
- // set { this.m_AppInfo = value; }
- //}
- }
- }
|