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 System.Data.OleDb;
using System.IO;

namespace shop
{
    public partial class backup : Form
    {
        public backup()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string CurrentDatabasePath = Environment.CurrentDirectory + @"\shoping.mdb";

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                string PathtobackUp = fbd.SelectedPath.ToString();
                File.Copy(CurrentDatabasePath, PathtobackUp + @"\ShopAgrin.bk", true);
                progressBar1.PerformStep();
                MessageBox.Show("پشتیبان گیری با موفقیت انجام شد", "ایجاد پشتیبان");
                progressBar1.Value = 0;
                Close();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string PathToRestoreDB = Environment.CurrentDirectory + @"\shoping.mdb";

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Text file (*.bk)|*.bk";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string Filetorestore = ofd.FileName;
                File.Copy(Filetorestore, PathToRestoreDB, true);
                progressBar1.PerformStep();
                MessageBox.Show("پشتیبان با موفقیت بازگردانی شد", "بازگرداندن پشتیبان");
                progressBar1.PerformStep();
                progressBar1.Value = 0;
            }
        }

        private void progressBar1_Click(object sender, EventArgs e)
        {

        }

        private void backup_Load(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }
    }
}
