private void BackupManager_Load(object sender, EventArgs e)
{
txtFileName.Text = "DB_Backup_" + DateTime.Now.ToString("dd-MMM-yy");
}
private void btnDBBackup_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtFileName.Text.Trim()))
{
BackUp();
}
else
{
MessageBox.Show("Please Enter Backup File Name", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtFileName.Focus();
return;
}
}
private void BackUp()
{
try
{
progressBar1.Value = 0;
for (progressBar1.Value = 0; progressBar1.Value < 100; progressBar1.Value++)
{
}
pl.DbName = "Inventry";
pl.Path = @"D:/" + txtFileName.Text.Trim() + ".bak";
for (progressBar1.Value = 100; progressBar1.Value < 200; progressBar1.Value++)
{
}
bl.DbBackUp(pl);
for (progressBar1.Value = 200; progressBar1.Value < 300; progressBar1.Value++)
{
}
for (progressBar1.Value = 300; progressBar1.Value < 400; progressBar1.Value++)
{
}
for (progressBar1.Value = 400; progressBar1.Value < progressBar1.Maximum; progressBar1.Value++)
{
}
if (progressBar1.Value == progressBar1.Maximum)
{
MessageBox.Show("Backup Saved Successfully...!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Action Failed, Please try again later", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show("Action Failed, Please try again later", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
progressBar1.Value = 0;
}
}