Sie sind auf Seite 1von 7

using using using using using using

System; System.Collections.Generic; System.Linq; System.Text; System.Threading; System.Data.OleDb;

namespace event_handler_saqib { class dabase { public static void recordinsertion() { OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.O LEDB.4.0; Data Source=C:\\Users\\Saqib Khan\\Desktop\\siramjidQuiz.mdb"); conn.Open(); OleDbCommand command = new OleDbCommand(); command.CommandText = "insert into student values(@ID,@name)"; command.Connection = conn; command.Parameters.Add("@ID", OleDbType.Numeric).Value = int.Parse(C onsole.ReadLine()); command.Parameters.Add("@name", OleDbType.VarChar).Value = Console.R eadLine(); command.ExecuteNonQuery(); conn.Close();

} }

public delegate void myevent(object send,EventArgs egs); class saqitimer { public event myevent timerevent; public void start() { if (timerevent == null) { Console.WriteLine("No event is ocured"); } else { for (int i = 0; i < 5; i++) { timerevent(this, null);

Thread.Sleep(1000); } } } } class Program { public static void ontick(object sendr, EventArgs evgrs) { Console.WriteLine("MY name is saqib khan"); } static void Main(string[] args) { Console.WriteLine("\tEnter student id and name to insert "); dabase.recordinsertion();

saqitimer st = new saqitimer(); st.timerevent+= new myevent(ontick); st.timerevent-=new myevent(ontick); st.start(); } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace AsifMAccessConnection { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { char[] sep = {' ' }; int count1=2; string recs = listBox1.Text; string[] item = recs.Split(sep, count1); textBox1.Text = item[0];

textBox2.Text = item[1]; } private void groupBox2_Enter(object sender, EventArgs e) { } private void btn_next_Click(object sender, EventArgs e) { int index = listBox1.SelectedIndex; int size=listBox1.Items.Count - 1; if (index < size) { ++index; listBox1.SetSelected(index, true); } else { listBox1.SetSelected(0, true); } string item = listBox1.Text; char[] sep = {' '}; int count1 = 2; string[] word = item.Split(sep,count1); textBox2.Text = word[0]; textBox1.Text = word[1]; } private void btn_prev_Click(object sender, EventArgs e) { string item = listBox1.Text; char[] sep = { ' ' }; int count1 = 2; string[] word = item.Split(sep, count1); textBox2.Text = word[0]; textBox1.Text = word[1]; ///////////////////////////////// int index1 = listBox1.SelectedIndex; int size1 = listBox1.Items.Count - 1; if (index1 >0) { ++index1; listBox1.SetSelected(index1, true); } else { listBox1.SetSelected(size1-1, true); } } private void Form1_Load(object sender, EventArgs e) { // btn_addRecord.BackColor= } private void btnemolu_addRecord_Click_1(object sender, EventArgs e)

{ //OleDbConnection con = new OleDbConnection("Provider=Microsoft.jet. OleDb.4.0;Data Source=C:\\Users\\zzz\\Desktop\\EmployeeDataBase.mdb"); //con.Open(); //OleDbCommand command = new OleDbCommand("insert into Employee valu es(@Emp_ID,@Emp_Name) ", con); //command.Parameters.Add("@Emp_ID", OleDbType.Numeric).Value = int.P arse(txt_id.Text); //command.Parameters.Add("@Emp_Name", OleDbType.VarChar).Value = txt _name.Text; //command.ExecuteNonQuery(); //con.Close(); //OleDbConnection con = new OleDbConnection("provider=microsoft.jet. oledb.4.0;data source=c://"); //con.Open(); //OleDbCommand com = new OleDbCommand("insert into c#(@ name)", con) ; //com.Parameters.Add(@ids, oleDbType.numer).Value = int.Parse(); //com.Parameters.Add(@ids,oleDbType.numeric).Value=int.Parse(textBox 1.text)); //com.ExecuteNonQuery(); //com.ExecuteNonQuery(); //OleDbConnection con = new OleDbConnection("provider=microsoft.jet. oldedb.4.0;data source=c://"); //con.Open(); //OleDbCommand commadd = new OleDbCommand("insert into table value(@ id)", con); //commadd.Parameters.Add(@ids, oleDbType.numeric).Value = int.Parse; //commadd.ExecuteNonQuery(); } int[] ids = new int[5]; string[] names = new string[5]; private void btn_showRecord_Click_1(object sender, EventArgs e) { OleDbConnection con = new OleDbConnection("Provider=Microsoft.jet.Ol eDb.4.0;Data Source=C:\\Users\\zzz\\Desktop\\EmployeeDataBase.mdb"); con.Open(); OleDbCommand command = new OleDbCommand("select * from Employee ", c on); OleDbDataReader recset = command.ExecuteReader(); OleDbConnection con=new OleDbConnection; listBox1.Items.Clear(); //int i = -1; while (recset.Read()) { //i++; listBox1.Items.Add(recset[0] + " " + recset[1]); //ids[i] = int.Parse(recset[0]); //names[i] = recset[1].ToString(); } con.Close(); ///////////////////////// listBox1.SetSelected(0, true); } private void button2_Click(object sender, EventArgs e)

{ //OleDbConnection con = new OleDbConnection("Provider=Microsoft.jet. OleDb.4.0;Data Source=C:\\Users\\zzz\\Desktop\\EmployeeDataBase.mdb"); //con.Open(); //OleDbCommand command = new OleDbCommand("delete * from Employee w here Emp_ID= "+int.Parse(textBox1.Text).ToString(), con); //command.ExecuteNonQuery(); //con.Close(); OleDbConnection con=new OleDbConnection("Provider=Microsoft.jet.oled b.4.0;Data Source=C:\\Users\\zzz\\Desktop\\EmployeeDataBase.mdb)"; con.Open(); OleDbCommand com=new OleDbCommand("delete * from Employee where Emp_ID ="+int.Parse(textBox1.Text).ToString(),con); } //oldebcommand comman=con.createcommand(); } } using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace delegate1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } delegate void MyDelegate(int a, int b); private void button1_Click(object sender, EventArgs e) { MyDelegate de = new MyDelegate(sum); //de = new MyDelegate(sum); de += new MyDelegate(sub); de += new MyDelegate(mul); de(4, 5); //de(int.Parse(textBox1.Text), int.Parse(textBox2.Text)); //MessageBox.Show(result.ToString()); } public void sum(int aa, int bb) { MessageBox.Show((aa + bb).ToString()); } public void sub(int aa, int bb) { MessageBox.Show( (aa - bb).ToString()); } public void mul(int aa, int bb) { MessageBox.Show( (aa * bb).ToString()); }

private void button2_Click(object sender, EventArgs e) { } } } /////////// expetion hundling using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using controlexeption; namespace userDefineException { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { //MessageBox.Show(Math.Sqrt(int.Parse(textBox1.Text)).ToString() ); int num = int.Parse(textBox1.Text); if (num < 0) throw new NegNum("negaaaaaaaaaaative number"); else MessageBox.Show(Math.Sqrt(num).ToString()); } catch (NegNum ngn) { MessageBox.Show(ngn.Message); } } } } /////////// try { MessageBox.Show(Math.Sqrt(int.Parse(textBox1.Text)).ToString()); } catch (OverflowException oe) { //throw new FormatException("format exception"); MessageBox.Show(oe.Message); } catch (FormatException fe) {

MessageBox.Show(fe.Message); } //////////////////////// string output = ""; Regex expression=new Regex(@"mmm"); string input=("aaaaa"+"dddddddd"+"cccccccccccc"+"mmm"); foreach(Match mymatch in expression.Matches(input)) output+=mymatch.ToString(); MessageBox.Show(output,"msssge",MessageBoxButtons.OK,MessageBoxIcon. Exclamation);

Das könnte Ihnen auch gefallen