protected override string SaveData() { var result = _accountPresenter.Save(); if (!String.IsNullOrEmpty(result)) { GlobalVariable.AccountIDAccountTransferForm = result; } return(result); }
/// <summary> /// Handles the Click event of the btnFinish control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void btnFinish_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; var restore = new Restore { Action = RestoreActionType.Database, Database = txtDatabaseName.Text.Trim(), ReplaceDatabase = true, ContinueAfterError = true }; if (!System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + DatabaseTemplatePath)) { XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDatabaseTempNotExist"), ResourceHelper.GetResourceValueByName("ResExceptionCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var backupDeviceItem = new BackupDeviceItem(AppDomain.CurrentDomain.BaseDirectory + DatabaseTemplatePath, DeviceType.File); restore.Devices.Add(backupDeviceItem); var fileList = restore.ReadFileList(_server); restore.RelocateFiles.Add(new RelocateFile(fileList.Rows[0][0].ToString().Trim(), btnDatabasePath.Text + @"\" + txtDatabaseName.Text.Trim() + ".mdf")); restore.RelocateFiles.Add(new RelocateFile(fileList.Rows[1][0].ToString().Trim(), btnDatabasePath.Text + @"\" + txtDatabaseName.Text.Trim() + "_log.ldf")); restore.SqlRestore(_server); var database = _server.Databases[txtDatabaseName.Text.Trim()]; if (database != null) { database.SetOnline(); } ////LinhMC change logicalName, ThangNK comment lại khi chuyển sang tư vấn nó ko lỗi //if (_server != null) //{ // var databaseName = txtDatabaseName.Text.Trim(); // string strCommand = "ALTER DATABASE " + databaseName + " MODIFY FILE (NAME = aBigTime, NEWNAME = " + // databaseName + "); ALTER DATABASE " + databaseName + // " MODIFY FILE (NAME = aBigTime_log, NEWNAME = " + databaseName + "_log);"; // _server.ConnectionContext.ExecuteNonQuery(strCommand); //} //update registry RegistryHelper.RemoveConnectionString(); RegistryHelper.SetValueForRegistry("DatabaseName", txtDatabaseName.Text); RegistryHelper.SetValueForRegistry("DatabasePath", btnDatabasePath.Text + @"\"); RegistryHelper.SaveConfigFile(); //update options var message = _dbOptionsPresenter.Save(); if (message != null) { XtraMessageBox.Show(message, ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //update currency _currencyPresenter.DisplayByCurrencyCode(cboCurrencyAccounting.EditValue == null ? null : cboCurrencyAccounting.EditValue.ToString()); if (CurrencyId != 0) { IsActive = true; _currencyPresenter.Save(); } _currencyPresenter.DisplayByCurrencyCode(cboCurrencyAccounting.EditValue == null ? null : cboCurrencyLocal.EditValue.ToString()); if (CurrencyId != 0) { IsActive = true; _currencyPresenter.Save(); } _currencyPresenter.DisplayByCurrencyCode(cboCurrencyAccounting.EditValue == null ? null : cboCurrencyCodeOfSalary.EditValue.ToString()); if (CurrencyId != 0) { IsActive = true; _currencyPresenter.Save(); } XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResCreateDBSucces"), ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Information); } //update account _accountPresenter.DisplayByAccountCode("11122"); CurrencyCode = cboCurrencyLocal.EditValue.ToString().Trim(); _accountPresenter.Save(); _accountPresenter.DisplayByAccountCode("11222"); CurrencyCode = cboCurrencyLocal.EditValue.ToString().Trim(); _accountPresenter.Save(); //update cac khoan luong LoadPayItem(); if (cboCurrencyCodeOfSalary.EditValue.Equals("USD")) { foreach (var payItem in _payItems) { _payItemPresenter.Display(payItem.PayItemId.ToString(CultureInfo.InvariantCulture)); CreditAccountCode = "11121"; _payItemPresenter.Save(); } } else { foreach (var payItem in _payItems) { _payItemPresenter.Display(payItem.PayItemId.ToString(CultureInfo.InvariantCulture)); CreditAccountCode = "11122"; _payItemPresenter.Save(); } } LoadAutoBusiness(); if (cboCurrencyLocal.EditValue != null && cboCurrencyAccounting.EditValue != null) { var lstAutoBusinessByNotUSD = _autoAutoBusiness.Where(w => w.CurrencyCode != null && w.CurrencyCode != string.Empty && w.CurrencyCode != cboCurrencyAccounting.EditValue.ToString()).ToList(); foreach (var autoBusiness in lstAutoBusinessByNotUSD) { _autoBusinessPresenter.Display(autoBusiness.AutoBusinessId.ToString(CultureInfo.InvariantCulture)); CurrencyCode = cboCurrencyLocal.EditValue.ToString(); _autoBusinessPresenter.Save(); } } Cursor = Cursors.Default; System.Windows.Forms.Application.Restart(); } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.ToString(), ResourceHelper.GetResourceValueByName("ResExceptionCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected override int SaveData() { return(_accountPresenter.Save()); }