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

📄 backframe.cs

📁 独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 
💻 CS
字号:
using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Windows.Forms;using System.IO;using System.Data.SqlClient;using System.Data;namespace WindowsApplication{	public class backFrame : WindowsApplication.ParentFrame
	{
		#region 控件声明...
		
		protected System.Windows.Forms.Button btnBrowser;
		protected System.Windows.Forms.Button btnOK;
		protected System.Windows.Forms.Button btnCancel;
		protected System.Windows.Forms.ImageList imageList;
		private System.Windows.Forms.SaveFileDialog saveFile;
		protected System.Windows.Forms.TextBox FileText;
		private System.Windows.Forms.PictureBox pictureBox1;		private System.ComponentModel.IContainer components = null;		#endregion 		#region 构造函数...		public backFrame()		{			// 该调用是 Windows 窗体设计器所必需的。			InitializeComponent();			// TODO: 在 InitializeComponent 调用后添加任何初始化		}		/// <summary>		/// 清理所有正在使用的资源。		/// </summary>		protected override void Dispose( bool disposing )		{			if( disposing )			{				if (components != null) 				{					components.Dispose();				}			}			base.Dispose( disposing );		}		#endregion		#region 设计器生成的代码		/// <summary>		/// 设计器支持所需的方法 - 不要使用代码编辑器修改		/// 此方法的内容。		/// </summary>		private void InitializeComponent()		{			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(backFrame));
			this.FileText = new System.Windows.Forms.TextBox();
			this.btnBrowser = new System.Windows.Forms.Button();
			this.imageList = new System.Windows.Forms.ImageList(this.components);
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.saveFile = new System.Windows.Forms.SaveFileDialog();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(424, 32);
			this.label1.Text = "系统备份";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(112, 216);
			this.button1.Name = "button1";
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(216, 200);
			this.button2.Name = "button2";
			// 
			// label2
			// 
			this.label2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
			this.label2.Cursor = System.Windows.Forms.Cursors.Hand;
			this.label2.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.label2.Location = new System.Drawing.Point(0, 144);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(424, 40);
			this.label2.Text = "www.xinhuayi@.com";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// FileText
			// 
			this.FileText.BackColor = System.Drawing.Color.White;
			this.FileText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.FileText.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.FileText.Location = new System.Drawing.Point(120, 56);
			this.FileText.Name = "FileText";
			this.FileText.ReadOnly = true;
			this.FileText.Size = new System.Drawing.Size(160, 21);
			this.FileText.TabIndex = 1;
			this.FileText.Text = "";
			// 
			// btnBrowser
			// 
			this.btnBrowser.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.btnBrowser.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnBrowser.ForeColor = System.Drawing.Color.Blue;
			this.btnBrowser.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnBrowser.ImageIndex = 1;
			this.btnBrowser.ImageList = this.imageList;
			this.btnBrowser.Location = new System.Drawing.Point(304, 56);
			this.btnBrowser.Name = "btnBrowser";
			this.btnBrowser.Size = new System.Drawing.Size(80, 24);
			this.btnBrowser.TabIndex = 3;
			this.btnBrowser.Text = "浏览(&B)";
			this.btnBrowser.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.btnBrowser.Click += new System.EventHandler(this.btnBrowser_Click);
			// 
			// imageList
			// 
			this.imageList.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
			this.imageList.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// btnOK
			// 
			this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.btnOK.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnOK.ForeColor = System.Drawing.Color.Blue;
			this.btnOK.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnOK.ImageIndex = 2;
			this.btnOK.ImageList = this.imageList;
			this.btnOK.Location = new System.Drawing.Point(200, 104);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(80, 27);
			this.btnOK.TabIndex = 4;
			this.btnOK.Text = "确定(&K)";
			this.btnOK.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.btnCancel.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnCancel.ForeColor = System.Drawing.Color.Blue;
			this.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnCancel.ImageIndex = 0;
			this.btnCancel.ImageList = this.imageList;
			this.btnCancel.Location = new System.Drawing.Point(304, 104);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(80, 27);
			this.btnCancel.TabIndex = 5;
			this.btnCancel.Text = "取消(&C)";
			this.btnCancel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// saveFile
			// 
			this.saveFile.RestoreDirectory = true;
			this.saveFile.ShowHelp = true;
			this.saveFile.Title = "系统备份对话框";
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(0, 40);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(112, 96);
			this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pictureBox1.TabIndex = 6;
			this.pictureBox1.TabStop = false;
			// 
			// backFrame
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.White;
			this.CancelButton = null;
			this.ClientSize = new System.Drawing.Size(418, 183);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.btnBrowser);
			this.Controls.Add(this.FileText);
			this.Name = "backFrame";
			this.Text = "backFrame";
			this.Load += new System.EventHandler(this.backFrame_Load);
			this.Controls.SetChildIndex(this.FileText, 0);
			this.Controls.SetChildIndex(this.btnBrowser, 0);
			this.Controls.SetChildIndex(this.btnOK, 0);
			this.Controls.SetChildIndex(this.btnCancel, 0);
			this.Controls.SetChildIndex(this.pictureBox1, 0);
			this.Controls.SetChildIndex(this.label1, 0);
			this.Controls.SetChildIndex(this.button1, 0);
			this.Controls.SetChildIndex(this.button2, 0);
			this.Controls.SetChildIndex(this.label2, 0);
			this.ResumeLayout(false);

		}		#endregion		#region 变量声明...		private static string backSql="";        private  ConnectionData conn=new ConnectionData();		#endregion		#region 初始化变量...
		private void backFrame_Load(object sender, System.EventArgs e)
		{
		    this.saveFile.Filter="*.txt|*.txt";
			this.saveFile.InitialDirectory=Application.ExecutablePath+@"\WindowsApplication\backup\";
		}
		#endregion 
		#region 寻找文件存储一个字符串...
		private void btnBrowser_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(this.saveFile.ShowDialog()==DialogResult.OK)
				{
					this.FileText.Text=saveFile.FileName.ToString().Trim();
					backSql="backup database SystemODBC to disk='"+this.FileText.Text.ToString().Trim()+"'";
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}		#endregion
		#region 备份文件....
		private void btnOK_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(this.FileText.Text.ToString().Equals(""))
				{
					MessageBox.Show(this,"此处不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				}
				int k=conn.ExcuteStrSql(backSql);
				if(k>0)
				{
					MessageBox.Show(this,"备份成功!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				}
				else
				{
					MessageBox.Show(this,"备份失败!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				}
			}
			catch(Exception ese)
			{
				MessageBox.Show(this,ese.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}		#endregion
		#region 取消备份...
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
		    this.FileText.Text="";
			DialogResult result=MessageBox.Show(this,"是否关闭窗体呢???","提示信息",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
			if(result.Equals(DialogResult.Yes))
			{
				Close();
			}
			else
			{
				return;
			}
		}		#endregion	}}

⌨️ 快捷键说明

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