private void FormHardware_Load(object sender, EventArgs e) { try { #if UseSQLServer VEHeaderAdapter.Fill(m_VEHeader); labelDataBase.Text = "資料庫為MsSQL"; #else VEHeaderAdapter.Connection = MapPath.VEConnection; VEHeaderAdapter.Fill(m_VEHeader); labelDataBase.Text = "資料庫為Access"; #endif } catch (Exception ex) { MessageBox.Show("程式錯誤!:" + ex.Message); } // Config.Load(); textBoxProfileName.Text = Config.ProfileName; //textBoxPrinter.Text = Config.PrinterName; textBoxDotPrinter.Text = Config.DotPrinterName; ckBoxIsServer.Checked = Config.IsServer; //cbBoxRS232.Text = Config.ComPortName; //textBoxDataDir.Text = Config.DataDir; //textBoxUserName.Text = Config.UserName; //textBoxPassword.Text = Config.Password; //textBoxBackupDir.Text = Config.BackupDir; textBoxSqlServerIP.Text = Config.Local.ServerIP; textBoxSqlUserID.Text = Config.Local.UserID; textBoxSqlPassword.Text = Config.Local.Password; chBoxCloudSync.Checked = Config.EnableCloudSync; textBoxSqlDatabase.Text = Config.Database; textBoxSharedDatabase.Text = Config.SharedDatabase; textBoxSqlServerIPCloud.Text = Config.Cloud.ServerIP; textBoxSqlUserIDCloud.Text = Config.Cloud.UserID; textBoxSqlPasswordCloud.Text = Config.Cloud.Password; labelProgramVersion.Text = "程式版本 " + Application.ProductVersion.ToString(); labelRequiredVersion.Text = "要求版本 " + GetVersion(); }
private void 鎖定資料庫ToolStripMenuItem_Click(object sender, EventArgs e) { VoucherExpense.DamaiDataSet DataSet = new DamaiDataSet(); var headerAdapter = new VoucherExpense.DamaiDataSetTableAdapters.VEHeaderTableAdapter(); headerAdapter.Fill(DataSet.VEHeader); if (DataSet.VEHeader.Count == 0) { var row = DataSet.VEHeader.NewVEHeaderRow(); row.Closed = !MyFunction.LockAll; int y = DateTime.Now.Year; row.DataYear = new DateTime(y, 1, 1); DataSet.VEHeader.AddVEHeaderRow(row); } var header = DataSet.VEHeader[0]; header.BeginEdit(); header.Closed = !MyFunction.LockAll; header.EndEdit(); try { headerAdapter.Update(header); } catch (Exception ex) { MessageBox.Show("變更鎖定狀態未成功:" + ex.Message); return; } MyFunction.LockAll = !MyFunction.LockAll; SetFormTitle(); ToolStripMenuItem i = (ToolStripMenuItem)menu1.Items["查核MenuItem"]; if (MyFunction.LockAll) { i.DropDownItems["鎖定資料庫MenuItem"].Text = "解鎖資料庫"; } else { i.DropDownItems["鎖定資料庫MenuItem"].Text = "鎖定資料庫"; } }