الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

قواعد الب اٌنات

بدأه walio في 28 أبريل 2011 · 1 رد · 279 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع
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 WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        //================================================
        static string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
        "Data Source=Annuaire.mdb";
        OleDbConnection Conn = new OleDbConnection(ConStr);
        DataSet DataSet1 = new DataSet();
        string SQLstr = "Select * from Talifoune";
        OleDbDataAdapter DataAdapter1;
        //================================================
        private void ChangePosition()
        {
            int i1 = this.BindingContext[DataSet1, "talifoune"].Position + 1;
            int i2 = this.BindingContext[DataSet1, "Talifoune"].Count;
            label1.Text = "Record " + i1.ToString() + " From " + i2.ToString();
        }
        public void RefreshDataSet()
        {
            Conn.Open();
            DataSet1.Clear();
            DataAdapter1.Fill(DataSet1, "talifoune");
            Conn.Close();
        }
        public Form1()
        {
            InitializeComponent();
        }

        private void quitterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //******************************
Conn.Open();
DataAdapter1 = new OleDbDataAdapter(SQLstr, Conn);
DataAdapter1.Fill(DataSet1, "Talifoune");
Conn.Close();
//******************************
nom.DataBindings.Add("Text", DataSet1, "Talifoune.nom");
prenom.DataBindings.Add("Text", DataSet1, "Talifoune.prenom");
ville.DataBindings.Add("Text", DataSet1, "talifoune.ville");
num.DataBindings.Add("Text", DataSet1, "Talifoune.numero");
//******************************
ChangePosition();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.BindingContext[DataSet1, "Talifoune"].Position += 1;
            ChangePosition();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.BindingContext[DataSet1, "Talifoune"].Position -= 1;
            ChangePosition();
        }

        private void ouvrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            groupBox1.Visible = true;
            groupBox2.Visible = false;
        }

        private void ajouterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            groupBox1.Visible = false;
            groupBox2.Visible = true;
        }

        private void toolStripSplitButton2_ButtonClick(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            groupBox1.Visible = true;
            groupBox2.Visible = false;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string s = "'";
            OleDbCommand SaveInto = new OleDbCommand();
            SaveInto.Connection = Conn;
            SaveInto.CommandType = CommandType.Text;
            SaveInto.CommandText = "Insert Into Talifoune(enom,epre,eville,nume) " +
            " Values (" + s + enom.Text + s + "," + s +
            epre.Text + s + "," + s +
            eville.Text + s + nume.Text + s + ")";
            //*******************
            try
            {
                Conn.Open();
                SaveInto.ExecuteNonQuery();
                Conn.Close();
                MessageBox.Show("Terminé!!");
                Application.OpenForms[0].Show();
                (Application.OpenForms[0] as Form1).RefreshDataSet();
            }
            catch (Exception exp)
            {
                MessageBox.Show("Erreur d'insertion!!");
            }
        }

        private void supprimerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if( MessageBox.Show("Supprimer?",
"Supression", MessageBoxButtons.YesNo)
==DialogResult.Yes)
OleDbCommand DeleteCommand = new OleDbCommand();
DeleteCommand.Connection = Conn;
DeleteCommand.CommandType = CommandType.Text;
DeleteCommand.CommandText = "Delete from Talifoune where numero=" + numero.Text;
try
{
Conn.Open();
DeleteCommand.ExecuteNonQuery();
Conn.Close();
MessageBox.Show("Terminé!!");
ChangePosition();
RefreshDataSet();
}
catch(Exception exp)
{
}
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            this.BindingContext[DataSet1, "Talifoune"].Position += 1;
            ChangePosition();
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            this.BindingContext[DataSet1, "Talifoune"].Position -= 1;
            ChangePosition();
        }


    }
}
#2

السلام عليكم ورحمه الله وبركاته

اخي شو المطلوب؟؟

.:: Wish to become better and better ::.

مواضيع مشابهة