⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chdbase.cs

📁 报刊广告管理系统。CSharp编写
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;

namespace WWAM.Forms.Child
{
	/// <summary>
	/// ChdBase 的摘要说明。
	/// </summary>
	public class ChdBase : System.Windows.Forms.Form
	{
		#region ChdBase

		protected DevExpress.XtraNavBar.NavBarItem linkItem;
		private System.ComponentModel.IContainer components;
		protected DevExpress.XtraEditors.SimpleButton btnClose;
		private DevExpress.LookAndFeel.DefaultLookAndFeel defaultLookAndFeel1;

		public ChdBase()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		public ChdBase(DevExpress.XtraNavBar.NavBarItem item)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//

			linkItem = item;
			linkItem.Enabled = false;
		}
		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ChdBase));
			this.defaultLookAndFeel1 = new DevExpress.LookAndFeel.DefaultLookAndFeel(this.components);
			this.btnClose = new DevExpress.XtraEditors.SimpleButton();
			this.SuspendLayout();
			// 
			// defaultLookAndFeel1
			// 
			this.defaultLookAndFeel1.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
			this.defaultLookAndFeel1.LookAndFeel.UseWindowsXPTheme = false;
			// 
			// btnClose
			// 
			this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.btnClose.Image = ((System.Drawing.Image)(resources.GetObject("btnClose.Image")));
			this.btnClose.Location = new System.Drawing.Point(512, 8);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new System.Drawing.Size(24, 24);
			this.btnClose.TabIndex = 0;
			this.btnClose.TabStop = false;
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// ChdBase
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(552, 382);
			this.Controls.Add(this.btnClose);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "ChdBase";
			this.ResumeLayout(false);

		}
		#endregion
		#endregion

		#region Variable
		bool isFirstShow = true;
		WWAM.Forms.Dlg.DlgFrmMsg frmmsg;
		protected bool gridViewLayoutChanged = false;
		string layoutFileName = "";
		string layoutPath;
		#endregion
		
		#region Form Event
		protected override void OnClosed(EventArgs e)
		{
			OnFormClose();
			base.OnClosed (e);
			if(linkItem!=null)
				linkItem.Enabled = true;
			if(this.MdiParent!=null)
			{
				this.MdiParent.Text = WWAM.BLL.Global.PROGRAM_NAME;
			}
		}
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad (e);
			layoutPath = Application.StartupPath+@"\\gvLayout";
			isFirstShow = true;
			frmmsg = new WWAM.Forms.Dlg.DlgFrmMsg(this);
			if(linkItem!=null)
				this.Text = linkItem.Caption;
			OnFormLoad();
		}

		protected override void OnActivated(EventArgs e)
		{
			base.OnActivated (e);
			if(isFirstShow)
			{
				isFirstShow = false;
				OnFormShow();
			}
			if(this.MdiParent!=null)
			{
				this.MdiParent.Text = WWAM.BLL.Global.PROGRAM_NAME + " " + this.Text;
			}
			DataRefresh();
		}
		#endregion

		#region Virtaul Event
		protected virtual void OnFormLoad()
		{}
		protected virtual void OnFormClose()
		{}
		protected virtual void OnFormShow()
		{}
		protected virtual void DataRefresh()
		{}
		#endregion

		#region Control Event
		private void btnClose_Click(object sender, System.EventArgs e)
		{
			Close();
		}

		#endregion

		#region Property
		public WWAM.BLL.UserInfo BaseUserInfo
		{
			get
			{
				if(this.MdiParent!=null)
				{
					return ((FrmMain)MdiParent).UInfo;
				}
				else
				{
					return new WWAM.BLL.UserInfo();
				}
			}
		}
		public WWAM.DBA.SqlConn BaseDB
		{
			get
			{
				if(this.MdiParent!=null)
				{
					return ((FrmMain)MdiParent).DB;
				}
				else
				{
					return WWAM.DBA.Common.GetDB();
				}
			}
		}
		public WWAM.Forms.Dlg.DlgFrmMsg BaseMsgBox
		{
			get
			{
				return this.frmmsg;
			}
		}
		public WWAM.BLL.SysSetting BaseSysSet
		{
			get
			{
				if(this.MdiParent!=null)
				{
					return ((FrmMain)MdiParent).SysSet;
				}
				else
				{
					return new WWAM.BLL.SysSetting();
				}
			}
		}
		#endregion

		#region Property Method
		protected void setLayoutFileName(string fileName)
		{
			this.layoutFileName = layoutPath+"\\"+fileName+".gvl";
		}
		protected void ViewLoadLayout(DevExpress.XtraGrid.Views.Base.BaseView view)
		{
			if(File.Exists(layoutFileName))
			{
				view.RestoreLayoutFromXml(layoutFileName);
			}
		}
		protected void ViewSaveLayout(DevExpress.XtraGrid.Views.Base.BaseView view)
		{
			if(gridViewLayoutChanged && layoutFileName!="")
			{
				if(!Directory.Exists(layoutPath))
					Directory.CreateDirectory(layoutPath);
				view.SaveLayoutToXml(layoutFileName);
			}
		}
		protected void View_Layout(object sender, System.EventArgs e)
		{
			this.gridViewLayoutChanged = true;
		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -