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.Shapes;
using System.Data.SqlServerCe;

namespace WpfRibbonApplication1
{
    /// <summary>
    /// Interaction logic for New_contact.xaml
    /// </summary>
    public partial class New_contact : Window
    {
        public New_contact()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            using (SqlCeConnection con = new SqlCeConnection(@"Data Source=|DataDirectory|\dddd.sdf"))
            {
                string s = "INSERT INTO ddd VALUES('"+textBox1.Text+"','"+textBox2.Text+"','"+textBox3.Text+"','" +textBox4.Text+"')";
                SqlCeCommand cmds = new SqlCeCommand();
                cmds.Connection = con;
                cmds.CommandText = s;
   
                con.Open();
                int i = cmds.ExecuteNonQuery();

                MessageBox.Show(i+" Contact Inserted successfully","Success",MessageBoxButton.OK,MessageBoxImage.Information);

                Console.Write(cmds.ToString());

                con.Close();

            }

        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
          //  MainWindow mw = new MainWindow();
         //   mw.Show();
            
        }
    }
}
