private void FFondation_Load(object sender, EventArgs e) { String sqlmp = "Select * From modalite where codes='" + Program.Societe + "'"; DataSet dsm = met.recuperer_table(sqlmp, "modalite"); BindingSource bs = new BindingSource(dsm, "modalite"); Modep.DisplayMember = "libelle"; Modep.ValueMember = "Code"; Modep.DataSource = bs; rbnht.Checked = true; rbht.Checked = false; { increment(); nfact.Text = NumFact; Tcodc.Text = cli.Codec + ""; Tnomc.Text = cli.NomC + ""; Tadrc.Text = cli.adrc + ""; datefact.Value = DateTime.Now; try { int i = 0; foreach (string str in LSTid) { string sqldd = "SELECT * FROM lcontrat where ID = " + str; DataSet dsdd = met.recuperer_table(sqldd); if (dsdd != null) { if (dsdd.Tables.Count != 0) { if (dsdd.Tables[0].Rows.Count != 0) { mygrid1.Rows.Add(); var dr = dsdd.Tables[0].Rows[0]; mygrid1.Rows[i].Cells["Npylon"].Value = dr["NPYLON"]; mygrid1.Rows[i].Cells["TypePylone"].Value = dr["TYPEPYLON"]; mygrid1.Rows[i].Cells["TypeMassif"].Value = dr["TYPEMASSIF"]; mygrid1.Rows[i].Cells["VBP"].Value = dr["VBETON"]; mygrid1.Rows[i].Cells["VB350"].Value = 0; mygrid1.Rows[i].Cells["VTOTAL"].Value = dr["VBETON"]; mygrid1.Rows[i].Cells["U"].Value = "m3"; mygrid1.Rows[i].Cells["PUHTF"].Value = dr["PUBETON"]; //mygrid1.Rows[i].Cells["PTHT"].Value = dr["PTHT"]; mygrid1.Rows[i].Cells["TVAFF"].Value = 18; mygrid1.Rows[i].Cells["ID"].Value = dr["ID"]; i++; } } } } } catch { } mygrid1.Focus(); } }
private void Tcod_TextChanged(object sender, EventArgs e) { string req = "SELECT code,libelle FROM " + table + " where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and code like '%" + Tcod.Text + "%' and libelle like '%" + Tlib.Text + "%' order by code"; ds = met.recuperer_table(req, table); if (ds != null) { dataGridViewX1.DataSource = ds.Tables[table].DefaultView; } }
private void charger_lignefacture() { if (first) { dataGridViewX1.Rows[dataGridViewX1.Rows.Count - 1].Selected = true; } if (dataGridViewX1.SelectedRows.Count != 0) { // Chargement ligne commande string req1 = "select distinct l.num,l.codea, a.libelle , g.libelle as gamme , d.libelle as depot , l.qte , l.pu , l.tva ,l.taxe, l.tvaf , l.rem , l.netht , l.netttc,l.codesa,l.ID from lentcc l , article a , gamme g , depot d where l.codes='" + Program.Societe + "' and l.codee='" + Program.Exercice + "' and l.num= '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "' and l.codem='" + Program.Magasin + "' and l.codea = a.code and l.codes= a.codes and l.codee= a.codee and l.codea = g.codea and l.codeg=g.codeg and l.codes=g.codes and l.codee=g.codee and l.coded= d.code and l.codes=d.codes and l.codee=d.codee and l.codem=d.codem "; DataSet ds1 = met.recuperer_table(req1, "lentcc"); foreach (DataRow dr in ds1.Tables["lentcc"].Rows) { if (dr["codesa"] != DBNull.Value) { string sql = "select libelle from sarticle where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codea= '" + dr["codea"] + "' and code = '" + dr["codesa"] + "'"; DataSet dtmp = met.recuperer_table(sql, "sarticle"); dr["libelle"] = dtmp.Tables[0].Rows[0][0]; dr["codea"] = DBNull.Value; dr["gamme"] = DBNull.Value; dr["depot"] = DBNull.Value; } } dataGridViewX2.DataSource = ds1.Tables["lentcc"].DefaultView; } }
private void impetatfact_Load(object sender, EventArgs e) { string sql = "select * from client where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'"; ds = met.recuperer_table(sql, "client"); dated.Value = DateTime.Now; datef.Value = DateTime.Now; }
private void FFondation_Load(object sender, EventArgs e) { String sqlmp = "Select * From modalite where codes='" + Program.Societe + "'"; DataSet dsm = met.recuperer_table(sqlmp, "modalite"); BindingSource bs = new BindingSource(dsm, "modalite"); Modep.DisplayMember = "libelle"; Modep.ValueMember = "Code"; Modep.DataSource = bs; rbnht.Checked = true; rbht.Checked = false; if (newf) { increment(); nfact.Text = NumFact; } }
private void factclibl_Load(object sender, EventArgs e) { String req = "SELECT * FROM pnumste where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' "; ds = met.recuperer_table(req, "pnumste"); if (ds != null) { if (ds.Tables.Count != 0) { if (ds.Tables[0].Rows.Count != 0) { index = ds.Tables[0].Rows.Count - 1; } } } increment(); metparam.Init(); datefact.Value = DateTime.Now; loadF(); cmbtypevente.SelectedIndex = 0; }
private void harticle_Load(object sender, EventArgs e) { String sql = "select datem, prixht from articlehist where codes = '" + Program.Societe + "' and codee ='" + Program.Exercice + "' and codea = '" + codea + "'"; DataSet ds = met.recuperer_table(sql); try { dataGridView1.DataSource = ds.Tables[0].DefaultView; } catch { } }
public void load_contrat() { grd_contrat.Rows.Clear(); String sql = "SELECT * FROM Contrat Where CODEC = '" + cli.Codec + "' and fermer = false"; DataSet dsc = met.recuperer_table(sql); if (dsc.Tables.Count != 0) { int i = 0; foreach (DataRow dr in dsc.Tables[0].Rows) { grd_contrat.Rows.Add(); grd_contrat.Rows[i].Cells["CODE"].Value = dr["CODE"]; grd_contrat.Rows[i].Cells["IDC"].Value = dr["ID"]; grd_contrat.Rows[i].Cells["Fgarantie"].Value = dr["Fgarantie"]; grd_contrat.Rows[i].Cells["Favance"].Value = dr["Favance"]; grd_contrat.Rows[i].Cells["NUMFgarantie"].Value = dr["NUMFgarantie"]; grd_contrat.Rows[i].Cells["NUMFAvance"].Value = dr["NUMFAvance"]; grd_contrat.Rows[i].ReadOnly = true; i++; } } }
private void buttonX2_Click(object sender, EventArgs e) { if (cli != null) { if (!modif) { Double xtht = 0, xtva = 0, xttc = 0, xav = 0, xgar = 0; Double.TryParse(Tht.Text, out xtht); Double.TryParse(Ttva.Text, out xtva); Double.TryParse(Tttc.Text, out xttc); Double.TryParse(Tavnc.Text, out xav); Double.TryParse(Tgar.Text, out xgar); String dat = datefact.Value.ToString("yyyy-MM-dd"); string sql = "INSERT INTO contrat (CODE,CODEC, NOMC,ADRC,DATEDEBUT, THT, TVA,TTC,VGAR,VAVANC, CODES) VALUE ("//, AVANCE,solde,reste + "'" + nfact.Text + "'," + "'" + Tcodc.Text + "'," + "'" + Tnomc.Text + "'," + "'" + Tadrc.Text + "'," + "'" + dat + "'," + "'" + xtht.ToString().Replace(Program.sep, string.Empty) + "'," + "'" + xtva.ToString().Replace(Program.sep, string.Empty) + "'," + "'" + xttc.ToString().Replace(Program.sep, string.Empty) + "'," + "'" + xgar.ToString().Replace(Program.sep, string.Empty) + "'," + "'" + xav.ToString().Replace(Program.sep, string.Empty) + "'," + "'" + Program.Societe + "'" + ")"; String sqlID = "Select Max(ID) FROM contrat"; met.Execute(sql); DataSet dsID = met.recuperer_table(sqlID); String ID = string.Empty; try { ID = dsID.Tables[0].Rows[0].ItemArray[0] + ""; } catch { } //Pylones String sqlF = "INSERT INTO lcontrat (NPYLON,TYPEPYLON,TYPEMASSIF,ORDRE,PORTEE,PORTEEMOY,PUFOND,PUMONTAGE,PUDEROULAGE,POIDS,PUPoids,VBETON,PUBETON,CODES,IDCONTRAT) values"; Boolean frst = true; foreach (DataGridViewRow dr in mygrid1.Rows) { if (!dr.IsNewRow) { if (!frst) { sqlF += ",("; } else { sqlF += "("; } String xport = "Null", xportmoy = "Null", xpuf = "Null", xpum = "Null", xpud = "Null", xpoid = "Null", xpup = "Null", xvbp = "Null", xpuv = "Null"; if (dr.Cells["portee"].Value != null) { if (!(dr.Cells["portee"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["portee"].Value + "", out d1); xport = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["porteemoy"].Value != null) { if (!(dr.Cells["porteemoy"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["porteemoy"].Value + "", out d1); xportmoy = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUHTFondation"].Value != null) { if (!(dr.Cells["PUHTFondation"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUHTFondation"].Value + "", out d1); xpuf = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUHTMontage"].Value != null) { if (!(dr.Cells["PUHTMontage"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUHTMontage"].Value + "", out d1); xpum = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUHTDeroulage"].Value != null) { if (!(dr.Cells["PUHTDeroulage"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUHTDeroulage"].Value + "", out d1); xpud = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["Poids"].Value != null) { if (!(dr.Cells["Poids"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["Poids"].Value + "", out d1); xpoid = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUP"].Value != null) { if (!(dr.Cells["PUP"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUP"].Value + "", out d1); xpup = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["VBP"].Value != null) { if (!(dr.Cells["VBP"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["VBP"].Value + "", out d1); xvbp = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUV"].Value != null) { if (!(dr.Cells["PUV"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUV"].Value + "", out d1); xpuv = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } sqlF += "'" + dr.Cells["Npylon"].Value + "'" + ",'" + dr.Cells["TypePylone"].Value + "'" + ",'" + dr.Cells["TypeMassif"].Value + "'" + ",'" + (dr.Index + 1) + "'" + "," + xport + "" + "," + xportmoy + "" + "," + xpuf + "" + "," + xpum + "" + "," + xpud + "" + "," + xpoid + "" + "," + xpup + "" + "," + xvbp + "" + "," + xpuv + "" + ",'" + Program.Societe + "'" + "," + ID + ")"; frst = false; } } if (!frst) { met.Execute(sqlF); } MessageBox.Show("Enregistrement avec sucée."); } else { Double xtht = 0, xtva = 0, xttc = 0, xav = 0, xgar = 0; Double.TryParse(Tht.Text, out xtht); Double.TryParse(Ttva.Text, out xtva); Double.TryParse(Tttc.Text, out xttc); Double.TryParse(Tavnc.Text, out xav); Double.TryParse(Tgar.Text, out xgar); String dat = datefact.Value.ToString("yyyy-MM-dd"); string sql = "UPDATE contrat SET " // (,, ,,, , THT, TVA,TTC, AVANCE,solde,reste) VALUE (" + "CODE='" + nfact.Text + "'," + "CODEC='" + Tcodc.Text + "'," + "NOMC='" + Tnomc.Text + "'," + "ADRC='" + Tadrc.Text + "'," + "THT='" + xtht.ToString().Replace(Program.sep, string.Empty) + "'," + "TVA='" + xtva.ToString().Replace(Program.sep, string.Empty) + "'," + "TTC='" + xttc.ToString().Replace(Program.sep, string.Empty) + "'," + "VAVANC='" + xav.ToString().Replace(Program.sep, string.Empty) + "'," + "VGAR='" + xgar.ToString().Replace(Program.sep, string.Empty) + "'," + "DATEDEBUT='" + dat + "'," + "CODES='" + Program.Societe + "'" + "WHERE ID = " + IDContrat; met.Execute(sql); String ID = IDContrat; //Pylones foreach (string IDSUP in Lsupp) { String sqldel = "DELETE FROM lcontrat WHERE ID = " + IDSUP; met.Execute(sqldel); } String sqlF = "INSERT INTO lcontrat (NPYLON,TYPEPYLON,TYPEMASSIF,ORDRE,PORTEE,PORTEEMOY,PUFOND,PUMONTAGE,PUDEROULAGE,POIDS,PUPoids,VBETON,PUBETON,CODES,IDCONTRAT) values"; Boolean frst = true; foreach (DataGridViewRow dr in mygrid1.Rows) { String xport = "Null", xportmoy = "Null", xpuf = "Null", xpum = "Null", xpud = "Null", xpoid = "Null", xpup = "Null", xvbp = "Null", xpuv = "Null"; if (dr.Cells["portee"].Value != null) { if (!(dr.Cells["portee"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["portee"].Value + "", out d1); xport = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["porteemoy"].Value != null) { if (!(dr.Cells["porteemoy"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["porteemoy"].Value + "", out d1); xportmoy = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUHTFondation"].Value != null) { if (!(dr.Cells["PUHTFondation"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUHTFondation"].Value + "", out d1); xpuf = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUHTMontage"].Value != null) { if (!(dr.Cells["PUHTMontage"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUHTMontage"].Value + "", out d1); xpum = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUHTDeroulage"].Value != null) { if (!(dr.Cells["PUHTDeroulage"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUHTDeroulage"].Value + "", out d1); xpud = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["Poids"].Value != null) { if (!(dr.Cells["Poids"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["Poids"].Value + "", out d1); xpoid = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUP"].Value != null) { if (!(dr.Cells["PUP"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUP"].Value + "", out d1); xpup = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["VBP"].Value != null) { if (!(dr.Cells["VBP"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["VBP"].Value + "", out d1); xvbp = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["PUV"].Value != null) { if (!(dr.Cells["PUV"].Value + "").Equals("")) { Double d1 = 0; Double.TryParse(dr.Cells["PUV"].Value + "", out d1); xpuv = "'" + d1.ToString().Replace(Program.sep, string.Empty) + "'"; } } if (dr.Cells["ID"].Value == null) { if (!dr.IsNewRow) { if (!frst) { sqlF += ",("; } else { sqlF += "("; } sqlF += "'" + dr.Cells["Npylon"].Value + "'" + ",'" + dr.Cells["TypePylone"].Value + "'" + ",'" + dr.Cells["TypeMassif"].Value + "'" + ",'" + (dr.Index + 1) + "'" + "," + xport + "" + "," + xportmoy + "" + "," + xpuf + "" + "," + xpum + "" + "," + xpud + "" + "," + xpoid + "" + "," + xpup + "" + "," + xvbp + "" + "," + xpuv + "" + ",'" + Program.Societe + "'" + "," + ID + ")"; frst = false; } } else { String sqlu = "UPDATE lcontrat SET" + " NPYLON='" + dr.Cells["Npylon"].Value + "'" + ",ORDRE='" + (dr.Index + 1) + "'" + ",TYPEPYLON='" + dr.Cells["TypePylone"].Value + "'" + ",TYPEMASSIF='" + dr.Cells["TypeMassif"].Value + "'" + ", PORTEE=" + xport + "" + ", PORTEEMOY=" + xportmoy + "" + ",PUFOND=" + xpuf + "" + ",PUMONTAGE=" + xpum + "" + ",PUDEROULAGE=" + xpud + "" + ",POIDS=" + xpoid + "" + ",PUPoids=" + xpup + "" + ",VBETON=" + xvbp + "" + ",PUBETON=" + xpuv + "" + " WHERE ID = " + dr.Cells["ID"].Value; met.Execute(sqlu); } } if (!frst) { met.Execute(sqlF); } MessageBox.Show("Enregistrement avec sucée."); } } else { MessageBox.Show("Verifier Le Code Client."); } }
private void FFondation_Load(object sender, EventArgs e) { String sqlmp = "Select * From modalite where codes='" + Program.Societe + "'"; DataSet dsm = met.recuperer_table(sqlmp, "modalite"); BindingSource bs = new BindingSource(dsm, "modalite"); Modep.DisplayMember = "libelle"; Modep.ValueMember = "Code"; Modep.DataSource = bs; rbnht.Checked = true; rbht.Checked = false; if (newf) { increment(); nfact.Text = NumFact; } else { modif = true; string sql = "select * from facture where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and numf = '" + NumFact + "'"; DataSet ds = met.recuperer_table(sql); DataRow drf = null; try{ drf = ds.Tables[0].Rows[0]; }catch {} if (drf != null) { nfact.ReadOnly = true; try { datefact.Value = drf.Field <DateTime>("DATEF"); } catch { } nfact.Text = drf["NUMF"] + ""; tref.Text = drf["REF"] + ""; tvref.Text = drf["VREF"] + ""; tnref.Text = drf["NREF"] + ""; Tcodc.Text = drf["CODEC"] + ""; cli = new MetierClient(Tcodc.Text); Tnomc.Text = drf["NOMC"] + ""; Tadrc.Text = drf["ADRC"] + ""; Modep.SelectedValue = drf["MODEP"] + ""; try { Ttht.Text = drf.Field <decimal>("THT").ToString("N3") + ""; } catch { } try { Tret.Text = drf.Field <decimal>("RGARANTIE").ToString("N3") + ""; } catch { } try { Tav.Text = drf.Field <decimal>("RAVANCE").ToString("N3") + ""; } catch { } try { Ttimbre.Text = drf.Field <decimal>("TIMBRE").ToString("N3") + ""; } catch { } try { tprorata.Text = drf.Field <decimal>("prorata").ToString("N2") + ""; } catch { } try { Ttva.Text = drf.Field <decimal>("TVA").ToString("N3") + ""; } catch { } try { Tttc.Text = drf.Field <decimal>("TTC").ToString("N3") + ""; } catch { } try { Tnetht.Text = drf.Field <decimal>("NETHT").ToString("N3") + ""; } catch { } try { tpav.Text = drf.Field <decimal>("VAVANCE").ToString("N2") + ""; } catch { } try { Tpret.Text = drf.Field <decimal>("VGARANTIE").ToString("N2") + ""; } catch { } } string sqld = "select * from ltravaux where codes = '" + Program.Societe + "' and numf = '" + NumFact + "' and codee='" + Program.Exercice + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { mygrid1.Rows.Add(); mygrid1.Rows[i].Cells["Npylon"].Value = dr["DESIGNATION"]; mygrid1.Rows[i].Cells["VBP"].Value = dr["QTE"]; mygrid1.Rows[i].Cells["U"].Value = dr["U"]; mygrid1.Rows[i].Cells["PUHTF"].Value = dr["PUHT"]; mygrid1.Rows[i].Cells["PTHT"].Value = dr["PTHT"]; mygrid1.Rows[i].Cells["TVAFF"].Value = dr["TVA"]; mygrid1.Rows[i].Cells["ID"].Value = dr["ID"]; i++; } } catch { } mygrid1.Focus(); } }
private void FFondation_Load(object sender, EventArgs e) { act = false; String sqlmp = "Select * From modalite where codes='" + Program.Societe + "'"; DataSet dsm = met.recuperer_table(sqlmp, "modalite"); BindingSource bs = new BindingSource(dsm, "modalite"); Modep.DisplayMember = "libelle"; Modep.ValueMember = "Code"; Modep.DataSource = bs; rbnht.Checked = true; rbht.Checked = false; { increment(); nfact.Text = NumFact; //cli = new MetierClient(Tcodc.Text); Tnomc.Text = cli.NomC + ""; Tadrc.Text = cli.adrc + ""; Tcodc.Text = cli.Codec; if (max < souh) { souh = max; } if (max == 30) { souh = 20; } tprorata.Text = souh.ToString("N2"); datefact.Value = DateTime.Now; try { int i = 0; foreach (string str in LSTid) { string sqldd = "SELECT * FROM lcontrat where ID = " + str; DataSet dsdd = met.recuperer_table(sqldd); if (dsdd != null) { if (dsdd.Tables.Count != 0) { if (dsdd.Tables[0].Rows.Count != 0) { var dr = dsdd.Tables[0].Rows[0]; mygrid1.Rows.Add(); mygrid1.Rows[i].Cells["ID"].Value = dr["ID"]; mygrid1.Rows[i].Cells["Npylon"].Value = dr["NPYLON"]; mygrid1.Rows[i].Cells["TypePylone"].Value = dr["TYPEPYLON"]; mygrid1.Rows[i].Cells["VBP"].Value = dr["PORTEEMOY"]; mygrid1.Rows[i].Cells["U"].Value = "KM"; mygrid1.Rows[i].Cells["PUHTF"].Value = dr["PUMONTAGE"]; //mygrid1.Rows[i].Cells["PTHT"].Value = dr["PTHT"]; mygrid1.Rows[i].Cells["TVAFF"].Value = 18; if (i != 0) { section += "-"; } section += dr["NPYLON"]; } } } i++; } } catch { } recap(); mygrid1.Focus(); } act = true; calcultotal(); }
private void charger_lignefacture() { if (first) { dataGridViewX1.Rows[dataGridViewX1.Rows.Count - 1].Selected = true; } if (dataGridViewX1.SelectedRows.Count != 0) { // type Facture if (dataGridViewX1.SelectedRows[0].Cells["mode"].Value.Equals("D")) { string sqlfac = "Select montreg From eentcs where codes = '" + Program.Societe + "' AND codee ='" + Program.Exercice + "' AND codem ='" + Program.Magasin + "' AND num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'"; DataSet tmpf = met.recuperer_table(sqlfac); if (tmpf != null) { if (tmpf.Tables.Count != 0) { if (tmpf.Tables[0].Rows.Count != 0) { double xmntreg = 0; double.TryParse(tmpf.Tables[0].Rows[0]["montreg"] + "", out xmntreg); if (xmntreg == 0) { buttonX2.Enabled = true; buttonX3.Enabled = true; } else { buttonX2.Enabled = false; buttonX3.Enabled = false; } } } } } else { string sqlfac = "Select montreg,mode From eentcs where codes = '" + Program.Societe + "' AND codee ='" + Program.Exercice + "' AND codem ='" + Program.Magasin + "' AND num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'"; DataSet tmpf = met.recuperer_table(sqlfac); if (tmpf != null) { if (tmpf.Tables.Count != 0) { if (tmpf.Tables[0].Rows.Count != 0) { string xmode = tmpf.Tables[0].Rows[0]["mode"] + ""; double xmntreg = 0; double.TryParse(tmpf.Tables[0].Rows[0]["montreg"] + "", out xmntreg); if (xmntreg == 0) { buttonX2.Enabled = false; buttonX3.Enabled = true; } else { buttonX2.Enabled = false; if (xmode == "B") { buttonX3.Enabled = true; } else { buttonX3.Enabled = false; } } } } } } // Chargement ligne Facture string req1 = "select distinct l.num,l.codea, a.libelle , g.libelle as gamme , d.libelle as depot , l.qte , l.pu , l.tva ,l.taxe ,l.tvaf , l.rem , l.netht , l.netttc,l.codesa,l.ID from lentcs l , article a , gamme g , depot d where l.codes='" + Program.Societe + "' and l.codee='" + Program.Exercice + "' and l.num= '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "' and l.codem='" + Program.Magasin + "' and l.codea = a.code and l.codes= a.codes and l.codee= a.codee and l.codea = g.codea and l.codeg=g.codeg and l.codes=g.codes and l.codee=g.codee and l.coded= d.code and l.codes=d.codes and l.codee=d.codee and l.codem=d.codem "; DataSet ds1 = met.recuperer_table(req1, "lentcs"); foreach (DataRow dr in ds1.Tables["lentcs"].Rows) { if (dr["codesa"] != DBNull.Value) { string sql = "select libelle from sarticle where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codea= '" + dr["codea"] + "' and code = '" + dr["codesa"] + "'"; DataSet dtmp = met.recuperer_table(sql, "sarticle"); dr["libelle"] = dtmp.Tables[0].Rows[0][0]; dr["codea"] = DBNull.Value; dr["gamme"] = DBNull.Value; dr["depot"] = DBNull.Value; } } dataGridViewX2.DataSource = ds1.Tables["lentcs"].DefaultView; } }
private void buttonX2_Click(object sender, EventArgs e) { if (cli != null) { if (!modif) { string err = ""; if (err.Equals("")) { SaveIncrementationNumero(); String dat = datefact.Value.ToString("yyyy-MM-dd"); string sql = "INSERT INTO Facture (NUMF,REF,NREF,VREF,CODEC, NOMC,ADRC,DATEF, CODES,CODEE, THT,RAVANCE,RGARANTIE,NETHT, TVA,TIMBRE,TTC,RS50,RS15,NET,MODEP,type,VGARANTIE,VAVANCE,prorata,Contrat) VALUE (" + "'" + nfact.Text + "'," + "'" + met.CString(tref.Text) + "'," + "'" + met.CString(tnref.Text) + "'," + "'" + met.CString(tvref.Text) + "'," + "'" + Tcodc.Text + "'," + "'" + met.CString(Tnomc.Text) + "'," + "'" + met.CString(Tadrc.Text) + "'," + "'" + dat + "'," + "'" + Program.Societe + "'," + "'" + Program.Exercice + "'," + "'" + Ttht.Text.Replace(Program.sep, string.Empty) + "'," + "'" + Tav.Text.Replace(Program.sep, string.Empty) + "'," + "'" + Tret.Text.Replace(Program.sep, string.Empty) + "'," + "'" + Tnetht.Text.Replace(Program.sep, string.Empty) + "'," + "'" + Ttva.Text.Replace(Program.sep, string.Empty) + "'," + "'" + Ttimbre.Text.Replace(Program.sep, string.Empty) + "'," + "'" + Tttc.Text.Replace(Program.sep, string.Empty) + "'," + "'" + rs50.Text.Replace(Program.sep, string.Empty) + "'," + "'" + rs15.Text.Replace(Program.sep, string.Empty) + "'," + "'" + net.Text.Replace(Program.sep, string.Empty) + "'," + "'" + Modep.SelectedValue + "'," + "'DD'," + "'" + Tpret.Text.Replace(Program.sep, string.Empty) + "'," + "'" + tpav.Text.Replace(Program.sep, string.Empty) + "'," + "'" + tprorata.Text.Replace(Program.sep, string.Empty) + "'," + "" + IDContrat + "" + ")"; met.Execute(sql); //Montage String sqlF = "insert INTO lderoulage (NPYLONE,TYPEPYLONE,QTE,U,PUHT,PTHT,TVA,CODES,CODEE,NUMF,IDLC,IDLC1) values"; Boolean frst = true; int lasord = 0; string lastid = ""; for (int cpt = 0; cpt < mygrid1.Rows.Count - 1; cpt += 2) { DataGridViewRow dr = mygrid1.Rows[cpt]; DataGridViewRow dr1 = mygrid1.Rows[cpt + 1]; if (!dr.IsNewRow) { if (!dr.Cells["ID"].Value.Equals(-1)) { if (!frst) { sqlF += ",("; } else { sqlF += "("; } string xqte = "0", xpu = "0", xptht = "0", xtva = "0", xid1 = "0"; if (cpt != mygrid1.Rows.Count - 2) { xqte = (dr1.Cells["VBP"].Value + "").Replace(Program.sep, string.Empty); xpu = (dr1.Cells["PUHTF"].Value + "").Replace(Program.sep, string.Empty); xptht = (dr1.Cells["PTHT"].Value + "").Replace(Program.sep, string.Empty); xtva = (dr1.Cells["TVAFF"].Value + "").Replace(Program.sep, string.Empty); xid1 = dr1.Cells["ID"].Value + ""; MAJProrat(dr.Cells["ID"].Value + ""); int.TryParse(dr1.Cells["ordre"].Value + "", out lasord); } else { } lastid = dr1.Cells["ID"].Value + ""; sqlF += "'" + met.CString(dr.Cells["Npylon"].Value) + "'" + ",'" + met.CString(dr.Cells["TypePylone"].Value) + "'" + ",'" + xqte + "'" + ",'" + met.CString(dr1.Cells["U"].Value) + "'" + ",'" + xpu + "'" + ",'" + xptht + "'" + ",'" + xtva + "'" + ",'" + Program.Societe + "'" + ",'" + Program.Exercice + "'" + ",'" + nfact.Text + "'" + ",'" + dr.Cells["ID"].Value + "','" + xid1 + "')"; frst = false; } } } lastid = mygrid1.Rows[mygrid1.Rows.Count - 2].Cells["ID"].Value + ""; string sqllastid = "SELECT MAX(ordre) FROM lcontrat WHERE IDCONTRAT = " + IDContrat; DataSet dsid = met.recuperer_table(sqllastid); try { int idtest = 0; int.TryParse(dsid.Tables[0].Rows[0][0] + "", out idtest); if (lasord == idtest) { MAJProrat(lastid + ""); } } catch { } if (!frst) { met.Execute(sqlF); } MessageBox.Show("Sauvgard avec sucée."); buttonX2.Visible = false; buttonX3.Visible = true; } else { MessageBox.Show(err); } } } else { MessageBox.Show("Verifier Le Code Client."); } }
private void charger_lignefacture() { if (dataGridViewX1.CurrentCell != null) { grid_fondation.Visible = false; Grid_montage.Visible = false; grid_deroulage.Visible = false; grid_divers.Visible = false; grid_FD.Visible = false; grid_MD.Visible = false; grid_DD.Visible = false; grid_AV.Visible = false; grid_GR.Visible = false; grid_TD.Visible = false; grid_TD.Rows.Clear(); grid_GR.Rows.Clear(); grid_AV.Rows.Clear(); grid_DD.Rows.Clear(); grid_MD.Rows.Clear(); grid_FD.Rows.Clear(); grid_divers.Rows.Clear(); grid_fondation.Rows.Clear(); Grid_montage.Rows.Clear(); grid_deroulage.Rows.Clear(); string xtype = dataGridViewX1.Rows[dataGridViewX1.CurrentCell.RowIndex].Cells["mode"].Value + ""; string NumFact = dataGridViewX1.Rows[dataGridViewX1.CurrentCell.RowIndex].Cells["NuM"].Value + ""; if (xtype == "F") { string sqld = "select * from lfondation where codes = '" + Program.Societe + "' and codee='" + Program.Exercice + "' and numf = '" + NumFact + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { grid_fondation.Rows.Add(); grid_fondation.Rows[i].Cells["NpylonF"].Value = dr["NPYLONE"]; grid_fondation.Rows[i].Cells["TypePyloneF"].Value = dr["TYPEPYLONE"]; grid_fondation.Rows[i].Cells["TypeMassifF"].Value = dr["Tmassif"]; grid_fondation.Rows[i].Cells["VBPF"].Value = dr["VBETPROPRETE"]; grid_fondation.Rows[i].Cells["VB350F"].Value = dr["VB350"]; grid_fondation.Rows[i].Cells["VTOTALF"].Value = dr["VTOTAL"]; grid_fondation.Rows[i].Cells["UF"].Value = dr["U"]; grid_fondation.Rows[i].Cells["PUHTFF"].Value = dr["PUHT"]; grid_fondation.Rows[i].Cells["PTHTF"].Value = dr["PTHT"]; grid_fondation.Rows[i].Cells["TVAFFF"].Value = dr["TVA"]; grid_fondation.Rows[i].Cells["IDF"].Value = dr["ID"]; i++; } } catch { } grid_fondation.Visible = true; grid_fondation.Dock = DockStyle.Fill; } else if (xtype == "M") { string sqld = "select * from lmontage where codes = '" + Program.Societe + "' and numf = '" + NumFact + "' and codee='" + Program.Exercice + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { Grid_montage.Rows.Add(); Grid_montage.Rows[i].Cells["NpylonM"].Value = dr["NPYLONE"]; Grid_montage.Rows[i].Cells["TypePyloneM"].Value = dr["TYPEPYLONE"]; Grid_montage.Rows[i].Cells["VBPM"].Value = dr["POIDS"]; Grid_montage.Rows[i].Cells["UM"].Value = dr["U"]; Grid_montage.Rows[i].Cells["PUHTFM"].Value = dr["PUHT"]; Grid_montage.Rows[i].Cells["PTHTM"].Value = dr["PTHT"]; Grid_montage.Rows[i].Cells["TVAFFM"].Value = dr["TVA"]; Grid_montage.Rows[i].Cells["IDM"].Value = dr["ID"]; i++; } } catch { } Grid_montage.Visible = true; Grid_montage.Dock = DockStyle.Fill; } else if (xtype == "D") { string sqld = "select * from lderoulage where codes = '" + Program.Societe + "' and numf = '" + NumFact + "' and codee='" + Program.Exercice + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { grid_deroulage.Rows.Add(); grid_deroulage.Rows[i].Cells["Npylon"].Value = dr["DESIGNATION"]; grid_deroulage.Rows[i].Cells["TypePylone"].Value = dr["SECTION"]; grid_deroulage.Rows[i].Cells["VBP"].Value = dr["QTE"]; grid_deroulage.Rows[i].Cells["U"].Value = dr["U"]; grid_deroulage.Rows[i].Cells["PUHTF"].Value = dr["PUHT"]; grid_deroulage.Rows[i].Cells["PTHT"].Value = dr["PTHT"]; grid_deroulage.Rows[i].Cells["TVAFF"].Value = dr["TVA"]; grid_deroulage.Rows[i].Cells["ID"].Value = dr["ID"]; i++; } } catch { } grid_deroulage.Visible = true; grid_deroulage.Dock = DockStyle.Fill; } else if (xtype == "T") { string sqld = "select * from ltravaux where codes = '" + Program.Societe + "' and numf = '" + NumFact + "' and codee='" + Program.Exercice + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { grid_divers.Rows.Add(); grid_divers.Rows[i].Cells["NpylonT"].Value = dr["DESIGNATION"]; grid_divers.Rows[i].Cells["VBPT"].Value = dr["QTE"]; grid_divers.Rows[i].Cells["UT"].Value = dr["U"]; grid_divers.Rows[i].Cells["PUHTFT"].Value = dr["PUHT"]; grid_divers.Rows[i].Cells["PTHTT"].Value = dr["PTHT"]; grid_divers.Rows[i].Cells["TVAFFT"].Value = dr["TVA"]; grid_divers.Rows[i].Cells["IDT"].Value = dr["ID"]; i++; } } catch { } grid_divers.Visible = true; grid_divers.Dock = DockStyle.Fill; } else if (xtype == "FD") { string sqld = "select * from lfondation where codes = '" + Program.Societe + "' and codee='" + Program.Exercice + "' and numf = '" + NumFact + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { grid_FD.Rows.Add(); grid_FD.Rows[i].Cells["NpylonFD"].Value = dr["NPYLONE"]; grid_FD.Rows[i].Cells["TypePyloneFD"].Value = dr["TYPEPYLONE"]; grid_FD.Rows[i].Cells["VBPFD"].Value = dr["QTE"]; grid_FD.Rows[i].Cells["UFD"].Value = dr["U"]; grid_FD.Rows[i].Cells["PUHTFFD"].Value = dr["PUHT"]; grid_FD.Rows[i].Cells["PTHTFD"].Value = dr["PTHT"]; grid_FD.Rows[i].Cells["TVAFFFD"].Value = dr["TVA"]; grid_FD.Rows[i].Cells["IDFD"].Value = dr["ID"]; i++; } } catch { } grid_FD.Visible = true; grid_FD.Dock = DockStyle.Fill; } else if (xtype == "MD") { string sqld = "select * from lmontage where codes = '" + Program.Societe + "' and numf = '" + NumFact + "' and codee='" + Program.Exercice + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { grid_MD.Rows.Add(); grid_MD.Rows[i].Cells["NpylonMD"].Value = dr["NPYLONE"]; grid_MD.Rows[i].Cells["TypePyloneMD"].Value = dr["TYPEPYLONE"]; grid_MD.Rows[i].Cells["VBPMD"].Value = dr["POIDS"]; grid_MD.Rows[i].Cells["UMD"].Value = dr["U"]; grid_MD.Rows[i].Cells["PUHTFMD"].Value = dr["PUHT"]; grid_MD.Rows[i].Cells["PTHTMD"].Value = dr["PTHT"]; grid_MD.Rows[i].Cells["TVAFFMD"].Value = dr["TVA"]; grid_MD.Rows[i].Cells["IDMD"].Value = dr["ID"]; i++; } } catch { } grid_MD.Visible = true; grid_MD.Dock = DockStyle.Fill; } else if (xtype == "DD") { string sqld = "select * from lderoulage where codes = '" + Program.Societe + "' and numf = '" + NumFact + "' and codee='" + Program.Exercice + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { grid_DD.Rows.Add(); grid_DD.Rows[i].Cells["NpylonDD"].Value = dr["NPYLONE"]; grid_DD.Rows[i].Cells["TypePyloneDD"].Value = dr["TYPEPYLONE"]; grid_DD.Rows[i].Cells["VBPDD"].Value = dr["QTE"]; grid_DD.Rows[i].Cells["UDD"].Value = dr["U"]; grid_DD.Rows[i].Cells["PUHTFDD"].Value = dr["PUHT"]; grid_DD.Rows[i].Cells["PTHTDD"].Value = dr["PTHT"]; grid_DD.Rows[i].Cells["TVAFFDD"].Value = dr["TVA"]; grid_DD.Rows[i].Cells["IDDD"].Value = dr["ID"]; i++; } } catch { } grid_DD.Visible = true; grid_DD.Dock = DockStyle.Fill; } else if (xtype == "AV") { string sqld = "select * from ltravaux where codes = '" + Program.Societe + "' and numf = '" + NumFact + "' and codee='" + Program.Exercice + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { grid_AV.Rows.Add(); grid_AV.Rows[i].Cells["desav"].Value = dr["designation"]; grid_AV.Rows[i].Cells["Tauxav"].Value = dr["PUHT"]; grid_AV.Rows[i].Cells["mnttravaux"].Value = dr["taux"]; grid_AV.Rows[i].Cells["PTHTAV"].Value = dr["PTHT"]; grid_AV.Rows[i].Cells["TVAAV"].Value = dr["TVA"]; grid_AV.Rows[i].Cells["IDAV"].Value = dr["ID"]; i++; } } catch { } grid_AV.Visible = true; grid_AV.Dock = DockStyle.Fill; } else if (xtype == "GR") { string sqld = "select * from ltravaux where codes = '" + Program.Societe + "' and numf = '" + NumFact + "' and codee='" + Program.Exercice + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { grid_GR.Rows.Add(); grid_GR.Rows[i].Cells["desgr"].Value = dr["designation"]; grid_GR.Rows[i].Cells["Tauxgr"].Value = dr["PUHT"]; grid_GR.Rows[i].Cells["mnttravauxgr"].Value = dr["taux"]; grid_GR.Rows[i].Cells["PTHTGR"].Value = dr["PTHT"]; grid_GR.Rows[i].Cells["TVAGR"].Value = dr["TVA"]; grid_GR.Rows[i].Cells["IDGR"].Value = dr["ID"]; i++; } } catch { } grid_GR.Visible = true; grid_GR.Dock = DockStyle.Fill; } else if (xtype == "TD") { string sqld = "select * from ldivers where codes = '" + Program.Societe + "' and numf = '" + NumFact + "' and codee='" + Program.Exercice + "'"; DataSet dsd = met.recuperer_table(sqld); try { int i = 0; foreach (DataRow dr in dsd.Tables[0].Rows) { grid_TD.Rows.Add(); grid_TD.Rows[i].Cells["NpylonTD"].Value = dr["NPYLONE"]; grid_TD.Rows[i].Cells["TypePyloneTD"].Value = dr["TYPEPYLONE"]; grid_TD.Rows[i].Cells["VBPTD"].Value = dr["QTE"]; grid_TD.Rows[i].Cells["UTD"].Value = dr["U"]; grid_TD.Rows[i].Cells["PUHTFTD"].Value = dr["PUHT"]; grid_TD.Rows[i].Cells["PTHTTD"].Value = dr["PTHT"]; grid_TD.Rows[i].Cells["TVAFFTD"].Value = dr["TVA"]; grid_TD.Rows[i].Cells["IDTD"].Value = dr["ID"]; i++; } } catch { } grid_TD.Visible = true; grid_TD.Dock = DockStyle.Fill; } } }
private void buttonX2_Click(object sender, EventArgs e) { if (cli != null) { if (!modif) { String dat = datefact.Value.ToString("yyyy-MM-dd"); string sql = "INSERT INTO contrat (CODE,CODEC, NOMC,ADRC,DATEDEBUT,VGAR,VAVANC, CODES) VALUE ("//, THT, TVA,TTC, AVANCE,solde,reste + "'" + nfact.Text + "'," + "'" + Tcodc.Text + "'," + "'" + Tnomc.Text + "'," + "'" + Tadrc.Text + "'," + "'" + dat + "'," + "'" + Tgar.Text + "'," + "'" + Tavnc.Text + "'," + "'" + Program.Societe + "'" + ")"; String sqlID = "Select Max(ID) FROM contrat"; met.Execute(sql); DataSet dsID = met.recuperer_table(sqlID); String ID = string.Empty; try { ID = dsID.Tables[0].Rows[0].ItemArray[0] + ""; } catch { } //Pylones String sqlF = "INSERT INTO lcontrat (NPYLON,TYPEPYLON,TYPEMASSIF,POIDS,PUPoids,VBETON,PUBETON,DISTANCE,PUDISTANCE,CODES,IDCONTRAT) values"; Boolean frst = true; foreach (DataGridViewRow dr in mygrid1.Rows) { if (!dr.IsNewRow) { if (!frst) { sqlF += ",("; } else { sqlF += "("; } sqlF += "'" + dr.Cells["Npylon"].Value + "'" + ",'" + dr.Cells["TypePylone"].Value + "'" + ",'" + dr.Cells["TypeMassif"].Value + "'" + ",'" + (dr.Cells["Poids"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["PUP"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["VBP"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["PUV"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["distance"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["PUD"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + Program.Societe + "'" + "," + ID + ")"; frst = false; } } if (!frst) { met.Execute(sqlF); } MessageBox.Show("Enregistrement avec sucée."); } else { String dat = datefact.Value.ToString("yyyy-MM-dd"); string sql = "UPDATE contrat SET " // (,, ,,, , THT, TVA,TTC, AVANCE,solde,reste) VALUE (" + "CODE='" + nfact.Text + "'," + "CODEC='" + Tcodc.Text + "'," + "NOMC='" + Tnomc.Text + "'," + "ADRC='" + Tadrc.Text + "'," + "VGAR='" + Tgar.Text + "'," + "VAVANC='" + Tavnc.Text + "'," + "DATEDEBUT='" + dat + "'," + "CODES='" + Program.Societe + "'" + "WHERE ID = " + IDContrat; met.Execute(sql); String ID = IDContrat; //Pylones foreach (string IDSUP in Lsupp) { String sqldel = "DELETE FROM lcontrat WHERE ID = " + IDSUP; met.Execute(sqldel); } String sqlF = "INSERT INTO lcontrat (NPYLON,TYPEPYLON,TYPEMASSIF,POIDS,PUPoids,VBETON,PUBETON,DISTANCE,PUDISTANCE,CODES,IDCONTRAT) values"; Boolean frst = true; foreach (DataGridViewRow dr in mygrid1.Rows) { if (dr.Cells["ID"].Value == null) { if (!dr.IsNewRow) { if (!frst) { sqlF += ",("; } else { sqlF += "("; } sqlF += "'" + dr.Cells["Npylon"].Value + "'" + ",'" + dr.Cells["TypePylone"].Value + "'" + ",'" + dr.Cells["TypeMassif"].Value + "'" + ",'" + (dr.Cells["Poids"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["PUP"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["VBP"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["PUV"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["distance"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + (dr.Cells["PUD"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",'" + Program.Societe + "'" + "," + ID + ")"; frst = false; } } else { String sqlu = "UPDATE lcontrat SET" + " NPYLON='" + dr.Cells["Npylon"].Value + "'" + ",TYPEPYLON='" + dr.Cells["TypePylone"].Value + "'" + ",TYPEMASSIF='" + dr.Cells["TypeMassif"].Value + "'" + ",POIDS='" + (dr.Cells["Poids"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",PUPoids='" + (dr.Cells["PUP"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",VBETON='" + (dr.Cells["VBP"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",PUBETON='" + (dr.Cells["PUV"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",DISTANCE='" + (dr.Cells["distance"].Value + "").Replace(Program.sep, string.Empty) + "'" + ",PUDISTANCE='" + (dr.Cells["PUD"].Value + "").Replace(Program.sep, string.Empty) + "'" + " WHERE ID = " + dr.Cells["ID"].Value; met.Execute(sqlu); } } if (!frst) { met.Execute(sqlF); } MessageBox.Show("Enregistrement avec sucée."); } } else { MessageBox.Show("Verifier Le Code Client."); } }