private void RbnViewRequests_CheckedChanged(object sender, EventArgs e) { if (rbnViewRequests.Checked == true) { Form14 f14 = new Form14(); f14.Show(); rbnViewRequests.Checked = false; } }
public Form17(Form14 f) { f14 = f as Form14; InitializeComponent(); }
private void BtnSave_Click(object sender, EventArgs e) { if (cmbChangeReqStatus.SelectedItem == null) { MessageBox.Show("You have not selected the new Request status", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } else { try { if (cmbChangeReqStatus.SelectedItem.ToString().Trim().Equals("Deny Request")) { SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\Pbs\\source\\repos\\CorporateCoders\\CorporateCoders\\Database1.mdf;Integrated Security=True"); con.Open(); String sql = "update [dbo].[reqtable] set [Status] = @status where [Id] = @id and [Month]= @month and [Year] = @year and [DayOfMonth] = @date"; SqlCommand com = new SqlCommand(sql, con); com.Parameters.AddWithValue("@id", f14.id); com.Parameters.AddWithValue("@month", Microsoft.VisualBasic.DateAndTime.MonthName(DateTime.Now.Month)); com.Parameters.AddWithValue("@year", DateTime.Now.Year); com.Parameters.AddWithValue("@date", f14.date); com.Parameters.AddWithValue("@status", "Denied"); com.ExecuteNonQuery(); con.Close(); f14.Close(); Form14 form14 = new Form14(); form14.Show(); this.Close(); MessageBox.Show("SAVED SUCCESSFULLY", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } else if (cmbChangeReqStatus.SelectedItem.Equals("Approve Request")) { SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\Pbs\\source\\repos\\CorporateCoders\\CorporateCoders\\Database1.mdf;Integrated Security=True"); con.Open(); //Query to retrieve the requests Left String sql = "update [dbo].[reqTable] set [Status] = @status where [Id] = @id and [Month]= @month and [Year] = @year and [DayOfMonth] = @date"; SqlCommand com = new SqlCommand(sql, con); com.Parameters.AddWithValue("@id", f14.id); com.Parameters.AddWithValue("@month", Microsoft.VisualBasic.DateAndTime.MonthName(DateTime.Now.Month)); com.Parameters.AddWithValue("@year", DateTime.Now.Year); com.Parameters.AddWithValue("@date", f14.date); com.Parameters.AddWithValue("@status", "Approved"); com.ExecuteNonQuery(); con.Close(); SqlConnection con2 = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\Pbs\\source\\repos\\CorporateCoders\\CorporateCoders\\Database1.mdf;Integrated Security=True"); con2.Open(); //Query to retrieve the requests Left String sql2 = "update [dbo].[Attendance] set [Status] = @status where [Id] = @id and [Month]= @month and [Year] = @year and [DayOfMonth] = @date"; SqlCommand com2 = new SqlCommand(sql2, con2); com2.Parameters.AddWithValue("@id", f14.id); com2.Parameters.AddWithValue("@month", Microsoft.VisualBasic.DateAndTime.MonthName(DateTime.Now.Month)); com2.Parameters.AddWithValue("@year", DateTime.Now.Year); com2.Parameters.AddWithValue("@date", f14.date); com2.Parameters.AddWithValue("@status", "Full Day"); com2.ExecuteNonQuery(); con2.Close(); this.Close(); f14.Close(); Form14 form14 = new Form14(); form14.Show(); MessageBox.Show("SAVED SUCCESSFULLY", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } } catch (Exception ex) { MessageBox.Show(ex + "\nUNFORTUNATELY STOPPED!\nSORRY, AN UNEXPECTED ERROR OCCURED WHILE COLLECTING DATA.", "PLEASE TRY AGAIN", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); this.Close(); f14.Show(); } } }