public static void Restore(OpenFileDialog backup) { mainmdi main = new mainmdi(); string path = Application.StartupPath + "\\db\\"; string filename = System.IO.Path.GetFileNameWithoutExtension(backup.FileName); // dboperation.DbRestore(backup, filename); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } frmwait = new Form(); frmwait.Name = "frmwait"; frmwait.MdiParent = main.MdiParent; frmwait.Height = 100; frmwait.Width = 250; frmwait.MaximizeBox = false; frmwait.MinimizeBox = false; // frmwait.ControlBox = false; Label waitmsg = new Label(); waitmsg.Text = "Please Wait..."; waitmsg.Width = 250; waitmsg.Font = new System.Drawing.Font("Arial", 15); waitmsg.Left = 0; frmwait.Controls.Add(waitmsg); frmwait.Show(); Application.DoEvents(); dboperation.GetConn("master"); string strsql = "RESTORE FILELISTONLY " + " FROM DISK='" + backup.FileName + "'"; DataTable dt = dboperation.GetDataTable(strsql); string mdfpath = dt.Rows[0]["LogicalName"].ToString(); string ldfpath = dt.Rows[1]["LogicalName"].ToString(); strsql = "RESTORE DATABASE " + filename + " FROM DISK = '" + backup.FileName + "'" + " WITH MOVE '" + mdfpath + "' TO '" + path + "\\" + filename + ".mdf'," + " MOVE '" + ldfpath + "' TO '" + path + "\\" + filename + ".ldf'"; if (dboperation.ExecuteBackup(strsql)) { waitmsg.Text = "Restoration Completed"; frmwait.Update(); Thread.Sleep(500); frmwait.Close(); } else { waitmsg.Text = "Restoration Failed"; frmwait.Update(); Thread.Sleep(500); frmwait.Close(); } }
private void btnprint_Click(object sender, EventArgs e) { rptSalesInvoice frm = new rptSalesInvoice(); mainmdi main = new mainmdi(); frm.invoice = txtinvoice.Text; frm.MdiParent = this.MdiParent; frm.Show(); }
private void btnSave_Click(object sender, EventArgs e) { period.periodstart = txtPeriodFrom.Value; period.periodend = txtPeriodTo.Value; period.EditPeriod(); mainmdi main = new mainmdi(); main.SetCompanyInfo(); main.statusStrip1.Refresh(); main.Refresh(); this.Close(); }