public MiscellaneousView()
        {
            InitializeComponent();
            Miscellaneous data = new Miscellaneous();

            Miscellaneous.ItemsSource = data.GetData();
            DataContext = data;
        }
        protected void Save_Click(object sender, RoutedEventArgs e)
        {
            if (CheckForError(Details) || CheckForError(Expenses))
            {
                MessageBox.Show("Error!Check Input Again");
                return;
            }

            double previous = this.last_total();

            if ((string)Save.Content == "Save")
            {
                using (SqlConnection conn = new SqlConnection(@Connection.ConnectionString))
                {
                    SqlCommand CmdSql = new SqlCommand("INSERT INTO [Miscellaneous] (ME_Date, ME_Details, ME_Expenses, ME_Total) VALUES (@Date, @Details, @Expenses, @Total)", conn);
                    conn.Open();
                    CmdSql.Parameters.AddWithValue("@Date", Date.SelectedDate);
                    CmdSql.Parameters.AddWithValue("@Details", Details.Text);
                    CmdSql.Parameters.AddWithValue("@Expenses", Expenses.Text);
                    CmdSql.Parameters.AddWithValue("@Total", previous + Convert.ToDouble(Expenses.Text));
                    CmdSql.ExecuteNonQuery();
                    conn.Close();

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

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



                    string   table = "Miscellaneous Expenses";
                    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 [Miscellaneous] SET ME_Date = @Date , ME_Details = @Details, ME_Expenses = @Expenses, ME_Total = @Total WHERE ME_Id=" + EntryNo.Text, conn);
                    conn.Open();
                    CmdSql.Parameters.AddWithValue("@Date", Date.SelectedDate);
                    CmdSql.Parameters.AddWithValue("@Details", Details.Text);
                    CmdSql.Parameters.AddWithValue("@Expenses", Expenses.Text);
                    CmdSql.Parameters.AddWithValue("@Total", previous + Convert.ToDouble(Expenses.Text));
                    CmdSql.ExecuteNonQuery();
                    conn.Close();

                    //Inserting value in Entry table

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

                    string   table = "Miscellaneous Expenses";
                    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");
            }

            Miscellaneous data = new Miscellaneous();

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