private void bt_valider_Click(object sender, EventArgs e) { if (uf.confirmer_questionON(this, "Etes-vous sûre de valider ?") == DialogResult.Yes) { DataTableReader rr = realvistaDataSet.facturation.CreateDataReader(); string numf = ""; decimal mttbrutmoinsrabais = 0; decimal mttapayer = 0; int numfolio = 0; string idcomptedebit = ""; string idcomptefacture = ""; string nomprenom = ""; if (!brappel) { numfolio = int.Parse(Fmain.Maxsuivant(Fmain.nombasecompta + ".cpta_mouvement", "numfolio", "year(datemouvement) = " + DateTime.Now.Year.ToString())); idcomptedebit = uf.ValeurParCond(comrech, Fmain.nombasecompta + ".cpta_compte", "idcompte, codecompte", "idcompte", "codecompte = " + Fmain.comptedebit); idcomptefacture = uf.ValeurParCond(comrech, Fmain.nombasecompta + ".cpta_compte", "idcompte, codecompte", "idcompte", "codecompte = " + Fmain.comptefacture); } while (rr.Read()) { if (numf != rr.GetValue(rr.GetOrdinal("fact_nofacture")).ToString()) { if (brappel) { if (numf != "") { uf.executeSQL(comrealvistamod, "fact_facturation", "dateecheance, rappel", string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancerappel")).ToString()))) + "$" + "##rappel+1", 1, "identreprise = " + Fmain.identreprisesel + " AND reffacturedeltareal = '" + numf + "'"); uf.executeSQL(comrealvistamod, "fact_procedures", "identreprise,idclient,numfacture,inouttype,initial,dateproc,typecourrier,echeanceproc", Fmain.identreprisesel + "$" + rr.GetValue(rr.GetOrdinal("iCli")).ToString() + "$" + numf + "$" + "out" + "$" + Fmain.InitUser + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + "Rappel " + ((int.Parse(rr.GetValue(rr.GetOrdinal("fact_nbrrappel")).ToString())) + 1).ToString() + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancerappel")).ToString()))), 2, ""); } } else { if (numf != "") { string newid = uf.executeSQL(comrealvistamod, Fmain.nombasecompta + ".cpta_mouvement", "numfolio,datesaisie,datemouvement,typeecriture,idcompte,codecompte,idcomptec,codecomptec,libelledetail,entree,sortie", numfolio.ToString() + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + "1" + "$" + idcomptedebit + "$" + Fmain.comptedebit + "$" + idcomptefacture + "$" + Fmain.comptefacture + "$" + numf + " " + nomprenom + "$" + uf.getFormatCur(mttapayer, false) + "$" + "0", 2, ""); uf.executeSQL(comrealvistamod, "fact_facturation", "dateimpression, dateecheance, idmouvementenvoye", string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancejour")).ToString()))) + "$" + newid, 1, "identreprise = " + Fmain.identreprisesel + " AND reffacturedeltareal ='" + numf + "'"); uf.executeSQL(comrealvistamod, "fact_procedures", "identreprise,idclient,numfacture,inouttype,initial,dateproc,typecourrier,echeanceproc", Fmain.identreprisesel + "$" + rr.GetValue(rr.GetOrdinal("iCli")).ToString() + "$" + numf + "$" + "out" + "$" + Fmain.InitUser + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + "Facture" + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancejour")).ToString()))), 2, ""); numfolio++; } mttapayer = 0; } numf = rr.GetValue(rr.GetOrdinal("fact_nofacture")).ToString(); } if (!brappel) { mttbrutmoinsrabais = rr.GetDecimal(rr.GetOrdinal("art_montantbrut")) - rr.GetDecimal(rr.GetOrdinal("art_rabaischf")); mttapayer += mttbrutmoinsrabais + (mttbrutmoinsrabais * decimal.Parse(rr.GetValue(rr.GetOrdinal("fact_tvapourcent")).ToString()) / 100); nomprenom = rr.GetString(rr.GetOrdinal("cli_nom")) + " " + rr.GetString(rr.GetOrdinal("cli_prenom")) + " " + rr.GetString(rr.GetOrdinal("cli_npa")) + " " + rr.GetString(rr.GetOrdinal("cli_ville")); } } if (numf != "") { if (brappel) { //uf.executeSQL(comrealvistamod, "fact_facturation", "dateecheance, rappel", string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancejour")).ToString()))) + "$" + "##rappel+1", 1, "identreprise = " + Fmain.identreprisesel + " AND reffacturedeltareal = '" + numf + "'"); uf.executeSQL(comrealvistamod, "fact_facturation", "dateecheance, rappel", string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancerappel")).ToString()))) + "$" + "##rappel+1", 1, "identreprise = " + Fmain.identreprisesel + " AND reffacturedeltareal = '" + numf + "'"); uf.executeSQL(comrealvistamod, "fact_procedures", "identreprise,idclient,numfacture,inouttype,initial,dateproc,typecourrier,echeanceproc", Fmain.identreprisesel + "$" + rr.GetValue(rr.GetOrdinal("iCli")).ToString() + "$" + numf + "$" + "out" + "$" + Fmain.InitUser + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + "Rappel " + ((int.Parse(rr.GetValue(rr.GetOrdinal("fact_nbrrappel")).ToString())) + 1).ToString() + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancerappel")).ToString()))), 2, ""); //Fmain.identreprisesel + "$" + rr.GetValue(rr.GetOrdinal("iCli")).ToString() + "$" + numf + "$" + "out" + "$" + Fmain.InitUser + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + "Rappel" + rr.GetValue(rr.GetOrdinal("ent_echeancejour")).ToString().Substring(rr.GetValue(rr.GetOrdinal("ent_echeancejour")).ToString().IndexOf("A") + 1) + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancejour")).ToString()))), 2, ""); } else { string newid = uf.executeSQL(comrealvistamod, Fmain.nombasecompta + ".cpta_mouvement", "numfolio,datesaisie,datemouvement,typeecriture,idcompte,codecompte,idcomptec,codecomptec,libelledetail,entree,sortie", numfolio.ToString() + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + "1" + "$" + idcomptedebit + "$" + Fmain.comptedebit + "$" + idcomptefacture + "$" + Fmain.comptefacture + "$" + numf + " " + nomprenom + "$" + uf.getFormatCur(mttapayer, false) + "$" + "0", 2, ""); uf.executeSQL(comrealvistamod, "fact_facturation", "dateimpression, dateecheance, idmouvementenvoye", string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancejour")).ToString()))) + "$" + newid, 1, "identreprise = " + Fmain.identreprisesel + " AND reffacturedeltareal ='" + numf + "'"); uf.executeSQL(comrealvistamod, "fact_procedures", "identreprise,idclient,numfacture,inouttype,initial,dateproc,typecourrier,echeanceproc", Fmain.identreprisesel + "$" + rr.GetValue(rr.GetOrdinal("iCli")).ToString() + "$" + numf + "$" + "out" + "$" + Fmain.InitUser + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + "Facture" + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(int.Parse(rr.GetValue(rr.GetOrdinal("ent_echeancejour")).ToString()))), 2, ""); numfolio++; } } this.DialogResult = DialogResult.OK; } }
private void bt_valider_Click(object sender, EventArgs e) { decimal dprix = 0; decimal.TryParse(uf.valtexte(edprix), out dprix); decimal drabaisp = 0; decimal drabaism = 0; decimal.TryParse(uf.valtexte(edrabaismontant), out drabaism); decimal.TryParse(uf.valtexte(edrabaispourcent), out drabaisp); if (unite.SelectedIndex < 0) { uf.AfficherErreur("Veuillez l'unité de cet article !"); return; } if (drabaisp > 0) { drabaism = 0; } if (dprix == 0) { uf.AfficherErreur("Veuillez entrer le prix de cet article !"); return; } if (etat == 2 && dprix == 0) { uf.AfficherErreur("Veuillez entrer le prix de cet article !"); return; } string champ = "identreprise, codearticle, descriptif_ligne1, descriptif_ligne2, descriptif_ligne3, descriptif_ligne4, descriptif_ligne5, remarque, idunite"; string val = "115 $ ART 02 $ DESCR 2 $ remarque 2 $ 3 $ 20.30"; val = Fmain.identreprisesel + "$" + valtexte(codearticle) + "$" + valtexte(descriptif_ligne1) + "$" + valtexte(descriptif_ligne2) + "$" + valtexte(descriptif_ligne3) + "$" + valtexte(descriptif_ligne4) + "$" + valtexte(descriptif_ligne5) + "$" + valtexte(remarque) + "$" + uf.valcombo(unite); if (etat == 2) { string newid = uf.executeSQL(comrealvista, "fact_articles", champ, val, etat, ""); uf.executeSQL(comrealvista, "fact_prix", "idarticleprix, dateprix, prix", newid + "$" + string.Format("{0:yyyy-MM-dd}", eddateprix.Value) + "$" + uf.getFormatCur(dprix), 2, ""); if (drabaisp > 0 || drabaism > 0) { uf.executeSQL(comrealvista, "fact_rabais", "idarticlerabais, dateranaisde, dateranaisa, rabaispourcent, rabaismontant", newid + "$" + string.Format("{0:yyyy-MM-dd}", eddaterabaisde.Value) + "$" + string.Format("{0:yyyy-MM-dd}", eddaterabaisa.Value) + "$" + uf.getFormatCur(edrabaispourcent) + "$" + uf.getFormatCur(edrabaismontant), 2, ""); } } else if (etat == 1) { uf.executeSQL(comrealvista, "fact_articles", champ, val, etat, "idarticle = " + gv_article.CurrentRow.Cells["g_idarticle"].Value.ToString()); } if (etat == 1) { curligne = gv_article.CurrentRow.Index; } else { curligne = gv_article.RowCount - 1; } uf.afficherInfo(this, reqdon, comrealvista, gv_article, ""); annule(); }