📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DataManager.Properties;
using System.Data.SqlClient;
namespace DataManager
{
public partial class Form1 : Form
{
public static string ConnectionString = Settings.Default.ConnectionString.ToString();
//SqlConnection cn = new SqlConnection(ConnectionString);
SqlCommand cmd ;
DataAccess cn = new DataAccess();
DbOper dboper = new DbOper();
public Form1()
{
InitializeComponent();
}
private void button5_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
textBox4.Text = folderBrowserDialog1.SelectedPath;
}
}
private void button3_Click(object sender, EventArgs e)
{
try
{
string filename = "" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "_all.bak";
dboper.DbBackup("sa", "", "(local)", "ALlwin_omt", filename, progressBar1);
string strPath = textBox4.Text + "\\" + filename;
if (radioButton2.Checked)
{
string strSQL = "BACKUP DATABASE " + textBox3.Text.Trim() + " TO DISK='" + strPath + "' WITH Format, Name='All_Data'";
cn.ExecuteSQL(strSQL);
}
else
{
string strSQL = "BACKUP DATABASE " + textBox3.Text.Trim() + " TO DISK='" + strPath + "' WITH DIFFERENTIAL, Name='DIF_Data'";
cn.ExecuteSQL(strSQL);
}
MessageBox.Show("Backup Success!!");
return;
}
catch
{
MessageBox.Show("Backup fail!");
return;
}
}
private void button6_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog1.FileName);
MessageBox.Show(sr.ReadToEnd());
sr.Close();
}
string strPath = openFileDialog1.FileName;
txtDataBak.Text = strPath;
}
private void Form1_Load(object sender, EventArgs e)
{
DbOper.CombServer(comboBox1);
}
private void button4_Click(object sender, EventArgs e)
{
if (txtDataBak.Text == "")
{
MessageBox.Show("Please Select a Backup file!");
return;
}
if (txtUID.Text == "")
{
MessageBox.Show("UserName Can't empty");
return;
}
try
{
dboper.DbRestore(txtUID.Text, txtPwd.Text, txtServer.Text, txtDataBase.Text, txtDataBak.Text, progressBar2);
//DbOper.DbRestore(txtUID.Text, txtPwd.Text, txtServer.Text, txtDataBase.Text, txtDataBak.Text);
MessageBox.Show("Resume Success!!");
return;
}
catch
{
MessageBox.Show("Resume Fail!!");
return;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -