Example #1
0
        private void btnBackup_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtPath.Text.Trim() != "")
                {
                    string strPath     = txtPath.Text + @"\ERPManage";
                    string strFileName = DateTime.Now.ToString("yyyy-MM-dd");

                    SystemManage SystemManage = new SystemManage();
                    SystemManage.sp_BackupDatabase(strPath, strFileName);

                    //写日志
                    SysLog.AddOperateLog(SysParams.UserName, "系统数据库备份", "备份", SysParams.UserName + "用户备份了系统数据库,备份路径:" + strPath + strFileName + ".bak");


                    this.ShowMessage("数据库备份成功,已备份到" + strPath + strFileName + ".bak");
                }
                else
                {
                    this.ShowMessage("请选择备份路径!");
                }
            }catch (Exception err)
            {
                this.ShowErrorMessage("数据库备份出现错误,请检查备份路径是否正确!");
            }
        }