private bool copyDatabase(string Dbname, string NewName) { // PackageName = Config.GetValue("Package").ToString(); try { //backup if (!System.IO.Directory.Exists(Application.StartupPath + "\\Backup\\")) { System.IO.Directory.CreateDirectory(Application.StartupPath + "\\Backup\\"); } string backupDataDb = "backup database " + Dbname + " to DISK = '" + Application.StartupPath + "\\Backup\\" + Dbname + DateTime.Now.ToString("dd_MM_yyyy") + ".dat' with init"; _db.UpdateByNonQueryNoTrans(backupDataDb); //backupDataDb = "backup database " + PackageName.Replace("CDT", "CBA") + " to DISK = '" + Application.StartupPath + "\\Backup\\" + PackageName.Replace("CDT", "CBA") + DateTime.Now.ToString("dd_MM_yyyy") + ".dat' with init"; //_dbStruct.UpdateByNonQueryNoTrans(backupDataDb); DataMaintain dmRtas = new DataMaintain(); bool re; re = dmRtas.RestoreDataToAnother(Application.StartupPath + "\\Data2005\\", Application.StartupPath + "\\Backup\\" + Dbname + DateTime.Now.ToString("dd_MM_yyyy") + ".dat", NewName); // re = re && dmRtas.RestoreDataToAnother(Application.StartupPath + "\\Data2005\\", Application.StartupPath + "\\Backup\\" + PackageName.Replace("CDT","CBA") + DateTime.Now.ToString("dd_MM_yyyy") + ".dat", newPackageName); //update Script return(true); } catch (Exception ex) { return(false); } }
void Main_Disposed(object sender, EventArgs e) { DataMaintain dmBk = new DataMaintain(); this.fno.notifyIcon1.Visible = false; //dmBk.BackupData(Application.StartupPath); }
private void simpleButtonOk_Click(object sender, EventArgs e) { if (this.dxErrorProviderMain.HasErrors) { XtraMessageBox.Show("Thông tin chưa hợp lệ, vui lòng kiểm tra lại!"); } else { this._ver = this.txtCDT.Text; string text = this.textEditServer.Text; string textRemote = this.txtRemoteServer.Text; DataMaintain maintain = new DataMaintain(text, textRemote, this.radioGroupCnnType.SelectedIndex, this.textEditUser.Text, this.textEditPassword.Text); maintain.isServer2005 = this.cEis2005.Checked; this.layoutControl1.Refresh(); bool flag = false; string H_KEY = Config.GetValue("H_KEY").ToString(); if (this.radioGroupType.SelectedIndex == 1) { flag = maintain.ClientExecute(this._ver); if (flag) { } if (flag && ckUpdateRemote.Checked) { maintain.UpdateRemoteServer(txtRemoteServer.Text, this._ver); } if (flag && CkUpdateLocal.Checked) { maintain.UpdateLocalServer(text, this._ver); } } else { flag = maintain.ServerExecute(Application.StartupPath, this._ver); } if (flag) { Registry.SetValue(H_KEY, "StructName", _ver); base.DialogResult = DialogResult.OK; } else { XtraMessageBox.Show("Có lỗi trong quá trình tạo số liệu, vui lòng kiểm tra lại!"); } } }
private void simpleButtonOk_Click(object sender, EventArgs e) { if (this.dxErrorProviderMain.HasErrors) { XtraMessageBox.Show("Thông tin chưa hợp lệ, vui lòng kiểm tra lại!"); } else { this._ver = this.txtCDT.Text; string text = this.textEditServer.Text; string textRemote = this.txtRemoteServer.Text; DataMaintain maintain = new DataMaintain(text, textRemote, this.radioGroupCnnType.SelectedIndex, this.textEditUser.Text, this.textEditPassword.Text); maintain.isServer2005 = this.cEis2005.Checked; this.layoutControl1.Refresh(); bool flag = false; if (this.radioGroupType.SelectedIndex == 1) { flag = maintain.ClientExecute(this._ver); string H_KEY = Config.GetValue("H_KEY").ToString(); if (flag) { } if (flag && ckUpdateRemote.Checked) { maintain.UpdateRemoteServer(txtRemoteServer.Text, this._ver); } if (flag && CkUpdateLocal.Checked) { maintain.UpdateLocalServer(text, this._ver); } } else { flag = maintain.ServerExecute(Application.StartupPath, this._ver); } if (flag) { //Đăng ký sử dụng nếu là dataonline if (text.Contains("45.")) { string _databaseName = _ver; CPUid cpu = new CPUid(Config.GetValue("ProductName").ToString()); ComputerConnection computer = new ComputerConnection(); computer.ComputerName = SystemInformation.ComputerName; computer.CPUID = cpu.MaMay; computer.DatabaseName = _databaseName; computer.LicenceKey = "";//cpu.GetKeyString(); computer.StructDB = Security.EnCode64(maintain.Connection); string ob = JsonConvert.SerializeObject(computer); CDTControl.Log log = new CDTControl.Log(); string re = log.RegistComputer(ob); if (re == null || re == "") { XtraMessageBox.Show("Có lỗi trong quá trình tạo số liệu, vui lòng kiểm tra lại!"); return; } } base.DialogResult = DialogResult.OK; } else { XtraMessageBox.Show("Có lỗi trong quá trình tạo số liệu, vui lòng kiểm tra lại!"); } } }
private void SystemMenuClick(object sender, ItemClickEventArgs e) { switch (e.Item.Name) { case "iRestart": Application.Restart(); break; case "iExit": if (XtraMessageBox.Show("Vui lòng xác nhận thoát khỏi ứng dụng?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes) { Application.Exit(); } break; case "iUserConfig": UserConfigAcc frmUserConfig = new UserConfigAcc(); if (frmUserConfig.IsShow) { frmUserConfig.ShowDialog(); } break; case "iCheckData": CheckData frmCheckData = new CheckData(true); frmCheckData.ShowDialog(); break; case "iViewHistory": CheckData frmViewHistory = new CheckData(false); frmViewHistory.ShowDialog(); break; case "iChangePassword": ChangePassword frmChangePwd = new ChangePassword(); frmChangePwd.ShowDialog(); break; case "iAbout": About frmAbout = new About(); frmAbout.ShowDialog(); break; case "iHelpOnline": System.Diagnostics.Process.Start("https://www.phanmemsgd.com"); break; case "iHelp": string fileHelp = Config.GetValue("Package").ToString() + ".chm"; if (System.IO.File.Exists(fileHelp)) { System.Diagnostics.Process.Start(fileHelp); } break; case "iBackup": DataMaintain dmBk = new DataMaintain(); bool isadmin = bool.Parse(Config.GetValue("Admin").ToString()); if (isadmin && dmBk.BackupData(Application.StartupPath)) { MessageBox.Show("Bakup Hoàn thành"); } else { } break; case "iDelete": Xoasolieu fxoasolieu = new Xoasolieu(); fxoasolieu.ShowDialog(); break; case "iRestore": string isAdmin = Config.GetValue("Admin").ToString(); if (isAdmin != "True") { return; } DataMaintain dmRt = new DataMaintain(); DateTime d; FrmDateSelect f = new FrmDateSelect(); f.ShowDialog(); d = f.d; if (d != null) { if (File.Exists(Application.StartupPath + "\\Backup\\" + dbName + d.ToString("dd_MM_yyyy") + ".dat")) { if (MessageBox.Show("Bạn có chắc chắn phục hồi số liệu ngày " + d.ToString("dd/MM/yyyy") + " không?, Dữ liệu hiện tại sẽ bị mất sau khi phục hồi!", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (dmRt.RestoreData(Application.StartupPath + "\\Backup\\" + dbName + d.ToString("dd_MM_yyyy") + ".dat")) { MessageBox.Show("Phục hồi số liệu hoàn thành!"); } else { MessageBox.Show("Phục hồi số liệu bị lỗi!"); } } } else { MessageBox.Show("Không tồn tại file backup ngày " + d.ToString("dd/MM/yyyy")); } } break; case "iRestoreAs": string isAdmin1 = Config.GetValue("Admin").ToString(); if (isAdmin1 != "True") { return; } DataMaintain dmRtas = new DataMaintain(); DateTime d1; string dataAnother; FrmRestoreAs fres = new FrmRestoreAs(); fres.ShowDialog(); d1 = fres.d; dataAnother = fres.DataAnother; if (d1 != null && dataAnother != null) { if (File.Exists(Application.StartupPath + "\\Backup\\" + dbName + d1.ToString("dd_MM_yyyy") + ".dat") && !File.Exists(Application.StartupPath + "\\Data2005\\" + dataAnother + ".mdf")) { if (MessageBox.Show("Bạn có chắc chắn phục hồi số liệu ngày " + d1.ToString("dd/MM/yyyy") + " vào dữ liệu " + dataAnother + " không?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (dmRtas.RestoreDataToAnother(Application.StartupPath + "\\Data2005\\", Application.StartupPath + "\\Backup\\" + dbName + d1.ToString("dd_MM_yyyy") + ".dat", dataAnother)) { MessageBox.Show("Tạo số liệu hoàn thành!"); } else { MessageBox.Show("Tạo số liệu bị lỗi!"); } } } else { MessageBox.Show("Không tồn tại file backup ngày " + d1.ToString("dd/MM/yyyy") + " hoặc đã tồn tại database " + dataAnother); } } break; case "iCollectData": FrmDataCollection frmDc = new FrmDataCollection(); frmDc.ShowDialog(); break; case "iImportExcel": if (!this.IsMdiContainer) { this.IsMdiContainer = true; mdiTabMain.MdiParent = this; } CDTSystem.fImExcel frmImportEx = new CDTSystem.fImExcel(); frmImportEx.MdiParent = this; frmImportEx.Disposed += Frm_Disposed; frmImportEx.Show(); break; case "iImportExcelMT": if (!this.IsMdiContainer) { this.IsMdiContainer = true; mdiTabMain.MdiParent = this; } CDTSystem.fImExcelMT frmImportExMT = new CDTSystem.fImExcelMT(); frmImportExMT.MdiParent = this; frmImportExMT.Disposed += Frm_Disposed; frmImportExMT.Show(); break; //case "fImExcelHongDongNai": // CusAccounting.fImExcelHongDongNaiOut fImExcelHongDongNai = new CusAccounting.fImExcelHongDongNaiOut(); // fImExcelHongDongNai.MdiParent = this; // fImExcelHongDongNai.Show(); // break; case "iCreateData": { fCopyPackage fcopyPackage = new fCopyPackage(); fcopyPackage.ShowDialog(); break; } case "iChonNLV": fChonNgayLV fChonNLV = new fChonNgayLV(); fChonNLV.ShowDialog(); break; case "isImportData": DateFilter dfilterIm = new DateFilter(); //dfilter.MdiParent = this; dfilterIm.ShowDialog(); if (dfilterIm.isAccept) { ImportDataFromDat I2Dat = new ImportDataFromDat(dfilterIm.TuNgay, dfilterIm.DenNgay); if (!I2Dat.Import()) { MessageBox.Show("Kết nhập dữ liệu không thành công"); } else { MessageBox.Show("Kết nhập dữ liệu thành công"); } } break; case "isExportData": DateFilter dfilterEx = new DateFilter(); //dfilter.MdiParent = this; dfilterEx.ShowDialog(); if (dfilterEx.isAccept) { ExportData2Dat E2Dat = new ExportData2Dat(dfilterEx.TuNgay, dfilterEx.DenNgay); if (!E2Dat.Export()) { MessageBox.Show("Xuất dữ liệu không thành công"); } else { MessageBox.Show("Xuất dữ liệu thành công"); } } break; case "iChotsolieu": fCatSolieu fcatsolieu = new fCatSolieu(); fcatsolieu.ShowDialog(); break; case "iAutoUpdate": string updatePath = Config.GetValue("UpdatePath").ToString(); this.DialogResult = DialogResult.Cancel; ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = false; startInfo.UseShellExecute = false; startInfo.FileName = "AutoUpdate.exe"; startInfo.WindowStyle = ProcessWindowStyle.Normal; startInfo.Arguments = " " + updatePath; try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close. using (Process exeProcess = Process.Start(startInfo)) { // exeProcess.WaitForExit(); } } catch { // Log error. } break; } }
private void SystemMenuClick(object sender, ItemClickEventArgs e) { switch (e.Item.Name) { case "iRestart": Application.Restart(); break; case "iExit": if (XtraMessageBox.Show("Vui lòng xác nhận thoát khỏi ứng dụng?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes) { Application.Exit(); } break; case "iUserConfig": UserConfigAcc frmUserConfig = new UserConfigAcc(); if (frmUserConfig.IsShow) { frmUserConfig.ShowDialog(); } break; case "iCheckData": CheckData frmCheckData = new CheckData(true); frmCheckData.ShowDialog(); break; case "iViewHistory": CheckData frmViewHistory = new CheckData(false); frmViewHistory.ShowDialog(); break; case "iChangePassword": ChangePassword frmChangePwd = new ChangePassword(); frmChangePwd.ShowDialog(); break; case "iAbout": About frmAbout = new About(); frmAbout.ShowDialog(); break; case "iHelpOnline": System.Diagnostics.Process.Start("http://www.sgd.com.vn"); break; case "iHelp": string fileHelp = Config.GetValue("Package").ToString() + ".chm"; if (System.IO.File.Exists(fileHelp)) { System.Diagnostics.Process.Start(fileHelp); } break; case "iBackup": DataMaintain dmBk = new DataMaintain(); if (dmBk.BackupData(Application.StartupPath)) { MessageBox.Show("Bakup Hoàn thành"); } else { } break; case "iDelete": Xoasolieu fxoasolieu = new Xoasolieu(); fxoasolieu.ShowDialog(); break; case "iRestore": string isAdmin = Config.GetValue("Admin").ToString(); if (isAdmin != "True") { return; } DataMaintain dmRt = new DataMaintain(); DateTime d; FrmDateSelect f = new FrmDateSelect(); f.ShowDialog(); d = f.d; if (d != null) { if (File.Exists(Application.StartupPath + "\\Backup\\" + dbName + d.ToString("dd_MM_yyyy") + ".dat")) { if (MessageBox.Show("Bạn có chắc chắn phục hồi số liệu ngày " + d.ToString("dd/MM/yyyy") + " không?, Dữ liệu hiện tại sẽ bị mất sau khi phục hồi!", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (dmRt.RestoreData(Application.StartupPath + "\\Backup\\" + dbName + d.ToString("dd_MM_yyyy") + ".dat")) { MessageBox.Show("Phục hồi số liệu hoàn thành!"); } else { MessageBox.Show("Phục hồi số liệu bị lỗi!"); } } } else { MessageBox.Show("Không tồn tại file backup ngày " + d.ToString("dd/MM/yyyy")); } } break; case "iRestoreAs": string isAdmin1 = Config.GetValue("Admin").ToString(); if (isAdmin1 != "True") { return; } DataMaintain dmRtas = new DataMaintain(); DateTime d1; string dataAnother; FrmRestoreAs fres = new FrmRestoreAs(); fres.ShowDialog(); d1 = fres.d; dataAnother = fres.DataAnother; if (d1 != null && dataAnother != null) { if (File.Exists(Application.StartupPath + "\\Backup\\" + dbName + d1.ToString("dd_MM_yyyy") + ".dat") && !File.Exists(Application.StartupPath + "\\Data2005\\" + dataAnother + ".mdf")) { if (MessageBox.Show("Bạn có chắc chắn phục hồi số liệu ngày " + d1.ToString("dd/MM/yyyy") + " vào dữ liệu " + dataAnother + " không?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (dmRtas.RestoreDataToAnother(Application.StartupPath + "\\Data2005\\", Application.StartupPath + "\\Backup\\" + dbName + d1.ToString("dd_MM_yyyy") + ".dat", dataAnother)) { MessageBox.Show("Tạo số liệu hoàn thành!"); } else { MessageBox.Show("Tạo số liệu bị lỗi!"); } } } else { MessageBox.Show("Không tồn tại file backup ngày " + d1.ToString("dd/MM/yyyy") + " hoặc đã tồn tại database " + dataAnother); } } break; case "iCollectData": FrmDataCollection frmDc = new FrmDataCollection(); frmDc.ShowDialog(); break; case "iImportExcel": CDTSystem.fImExcel frmImportEx = new CDTSystem.fImExcel(); frmImportEx.MdiParent = this; frmImportEx.Show(); break; case "iChonNLV": fChonNgayLV fChonNLV = new fChonNgayLV(); fChonNLV.ShowDialog(); break; case "isImportData": DateFilter dfilterIm = new DateFilter(); //dfilter.MdiParent = this; dfilterIm.ShowDialog(); if (dfilterIm.isAccept) { ImportDataFromDat I2Dat = new ImportDataFromDat(dfilterIm.TuNgay, dfilterIm.DenNgay); if (!I2Dat.Import()) { MessageBox.Show("Kết nhập dữ liệu không thành công"); } else { MessageBox.Show("Kết nhập dữ liệu thành công"); } } break; case "isExportData": DateFilter dfilterEx = new DateFilter(); //dfilter.MdiParent = this; dfilterEx.ShowDialog(); if (dfilterEx.isAccept) { ExportData2Dat E2Dat = new ExportData2Dat(dfilterEx.TuNgay, dfilterEx.DenNgay); if (!E2Dat.Export()) { MessageBox.Show("Xuất dữ liệu không thành công"); } else { MessageBox.Show("Xuất dữ liệu thành công"); } } break; } }
private void SystemMenuClick(object sender, ItemClickEventArgs e) { switch (e.Item.Name) { case "iRestart": Application.Restart(); break; case "iExit": if (XtraMessageBox.Show("Vui lòng xác nhận thoát khỏi ứng dụng?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes) { Application.Exit(); } break; case "iUserConfig": UserConfig frmUserConfig = new UserConfig(); if (frmUserConfig.IsShow) { frmUserConfig.ShowDialog(); } break; case "iCheckData": CheckData frmCheckData = new CheckData(true); frmCheckData.ShowDialog(); break; case "iViewHistory": CheckData frmViewHistory = new CheckData(false); frmViewHistory.ShowDialog(); break; case "iChangePassword": ChangePassword frmChangePwd = new ChangePassword(); frmChangePwd.ShowDialog(); break; case "iAbout": About frmAbout = new About(); frmAbout.ShowDialog(); break; case "iHelpOnline": System.Diagnostics.Process.Start("http://www.combosoft.com.vn/?.p=21"); break; case "iHelp": string fileHelp = Config.GetValue("Package").ToString() + ".chm"; if (System.IO.File.Exists(fileHelp)) { System.Diagnostics.Process.Start(fileHelp); } break; case "iBackup": DataMaintain dmBk = new DataMaintain(); dmBk.BackupData(Application.StartupPath); break; case "iRestore": DataMaintain dmRt = new DataMaintain(); dmRt.RestoreData(Application.StartupPath); break; case "iCollectData": FrmDataCollection frmDc = new FrmDataCollection(); frmDc.ShowDialog(); break; } }