(整理)数据库课程设计-仓库管理系统 - 图文 下载本文

精品文档

{

ofDialogFile.InitialDirectory = \;

ofDialogFile.Filter = \; ofDialogFile.RestoreDirectory = true; ofDialogFile.ShowDialog();

txtDRPath.Text = ofDialogFile.FileName.ToString().Trim(); }

private void btnDRevert_Click(object sender, EventArgs e) { try {

datacon.getcom(\ + txtDRPath.Text.Trim() + \);

MessageBox.Show(\数据还原成功!\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); }

catch (Exception ex) {

MessageBox.Show(ex.Message, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); } }

private void btnExit_Click(object sender, EventArgs e) {

this.Close(); }

private void frmDataRevert_FormClosed(object sender, FormClosedEventArgs e) {

this.Close(); } }

}

6.3数据备份恢复调用文件DataCon.cs

using System;

using System.Collections.Generic; using System.Text; using System.Data;

using System.Data.SqlClient;

namespace XRX.BaseClass

精品文档

精品文档

{

class DataCon {

#region 建立数据库连接 ///

/// 建立数据库连接. ///

/// 返回SqlConnection对象 public SqlConnection getcon() {

string M_str_sqlcon = \id=sa;PWD=\;

SqlConnection myCon = new SqlConnection(M_str_sqlcon); return myCon; }

#endregion

#region 执行SqlCommand命令 ///

/// 执行SqlCommand ///

/// public void getcom(string M_str_sqlstr) {

SqlConnection sqlcon = this.getcon(); sqlcon.Open();

SqlCommand sqlcom = new SqlCommand(M_str_sqlstr, sqlcon); sqlcom.ExecuteNonQuery(); sqlcom.Dispose(); sqlcon.Close(); sqlcon.Dispose(); }

#endregion

#region 创建DataSet对象 ///

/// 创建一个DataSet对象 ///

/// /// /// 返回DataSet对象

public DataSet getds(string M_str_sqlstr, string M_str_table) {

SqlConnection sqlcon = this.getcon();

精品文档