Vous êtes sur la page 1sur 9

*************coooneccterr*********

*******
public sqlconnecettion con=new sqlconnecttion("chaine");
public sqlcommande cmd;
public sqldatareader dr;
----
----------------ajouter
cmd=new sqlcomand("insert into client values "+ +" , "+ +" , " , con );
con.open();
cmd.exeoquer();
con.close();
---------------modifier
cmd=new sqlcommand("update client set nom='" + + "' , prenom=' "+ +" ' where nu
m=" + + "",con);
con.open();
cmd.execnonque();
con.close();
------------suupprimer
cmd=new sqlcommand("delete from client where num=" + + "",con);
con.open();
cmd.exenonque();
con.close();
------------rechercher
cmd=new sqlcommand("select num , nom , prenom from clientwhere num="++" ",con)
;
con.open();
dr=cmd.exereader();
if(dr.Read())
{
textbox.text=dr["nom"].tostring();
textbox.text=dr["prenom"].tostring();
}
dr.close();
con.close();
------------coombobox_load
cmd=new sqlcommande("slect num from client",con);
con.open();
dr=cmd.exereader();
while(dr.read())
{
combobox.items.add(dr[0]);
}
dr.close();
con.close();
----------------combobox_commited
cmd=new sqlcommand("slect nom , prenom from client where num="combobox1.text"",
con);
con.open();
dr=cmd.exereader();
while(dr.read())
{
textbox1.text=dr["nom"].tostring();
textbox2.text=dr["prenom"].tostring();
}
--------------------gridview_load
datagrudview.colums.add("num","num");
datagrudview.colums.add("nom","nom");
datagrudview.colums.add("prenom","prenom");
0
------------afficher f datagrid view
cmd=new sqlcomande("select * from client",con);
con.open();
dr=cmd.exereader();
while(dr.read())
{
datagridview.rows.add(dr["num"] ,dr["nom"],dr["prenom"]);
}
dr.close();
con.close();
----------- premier
cmd=new sqcomaand("select * from client" ,con) ;
con.open();
dr=cmd.exerread();
if(dr.read())
{
textbox1.text=dr[0].tostring();
textbox2.text=dr[1].tostring();
textbox3.text=dr[2].tostrung();
}
dr.close();
con.close();
------------dernier
cmd=new sqcomaand("select * from client" ,con) ;
con.open();
dr=cmd.exerread();
while(dr.read())
{
textbox1.text=dr[0].tostring();
textbox2.text=dr[1].tostring();
textbox3.text=dr[2].tostrung();
}
dr.close();
con.close();
------------------ precedent
cmd=new sqcomaand("select * from client where numm < "+textbo1.text+" order by n
um desc" ,con) ;
con.open();
dr=cmd.exerread();
if(dr.read())
{
textbox2.text=dr[1].tostring();
textbox3.text=dr[2].tostrung();
}
dr.close();
con.close();
-----------------------suivant
cmd=new sqcomaand("select * from client where numm > "+textbo1.text+" order by
num desc" ,con) ;
using systeme.data.sqlclient;
name spase;

//bouton connecter:

con.open();
dr=cmd.exerread();
while(dr.read())
{
textbox2.text=dr[1].tostring();
textbox3.text=dr[2].tostrung();
}
dr.close();
con.close();
--------------------------appeler_procceduere_sans_paramettre
cmd=new cmd("select * from client" , con)
cmd.commandtype=commadetype.storedprocedure;
con.open();
dr=cmd.exereder();
while(dr.read())
{
textbox.text=dr[0].tostring();
..
}
dr.close();
con.close();
--------------------------appeler_procceduere_avec_paramettre
cmd=new cmd("select * from client" , con)
cmd.commandtype=commadetype.storedprocedure;
con.open();
cmd.parametr.add("@a" , sqdbtype.varchar,20)
cmd.paramters["@a"].direction=parametrsdirection.input;
cmd.paramters["@a"].value=textbox.text;
dr=cmd.exereader();
whilel(dr.read)
{
datagridview.items.add(dr[0].tostring() , dr[1].tostrig())
}
dr.close();
con.close();
-------------------------------appeler_procceduere_avec_paramettre
cmd=new cmd("select * from client",con);
cmd.commandtype=commandtyoe.storedprocedure;
con.open();
cmd.paramerts.add("@a" , sqldbtype.int);
cmd.paramerts.add("@b" , sqldbtype.varchar , 20);
cmd.paramerts["@a"].direction=parametrsdirection.input;
cmd.parametrs["@b"].direction=parametrsdirection.output;
cmd.parametrs["@a"].value=textbox1.text;
cmd.exenoqur();
msgbox.show("le nom est "+cmd.paramerts["@b"].values.tostring());
con.close();
--------------pooo la cllas ajouterr ---------
public void ajouter (int a , strin b ....)
{
cmd=new cmd ("insert into . values ("a+" ,'"+b+"' ... " , con)
con.oen()
dr=cmd.er();
con.close();
}
--------------pooo la cllas supp---------
public void ajouter (int a , strin b ....)
{
cmd=new cmd ( "delete from ... . where "a+" " , con)
con.oen()
dr=cmd.er();
con.close();
}
-------- rechercher f la cllaasss retuurnn class --------
public cmater rechercher(int a )
{
string b , c .. ;
int a , d .. ;
cmater c =null ;
cmd=new cmd=("select * from .. where a ="+ a +"" , con );
con.open();
dr=cmd.ewr();
if(dr.read())
{
b=dr[1].tostring();
b=dr[2].tostring();
d= int.pars(dr[3].tostring());
c =new cmater(a , b , c , d ..)
}
dr.close();
con.close();

}
-------------pooo la cllas aficher return sqldatareader ------
public sqldatareader afficher ()
{
cmd=new cmd ( "select * from ... . ", con)
con.oen()
dr=cmd.er();
con.close();
return dr
}
--- buuton ajouter
cmater=new cmater();
c.ajouter(int.parc(textbox1.text) , textbox2.text .. )

--- buuton SUUPP


cmater=new cmater();
c.suupp(int.parc(textbox1.text)
--- buuton recher
cmater c =new cmater();
cmater rechercher = c.ajouter(textbox1.text);
if(rechercher!=null)
{
textebox1.text=recher.a.tostring();
textbox2.text= rechercher.b;
}
--- buuton afficher
cmater=new cmater();
dr =c.aaficher( )
con.open();
datatable dt=new datatabel();
dt.load(dr);
gridview.datasourse=dt;
con.close();
----------- connexionnnnnnn ---
bool b = false;
SqlCommand cmd = new SqlCommand("select * from compte",con);
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read()) {
if (textBox1.Text == dr[0].ToString() && textBox2.Text == dr[3].
ToString())
b = true;
}
if(b==false) MessageBox.Show("log ou pass incorrecte");
else if (b == true) {
Mj_archive m = new Mj_archive();
m.Show();
this.Hide();
}
dr.Close();
con.Close();
*********** deecooonecc
terr*************

public sqlconecction con =new sqlconnction("chaine");


sqldataadater da=new sqldatadapter();
dataset ds=new dataset();
------------------load
da=new sqldataadapter("select * from client",con);
da.fill(ds , "client");
comobobox.displaymemebre="Nom";
comobobox.valuemembre="Num";
-------------------combobox_load
for(int i =0 ; i < ds.table["client"].rows.count ; i++)
comobobox.items.add(ds.table["client"].rows[i][0]);
-------------------combobox_changed
for(int i=0 ; i < ds.table["client"].rows.count ; i++)
if (combobox.selectedindex.equal(ds.table["client"].rows[i][0]))
{
textbox1.text=ds.table["client"].rows[i][1].tostring();
textbox2.text=ds.table["client"].rows[i][2].tostring();
}
------------------ajouter
if(textbox1.text!="" ..... )
{
datarow ligne=ds.table["client"].newrow();
ligne[0]=textbox1.text;
ligne[1]=textbox2.text;
ds.table["client"].rows(ligne)
}
msgbox.show("bien ajouter");
---------------------modifier
if(textbox1.text!="" ....)
{
for(int i =0 ; i<ds.table["client"].rows.count ; i++)
{
datarow ligne=ds.table["client"].rows[i];
if(txtebox1.text == ligne[0].tostring())
{
ligne.beginedit();
ligne[1]=textbox1.text;
ligne[2]=textbox2.text;
ligne.endedite();
}
}
}
----------------supprimer
if(textbox1.text!="" ....)
{
for(int i =0 ; i<ds.table["client"].rows.count ; i++)
{
datarow ligne=ds.table["client"].rows[i];
if(txtebox1.text == ligne[0].tostring())
{
ligne.delete();
}
}
}
---------------enregistrer
if(msqbox.show("voulez vous enreg" , "attention" , msgboxbuuton.yesno)==dialgres
ult.yes)
{
sqlcommndbuilder cmdb=new sqlcommndbuilder (da);
da.update(ds ,"client");
}
msgbox.show("bien modifier");
----------------------nouveau
comobobox.selectindex = -1 ;
texebox.clear();
--------------------- premier
for(int i=0 ; i < ds.table["client"].rows.count ; i++)
if(i= 0)
{
textbox1.text = ds.tables["client"].row[i][0].tostring();
.....
}
pos =0;
---------------------dernier
for(int i=0 ; i < ds.table["client"].rows.count ; i++)
{
textbox1.text=ds.tables["client"].rows[i][0].tostring();
.........
}
pos=ds.tables["client"].rows.count -1 ;
---------------------------precedent
if ( pos > 0)
{
pos -- ;
}
for(int i=0 ; i < ds.table["client"].rows.count ; i++)
{
if(pos == i ){
textbox1.text=ds.tables["client"].rows[i][0].tostring();
.........}
}
----------------------------- suivant
if( pos < ds.tables["client"].rows.count - 1 )
{ pos ++ ; }
for(int i =0 ; i < ds.tables["client"].rows.count ; i++ )
{
if( pos == i)
{
textbox1.text = ds.tables["client"].rows[i][0].tostring();
textbox1.text = ds.tables["client"].rows[i][1].tostring();
}
}
---------------------------RowFilter
DataView dv = new DataView(ds.Tables["client"]);
dv.RowFilter = " Nom like 'z%'";
dataGridView1.DataSource = dv;
------------------------------afficher
dataGridView1.Rows.Clear();
foreach (DataRow drs in ds.Tables["client"].Rows)
if(drs.RowState!=DataRowState.Deleted)
{
dataGridView1.Rows.Add(drs[0],drs[1],drs[3],drs[3]);
}
------------------------------modifier ---datarow *
if(textbox1.text != "" ........... )
{
for(int i=0 ; i<ds.tables["client"].rows.count ; i++)
{
datarow[] dtr;
dtr=ds.tables["client"].select("num ="+textbox.text);
if(dtr.count()!=null)
{
dtr[0][1]=textbox1.text;
dtr[0][2]=textbox2.text;
}
}
}u
------------------------------suupprmier---datarow
if( textboxtext!= "" .... )
{
for(int i=0 ; i<ds.tables["client"].rows.count ; i++)
{
datarow[] dtr;
dtr=ds.tables["client"].select("num ="+textbox.text);
if(dtr.count()!=null)
{
dtr.delete();
}
}
}
---------------------------------crystal_repport
crystalrepor cr=new crystalrepor ();
crystareporview.reportsource=cr;
crystareporview.refrech();
--------------------------------crysta_report
dataset ds=new dataset();
da=new sqladatadapter("select * from client",con);
da.fill(ds.client);
crystalreport cr=new crystalreport();
cr.setdatasource(ds);
crystalreportview.reportsource=cr;
crystalreportview.refrech();