private void cmdLogin_Click(object sender, EventArgs e) { Variables var = new Variables(); Variables.DBName = txtDatabase.Text; Variables.ServerName = txtServer.Text; Variables.UserName = txtUser.Text; Variables.Password = txtPassword.Text; try { using (SqlConnection sqlConn = new SqlConnection(var.ConString())) { sqlConn.Open(); if (sqlConn.State == ConnectionState.Open) { mdiPayrollMenu parent = new mdiPayrollMenu(); parent.Show(); this.Hide(); } else { MessageBox.Show("Cannot established connection."); } } } catch (SqlException ex) { MessageBox.Show(ex.Message.ToString()); } }
private void tsbSaveAndClose_Click(object sender, EventArgs e) { try { mdiPayrollMenu parent = new mdiPayrollMenu(); if (Convert.ToDouble(txtIDS.Text) == 0) { MachineInserts(); this.Close(); parent.MachineListGet(); } else { MachineUpdates(); this.Close(); parent.MachineListGet(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }