Thursday, 5 January 2012

wpf

xml:










code:
using System;
using System.Collections.Generic;
using System.Collections;
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;


namespace WpfApplication2
{
///
/// Interaction logic for MainWindow.xaml
///

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
#region
ArrayList al = new ArrayList();
Database1Entities o = new Database1Entities();
int i,j;
string s,ss;
#endregion
private void Window_Loaded(object sender, RoutedEventArgs e)
{
view();
al.Add("--------Select--------");
al.Add("What is ur name?");
al.Add("What is ur vabority movie?");
al.Add("What is ur vabority game?");
al.Add("What is ur vabority place?");
for (i = 0; i < al.Count; i++)
comboBox1.Items.Add(al[i].ToString());
comboBox1.SelectedIndex = 0;

listBox1.Items.Add("Cricket");
listBox1.Items.Add("Hockey");
listBox1.Items.Add("Football");
listBox1.Items.Add("Baseball");
}
void view()
{
var m = from x in o.EMP1 select new {x.EID,x.NAME,x.ADDRESS,x.SEX,x.DOB,x.HOBBY,x.INTEREST,x.QUESTION,x.PASSWORD};
dataGrid1.ItemsSource = m;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
s=string.Empty;
ss=string.Empty;
if (radioButton1.IsChecked==true)
s = radioButton1.Content.ToString();
else
s = radioButton2.Content.ToString();
if (checkBox1.IsChecked==true)
ss =ss+ checkBox1.Content.ToString()+" ";
if(checkBox2.IsChecked==true)
ss = ss + checkBox2.Content.ToString() + " ";
if (checkBox3.IsChecked == true)
ss = ss + checkBox3.Content.ToString() + " ";
if (checkBox4.IsChecked == true)
ss = ss + checkBox4.Content.ToString() + " ";
o.EMP2(textBox1.Text, textBox2.Text, s, Convert.ToDateTime(datePicker1.SelectedDate), ss, listBox1.SelectedItem.ToString(), comboBox1.SelectedItem.ToString(), passwordBox1.Password.ToString());
o.SaveChanges();
view();
}
}
}

No comments:

Post a Comment