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

📄 dlgdatatype.cs

📁 报刊广告管理系统。CSharp编写
💻 CS
字号:
using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Windows.Forms;using System.Data;namespace WWAM.Forms.Dlg{	public class DlgDataType : WWAM.Forms.Dlg.DlgBase	{
		#region DlgDataType

		private DevExpress.XtraEditors.TextEdit txtCode;
		private DevExpress.XtraEditors.MemoEdit txtMemo;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label lblTitle;
		private System.Windows.Forms.Label lblName;		private System.ComponentModel.IContainer components = null;		public DlgDataType()		{			// 该调用是 Windows 窗体设计器所必需的。			InitializeComponent();			// TODO: 在 InitializeComponent 调用后添加任何初始化		}		public DlgDataType(Form form):base(form)		{			// 该调用是 Windows 窗体设计器所必需的。			InitializeComponent();			// TODO: 在 InitializeComponent 调用后添加任何初始化		}		/// <summary>		/// 清理所有正在使用的资源。		/// </summary>		protected override void Dispose( bool disposing )		{			if( disposing )			{				if (components != null) 				{					components.Dispose();				}			}			base.Dispose( disposing );		}		#region 设计器生成的代码		/// <summary>		/// 设计器支持所需的方法 - 不要使用代码编辑器修改		/// 此方法的内容。		/// </summary>		private void InitializeComponent()		{			this.lblName = new System.Windows.Forms.Label();
			this.txtCode = new DevExpress.XtraEditors.TextEdit();
			this.txtMemo = new DevExpress.XtraEditors.MemoEdit();
			this.label2 = new System.Windows.Forms.Label();
			this.lblTitle = new System.Windows.Forms.Label();
			((System.ComponentModel.ISupportInitialize)(this.txtCode.Properties)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.txtMemo.Properties)).BeginInit();
			this.SuspendLayout();
			// 
			// btnAccept
			// 
			this.btnAccept.Location = new System.Drawing.Point(128, 168);
			this.btnAccept.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
			this.btnAccept.LookAndFeel.UseWindowsXPTheme = false;
			this.btnAccept.Name = "btnAccept";
			this.btnAccept.TabIndex = 2;
			// 
			// btnCancel
			// 
			this.btnCancel.Location = new System.Drawing.Point(224, 168);
			this.btnCancel.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
			this.btnCancel.LookAndFeel.UseWindowsXPTheme = false;
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 3;
			// 
			// lblName
			// 
			this.lblName.Location = new System.Drawing.Point(24, 48);
			this.lblName.Name = "lblName";
			this.lblName.Size = new System.Drawing.Size(72, 24);
			this.lblName.TabIndex = 2;
			this.lblName.Text = "名称:";
			this.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// txtCode
			// 
			this.txtCode.EditValue = "";
			this.txtCode.EnterMoveNextControl = true;
			this.txtCode.Location = new System.Drawing.Point(104, 48);
			this.txtCode.Name = "txtCode";
			// 
			// txtCode.Properties
			// 
			this.txtCode.Properties.AppearanceFocused.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(224)), ((System.Byte)(192)));
			this.txtCode.Properties.AppearanceFocused.Options.UseBackColor = true;
			this.txtCode.Size = new System.Drawing.Size(176, 21);
			this.txtCode.TabIndex = 0;
			this.txtCode.EditValueChanged += new System.EventHandler(this.BaseEditor_EditValueChanged);
			// 
			// txtMemo
			// 
			this.txtMemo.EditValue = "";
			this.txtMemo.EnterMoveNextControl = true;
			this.txtMemo.Location = new System.Drawing.Point(104, 80);
			this.txtMemo.Name = "txtMemo";
			// 
			// txtMemo.Properties
			// 
			this.txtMemo.Properties.AppearanceFocused.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(224)), ((System.Byte)(192)));
			this.txtMemo.Properties.AppearanceFocused.Options.UseBackColor = true;
			this.txtMemo.Size = new System.Drawing.Size(176, 72);
			this.txtMemo.TabIndex = 1;
			this.txtMemo.EditValueChanged += new System.EventHandler(this.BaseEditor_EditValueChanged);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 80);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 24);
			this.label2.TabIndex = 5;
			this.label2.Text = "备注:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblTitle
			// 
			this.lblTitle.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblTitle.ForeColor = System.Drawing.Color.RoyalBlue;
			this.lblTitle.Location = new System.Drawing.Point(16, 8);
			this.lblTitle.Name = "lblTitle";
			this.lblTitle.Size = new System.Drawing.Size(128, 24);
			this.lblTitle.TabIndex = 6;
			this.lblTitle.Text = "基本资料";
			// 
			// DlgDataType
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(314, 208);
			this.Controls.Add(this.lblTitle);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.txtMemo);
			this.Controls.Add(this.txtCode);
			this.Controls.Add(this.lblName);
			this.Name = "DlgDataType";
			this.Controls.SetChildIndex(this.lblName, 0);
			this.Controls.SetChildIndex(this.txtCode, 0);
			this.Controls.SetChildIndex(this.txtMemo, 0);
			this.Controls.SetChildIndex(this.btnCancel, 0);
			this.Controls.SetChildIndex(this.btnAccept, 0);
			this.Controls.SetChildIndex(this.label2, 0);
			this.Controls.SetChildIndex(this.lblTitle, 0);
			((System.ComponentModel.ISupportInitialize)(this.txtCode.Properties)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.txtMemo.Properties)).EndInit();
			this.ResumeLayout(false);

		}		#endregion		#endregion
		#region Variable		bool appendmode = true;		DataView dvFind;		DataRow orow;		DlgFrmMsg msgBox;		#endregion		#region FormEvent		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad (e);
			msgBox = new DlgFrmMsg(this);
		}
		#endregion		#region Return Value		public DataRow GetRow()		{			orow["Code"] = this.txtCode.Text.Trim();			orow["Memo"] = this.txtMemo.Text.Trim();			return orow;		}		public bool IsChanged		{			get{return edited;}		}		#endregion		#region CanColse		protected override bool CanClose()
		{
			if(!appendmode && !edited)
			{
				return true;
			}
			if(DataRepeat())
			{
				msgBox.ShowWarning("指定的名称已被占用!");
				return false;
			}
			if(ControlEmpty(this.txtCode,"请输入名称"))return false;
			return base.CanClose ();
		}
		#endregion		#region OnFormShow		protected override void OnFormShow()
		{
			base.OnFormShow ();
			this.txtCode.Focus();
		}
		#endregion		#region ShowDialog		public DialogResult ShowDialog(int typeindex ,string typename, DataTable dtfind)		{			this.lblTitle.Text = typename;			this.lblName.Text = typename;			this.DataInit();			this.orow = WWAM.DBA.GetRow.GetTypeRow();			this.orow["Type"] = typeindex;			this.orow["Used"] = true;			this.dvFind = new DataView(dtfind);			this.edited = false;			this.appendmode = true;			return base.ShowDialog();		}		public DialogResult ShowDialog(DataRow dr , string typename,DataTable dtfind)		{			this.lblTitle.Text = typename;			this.lblName.Text = typename;			this.DataSetting(dr);			this.dvFind = new DataView(dtfind);			this.orow = WWAM.DBA.DRPro.CloneDataRow(dr);			this.edited = false;			this.appendmode = false;			return base.ShowDialog();		}		#endregion		#region DataMethod		void DataBind()		{		}		void DataInit()		{			this.txtCode.Text = string.Empty;			this.txtMemo.Text = string.Empty;		}		void DataSetting(DataRow _dr)		{			this.txtCode.Text = (string)_dr["Code"];			this.txtMemo.Text = (string)_dr["Memo"];		}		#endregion		#region Method		bool DataRepeat()		{			if(this.txtCode.Text.Trim()==string.Empty)				return false;			if(appendmode)			{				dvFind.RowFilter = string.Format("Code = '{0}' and Type = {1}",this.txtCode.Text.Trim(),(int)orow["Type"]);			}			else			{				dvFind.RowFilter = string.Format("Code = '{0}' and Type = {1} and Typeid <> {2}",this.txtCode.Text.Trim(),(int)orow["Type"],this.orow["Typeid"]);			}			return dvFind.Count>0;		}		#endregion	}}

⌨️ 快捷键说明

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