using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using WMPLib;
namespace saytan
{
    public partial class deed : Form
    {
        DataTable table;
        MySqlDataAdapter adapter;
        WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
        public deed()
        {
            InitializeComponent();
        }
        private void deed_Load(object sender, EventArgs e)
        {
            wplayer.URL = @"C:\Users\mangarmaagii\Documents\Visual Studio 2012\Projects\saytan\saytan\Resources\sounds\saytan.mp3";
            double time = wplayer.controls.currentPosition;
            wplayer.controls.play();
            loading();
            dataGridView1.Columns[0].HeaderText = "Саятан";
            dataGridView1.Columns[0].Width = 255;
            dataGridView1.Columns[1].HeaderText = "Хэдэн удаа";
            dataGridView1.Columns[1].Width = 255;
            label1.BackColor = System.Drawing.Color.Transparent;
            label3.BackColor = System.Drawing.Color.Transparent;
        }
        public void loading()
        {
            table = GetAllItems();
            dataGridView1.DataSource = table;
        }
        DataTable GetAllItems()
        {
            try
            {
                string query = "select * from saytan ";
                adapter = new MySqlDataAdapter(query, "Server=localhost; database=saytan; UID=root;CHARSET=utf8;");
                DataSet DS = new DataSet();
                DS.Clear();
                adapter.Fill(DS);
                return DS.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {
            this.Hide();
            this.Close();
            wplayer.controls.stop();
        }
    }
}
