using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Windows.Controls.Ribbon;
using System.Data.SqlServerCe;
using System.Data;
namespace WpfRibbonApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RibbonWindow
    {
        public MainWindow()
        {
            InitializeComponent();
           

            // Insert code required on object creation below this point.
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            New_contact nc = new New_contact();
            nc.Show();
        }

        private void Button1_Click_1(object sender, RoutedEventArgs e)
        {
            grid1.Visibility = Visibility.Visible;
            grid2.Visibility = Visibility.Hidden;



        }

        private void Button2_Click(object sender, RoutedEventArgs e)
        {
            grid1.Visibility = Visibility.Hidden;
            grid2.Visibility = Visibility.Visible;
            SqlCeConnection con = new SqlCeConnection(@"Data Source=|DataDirectory|\dddd.sdf");
            SqlCeDataAdapter da = new SqlCeDataAdapter("Select * from mail",con);
            DataSet ds = new DataSet();
            da.Fill(ds,"sent");
            dataGrid1.DataContext = ds;
        }

        private void Button4_Click(object sender, RoutedEventArgs e)
        {
            allcontacts all = new allcontacts();
            all.Show();

        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            Class1 ce = new Class1();
            if (textBox1.Text != "" && textBox2.Text != "")
            {
                ce.set(textBox1.Text, textBox2.Text);
                MessageBox.Show(textBox1.Text + " You are successfully sign in");
                grid1.Visibility=Visibility.Hidden;
                textBox1.Text = "";
                textBox2.Text = "";

            }
            else
            {
                MessageBox.Show( "Fill user name and password fields","Error",MessageBoxButton.OK,MessageBoxImage.Error);
                textBox1.Text = "";
                textBox2.Text = "";
            }
            
        }

        private void Button2_Click_1(object sender, RoutedEventArgs e)
        {
            create c = new create();
            c.Show();
        }

        private void MenuItem3_Click(object sender, RoutedEventArgs e)
        {
            this.Close();

        }

        private void Butt_Click(object sender, RoutedEventArgs e)
        {
            Class1 cls = new Class1();
            String un=cls.getun();
            String pw=cls.getpwd();

            if (un != "" && pw != "")
            {

                cls.clear();

                MessageBox.Show("Successfully Sign out", "Sucess");
            }
            else
            {
                MessageBox.Show("You must sign in before sign out!", "Warning");
            }
        }
        
    }
}
