public ShareView()
        {
            InitializeComponent();
            Share data = new Share();

            share.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 Share WHERE Share_Id = " + handle.FirstInput, con))
                    {
                        con.Open();
                        command.ExecuteNonQuery();
                        con.Close();
                    }

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

                    conn.CloseConnection();
                    Share data = new Share();
                    share.ItemsSource = data.GetData();
                    DataContext       = data;
                }
            }
        }
        protected void Save_Click(object sender, RoutedEventArgs e)
        {
            if (CheckForError(Collection) || CheckForError(Profit) || CheckForError(Withdraw))
            {
                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 [Share] (Share_Date, Share_Collection, Share_Profit, Share_Withdraw, Share_Remains) VALUES (@Date, @Collection, @Profit, @Withdraw, @Remains)", conn);
                    conn.Open();
                    CmdSql.Parameters.AddWithValue("@Date", Date.SelectedDate);
                    CmdSql.Parameters.AddWithValue("@Collection", Collection.Text);
                    CmdSql.Parameters.AddWithValue("@Profit", Profit.Text);
                    CmdSql.Parameters.AddWithValue("@Withdraw", Withdraw.Text);
                    CmdSql.Parameters.AddWithValue("@Remains", Convert.ToDouble(Collection.Text) + Convert.ToDouble(Profit.Text) - Convert.ToDouble(Withdraw.Text));
                    CmdSql.ExecuteNonQuery();
                    conn.Close();

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

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



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

            else
            {
                using (SqlConnection conn = new SqlConnection(@Connection.ConnectionString))
                {
                    SqlCommand CmdSql = new SqlCommand("UPDATE [Share] SET Share_Date = @Date , Share_Collection = @Collection, Share_Profit = @Profit, Share_Withdraw = @Withdraw, Share_Remains = @Remains WHERE Share_Id=" + EntryNo.Text, conn);
                    conn.Open();
                    CmdSql.Parameters.AddWithValue("@Date", Date.SelectedDate);
                    CmdSql.Parameters.AddWithValue("@Collection", Collection.Text);
                    CmdSql.Parameters.AddWithValue("@Profit", Profit.Text);
                    CmdSql.Parameters.AddWithValue("@Withdraw", Withdraw.Text);
                    CmdSql.Parameters.AddWithValue("@Remains", Convert.ToDouble(Collection.Text) + Convert.ToDouble(Profit.Text) - Convert.ToDouble(Withdraw.Text));
                    CmdSql.ExecuteNonQuery();
                    conn.Close();

                    //Inserting value in Entry table

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

                    string   table = "Security Fund";
                    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");
            }

            Share data = new Share();

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