public OfficeRentView()
        {
            InitializeComponent();
            OfficeRent data = new OfficeRent();

            officeRent.ItemsSource = data.GetData();
            DataContext            = data;
        }
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            RemoveDialogView handle = new RemoveDialogView();

            if (handle.ShowDialog() == true)
            {
                using (SqlConnection con = new SqlConnection(@Connection.ConnectionString))
                {
                    if (handle.FirstInput != handle.SecondInput)
                    {
                        MessageBox.Show("Entry No. did not match.Try again.\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        return;
                    }
                    Connection conn = new Connection();
                    conn.OpenConection();
                    int           isLogin = 0;
                    string        query   = "SELECT * From Stuff ";
                    SqlDataReader reader  = conn.DataReader(query);
                    while (reader.Read())
                    {
                        stuff_name = (string)reader["Stuff_Name"];
                        stuff_pass = (string)reader["Stuff_Password"];
                        if (stuff_name.Equals(Login.GlobalStuffName) && stuff_pass.Equals(handle.GetPassword))
                        {
                            isLogin = 1;
                            break;
                        }
                    }
                    if (isLogin != 1)
                    {
                        MessageBox.Show("Wrong Password.Try again.\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        return;
                    }

                    using (SqlCommand command = new SqlCommand("DELETE FROM Miscellaneous WHERE ME_Id = " + handle.FirstInput, con))
                    {
                        con.Open();
                        command.ExecuteNonQuery();
                        con.Close();
                    }

                    Id       = Convert.ToInt32(handle.FirstInput);
                    dateTime = DateTime.Today;
                    string   table = "Miscellanous Expenses";
                    string   type  = "Removed";
                    string   color = "Red";
                    EntryLog entry = new EntryLog();
                    entry.Add_Entry(table, type, Id, dateTime, color);

                    conn.CloseConnection();
                    OfficeRent data = new OfficeRent();
                    Miscellaneous.ItemsSource = data.GetData();
                    DataContext = data;
                }
            }
        }
        protected void Save_Click(object sender, RoutedEventArgs e)
        {
            if (CheckForError(Advance) || CheckForError(Rent))
            {
                MessageBox.Show("Error!Check Input Again");
                return;
            }
            if ((string)Save.Content == "Save")
            {
                using (SqlConnection conn = new SqlConnection(@Connection.ConnectionString))
                {
                    SqlCommand CmdSql = new SqlCommand("INSERT INTO [OfficeRent] (Office_Date, Office_Month, Office_Advance, Office_Rent) VALUES (@Date, @Month, @Advance, @Rent)", conn);
                    conn.Open();
                    CmdSql.Parameters.AddWithValue("@Date", Date.SelectedDate);
                    CmdSql.Parameters.AddWithValue("@Month", Month.Text);
                    CmdSql.Parameters.AddWithValue("@Advance", Advance.Text);
                    CmdSql.Parameters.AddWithValue("@Rent", Rent.Text);
                    CmdSql.ExecuteNonQuery();
                    conn.Close();

                    //Inserting value in Entry table
                    Connection conn2 = new Connection();

                    string query = "SELECT TOP 1 * FROM OfficeRent ORDER BY Office_Id DESC";
                    conn2.OpenConection();
                    SqlDataReader reader = conn2.DataReader(query);
                    while (reader.Read())
                    {
                        Id       = (int)reader["Office_Id"];
                        dateTime = (DateTime)reader["Office_Date"];
                    }
                    conn2.CloseConnection();



                    string   table = "Office Rent";
                    string   type  = "Inserted";
                    string   color = "Green";
                    EntryLog entry = new EntryLog();
                    entry.Add_Entry(table, type, Id, dateTime, color);
                    MessageBox.Show("Successfully Saved");
                }
            }

            else
            {
                using (SqlConnection conn = new SqlConnection(@Connection.ConnectionString))
                {
                    SqlCommand CmdSql = new SqlCommand("UPDATE [OfficeRent] SET Office_Date = @Date , Office_Month = @Month, Office_Advance = @Advance, Office_Rent = @Rent WHERE Office_Id=" + EntryNo.Text, conn);
                    conn.Open();
                    CmdSql.Parameters.AddWithValue("@Date", Date.SelectedDate);
                    CmdSql.Parameters.AddWithValue("@Month", Month.Text);
                    CmdSql.Parameters.AddWithValue("@Advance", Advance.Text);
                    CmdSql.Parameters.AddWithValue("@Rent", Rent.Text);
                    CmdSql.ExecuteNonQuery();
                    conn.Close();

                    //Inserting value in Entry table

                    Id       = Convert.ToInt32(EntryNo.Text);
                    dateTime = DateTime.Today;

                    string   table = "Office Rent";
                    string   type  = "Updated";
                    string   color = "Blue";
                    EntryLog entry = new EntryLog();
                    entry.Add_Entry(table, type, Id, dateTime, color);
                }
                Save.Content = "Save";
                MessageBox.Show("Successfully Updated");
            }

            OfficeRent data = new OfficeRent();

            officeRent.ItemsSource = data.GetData();
            DataContext            = data;
        }