|
|
@@ -4,12 +4,14 @@ using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
+using System.Globalization;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Net;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
+using System.Xml.Linq;
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
namespace Fuel01
|
|
|
@@ -21,24 +23,41 @@ namespace Fuel01
|
|
|
DataSet1.tb_venteDataTable tb_vente = new DataSet1.tb_venteDataTable();
|
|
|
DataSet1.tb_prestaDataTable tb_presta = new DataSet1.tb_prestaDataTable();
|
|
|
List<string> files2move = new List<string>();
|
|
|
- bool hasChanged = false;
|
|
|
|
|
|
+ bool hasChanged = false;
|
|
|
+ List<Produit> lproduit = new List<Produit>();
|
|
|
+ List<Vente> Ventes = new List<Vente>();
|
|
|
public f_tools()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+
|
|
|
Program.subfolder = Program.folder + @"\" + Program.key_ope;
|
|
|
+
|
|
|
if (!Directory.Exists(Program.subfolder))
|
|
|
Directory.CreateDirectory(Program.subfolder);
|
|
|
|
|
|
+ if (File.Exists(Program.folder + @"\param\produit.xml"))
|
|
|
+ {
|
|
|
+ lproduit = DbUtil.GetProduits();
|
|
|
+ }
|
|
|
+
|
|
|
if (File.Exists(Program.subfolder + @"\presta.json"))
|
|
|
- tb_presta = DbUtil.LoadFromJson<DataSet1.tb_prestaDataTable>(Program.subfolder + @"\presta.json", tb_presta);
|
|
|
+ {
|
|
|
+ tb_presta = DbUtil.LoadPrestaFromJson(Program.subfolder + @"\presta.json", lproduit);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Appelle le serveur pour récupérer les fichiers
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
private void bt_getdatas_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
textResult.Text = "";
|
|
|
line_res("Connexion au serveur");
|
|
|
- string url = Properties.Settings.Default.server_adress_datas ;
|
|
|
+ string url = Properties.Settings.Default.server_adress_datas;
|
|
|
List<string> lines = readHttp_Dir(url);
|
|
|
copyHttp(lines);
|
|
|
line_res("F I N");
|
|
|
@@ -52,27 +71,37 @@ namespace Fuel01
|
|
|
textResult.Text = "";
|
|
|
line_res("Début");
|
|
|
string[] files = Directory.GetFiles(Program.folder + @"\in", "*.json ");
|
|
|
+ List<Achats3> allAchats = new List<Achats3>();
|
|
|
foreach (string file in files)
|
|
|
{
|
|
|
- StreamReader readStream = new StreamReader(file, Encoding.UTF8);
|
|
|
- if (file.ToUpper().Contains(".GLOBAL."))
|
|
|
- streamtolist_glob(readStream, file);
|
|
|
- else
|
|
|
- streamtolist_uniq(readStream, file);
|
|
|
- readStream.Close();
|
|
|
+ var content = File.ReadAllText(file);
|
|
|
+ var achats = JsonConvert.DeserializeObject<List<Achats3>>(content);
|
|
|
+ allAchats.AddRange(achats);
|
|
|
}
|
|
|
+
|
|
|
+ Ventes = ConvertAchatsToVentes(Ventes, allAchats);
|
|
|
+
|
|
|
line_res("F I N");
|
|
|
- if (err == 0 && ok == false)
|
|
|
+ if (err == 0 && !ok)
|
|
|
{
|
|
|
if (MessageBox.Show("Voulez-vous enregister les achats", "Aucune erreur", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
|
|
|
{
|
|
|
ok = true;
|
|
|
- init_vente();
|
|
|
+ load_vente();
|
|
|
bt_trait_Click(sender, e);
|
|
|
tb_vente.WriteXml(Program.subfolder + @"\vente.xml", XmlWriteMode.WriteSchema);
|
|
|
+ //File.WriteAllText(Program.subfolder + @"\vente.json", JsonConvert.SerializeObject(allAchats));
|
|
|
hasChanged = false;
|
|
|
foreach (string file in files2move)
|
|
|
File.Move(file, file.Replace(Program.folder + @"\in", Program.folder + @"\in\done"));
|
|
|
+
|
|
|
+ foreach(var vente in Ventes)
|
|
|
+ {
|
|
|
+ traite(vente);
|
|
|
+ }
|
|
|
+
|
|
|
+ DbUtil.SaveToJson<DataSet1.tb_venteDataTable>(Program.subfolder + @"\vente.json", tb_vente);
|
|
|
+ load_vente();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
@@ -80,18 +109,50 @@ namespace Fuel01
|
|
|
this.Cursor = Cursors.Default;
|
|
|
}
|
|
|
|
|
|
- private void init_vente()
|
|
|
+ private void load_vente()
|
|
|
{
|
|
|
tb_vente.Clear();
|
|
|
if (File.Exists(Program.subfolder + @"\vente.json"))
|
|
|
+ {
|
|
|
tb_vente = DbUtil.LoadFromJson<DataSet1.tb_venteDataTable>(Program.subfolder + @"\vente.json", tb_vente);
|
|
|
- tb_vente.AcceptChanges();
|
|
|
- tbventeBindingSource.DataSource = tb_vente;
|
|
|
+ Ventes = JsonConvert.DeserializeObject<List<Vente>>(File.ReadAllText(Program.subfolder + @"\vente.json"));
|
|
|
+ if (Ventes != null && Ventes.Count > 0)
|
|
|
+ {
|
|
|
+ tb_vente.AcceptChanges();
|
|
|
+ tbventeBindingSource.DataSource = tb_vente;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ private void save_vente()
|
|
|
+ {
|
|
|
+ File.WriteAllText(Program.subfolder + @"\vente.json", JsonConvert.SerializeObject(Ventes));
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Vente> ConvertAchatsToVentes(List<Vente> ventes, List<Achats3> achats)
|
|
|
+ {
|
|
|
+ foreach (var achat in achats)
|
|
|
+ {
|
|
|
+ var vente = new Vente
|
|
|
+ {
|
|
|
+ date_vt = DateTime.ParseExact(achat.moment, "yyyy-MM-ddTHH:mm:ss.ffffff", CultureInfo.InvariantCulture),
|
|
|
+ epreuve_vt = Program.key_ope,
|
|
|
+ ht_vt = 0,
|
|
|
+ prod_vt = achat.libel,
|
|
|
+ pu_vt = achat.pu,
|
|
|
+ qtt_vt = achat.qtty,
|
|
|
+ station_vt = achat.stationKey.ToString(),
|
|
|
+ ttc_vt = achat.montantTTC,
|
|
|
+ tva_vt = 0,
|
|
|
+ vehi_vt = achat.bandeau
|
|
|
+ };
|
|
|
+ ventes.Add(vente);
|
|
|
+ }
|
|
|
+ return ventes;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Récupère les nom de fichiers à partir d'un repertoire listé en HTML
|
|
|
+ /// Récupère les noms des fichiers à partir d'un repertoire listé en HTML
|
|
|
/// </summary>
|
|
|
/// <param name="url_txt">URL à lister</param>
|
|
|
/// <returns>liste Urls des fichiers distants</returns>
|
|
|
@@ -111,36 +172,28 @@ namespace Fuel01
|
|
|
readStream.Close();
|
|
|
var files = JsonConvert.DeserializeObject<List<string>>(block);
|
|
|
|
|
|
- foreach(var file in files)
|
|
|
+ foreach (var file in files.Where(x => x.EndsWith(".json", StringComparison.OrdinalIgnoreCase)))
|
|
|
{
|
|
|
-
|
|
|
- var fileUrl = Path.Combine(url_txt, file);
|
|
|
- request = (HttpWebRequest)WebRequest.Create(fileUrl);
|
|
|
- response = (HttpWebResponse)request.GetResponse();
|
|
|
- receiveStream = response.GetResponseStream();
|
|
|
- readStream = new StreamReader(receiveStream, Encoding.UTF8);
|
|
|
- block = readStream.ReadToEnd();
|
|
|
- response.Close();
|
|
|
- readStream.Close();
|
|
|
- Console.WriteLine(block);
|
|
|
- var json = JsonConvert.DeserializeObject<string>(block);
|
|
|
- var achats = JsonConvert.DeserializeObject<List<Achats3>>(json);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var fileUrl = Path.Combine(url_txt, file);
|
|
|
+ request = (HttpWebRequest)WebRequest.Create(fileUrl);
|
|
|
+ response = (HttpWebResponse)request.GetResponse();
|
|
|
+ receiveStream = response.GetResponseStream();
|
|
|
+ readStream = new StreamReader(receiveStream, Encoding.UTF8);
|
|
|
+ block = readStream.ReadToEnd();
|
|
|
+ response.Close();
|
|
|
+ readStream.Close();
|
|
|
+ Console.WriteLine(block);
|
|
|
+ var json = JsonConvert.DeserializeObject<string>(block);
|
|
|
+ _ = JsonConvert.DeserializeObject<List<Achats3>>(json);
|
|
|
+ lines.Add("http://" + response.ResponseUri.Host + "/Achats/" + file);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- //int posd = 0;
|
|
|
- //int posf = 0;
|
|
|
- //while ((posd = block.IndexOf(dep, posd)) > 0)
|
|
|
- //{
|
|
|
- // Console.WriteLine(posd);
|
|
|
- // posd += dep.Length;
|
|
|
- // posf = block.IndexOf(fin, posd);
|
|
|
- // if (posf < 0) break;
|
|
|
- // string line = block.Substring(posd, posf - posd);
|
|
|
- // if (line.Contains("/Station_") && line.ToUpper().EndsWith(".XML"))
|
|
|
- // lines.Add("http://" + response.ResponseUri.Host + line);
|
|
|
- //}
|
|
|
}
|
|
|
catch (System.Net.WebException ex)
|
|
|
{
|
|
|
@@ -186,117 +239,186 @@ namespace Fuel01
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void streamtolist_glob(StreamReader readStream, string file)
|
|
|
+ //private void streamtolist_globXMLS(StreamReader readStream, string file)
|
|
|
+ //{
|
|
|
+
|
|
|
+ // XmlSerializer xs = new XmlSerializer(typeof(List<Achats>));
|
|
|
+ // List<Achats> ListAchats = new List<Achats>();
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+ // using (readStream)
|
|
|
+ // ListAchats = xs.Deserialize(readStream) as List<Achats>;
|
|
|
+ // }
|
|
|
+ // catch (Exception ex)
|
|
|
+ // {
|
|
|
+ // err++;
|
|
|
+ // line_res("ERREUR Fichier : " + file);
|
|
|
+ // MessageBox.Show(file + "\r\n" + ex.Message, "streamtolist_glob");
|
|
|
+ // }
|
|
|
+
|
|
|
+ // foreach (Achats ac in ListAchats)
|
|
|
+ // {
|
|
|
+ // line_res(string.Format("GLOBAL Date {0} Produit {1} PTTC {2}", ac.Date, ac.KindCarbu, ac.MontantCarbu));
|
|
|
+ // if (ok)
|
|
|
+ // {
|
|
|
+ // traite(ac);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (ok && err == 0) files2move.Add(file); // Normalement err toujours à zero pour autoriser le traitement cad ok=true;
|
|
|
+
|
|
|
+ //}
|
|
|
+
|
|
|
+ //private void streamtolist(StreamReader readStream, string file)
|
|
|
+ //{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //}
|
|
|
+
|
|
|
+ //private void streamtolist_uniq(StreamReader readStream, string file)
|
|
|
+ //{
|
|
|
+ // XmlSerializer xs = new XmlSerializer(typeof(Achats));
|
|
|
+ // Achats ac = null;
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+ // using (readStream)
|
|
|
+ // ac = xs.Deserialize(readStream) as Achats;
|
|
|
+
|
|
|
+ // line_res(string.Format("UNIQ Date {0} Produit {1} PTTC {2}", ac.Date, ac.KindCarbu, ac.MontantCarbu));
|
|
|
+ // if (ok)
|
|
|
+ // {
|
|
|
+ // traite(ac);
|
|
|
+ // files2move.Add(file);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // catch (Exception ex)
|
|
|
+ // {
|
|
|
+ // err++;
|
|
|
+ // line_res("ERREUR Fichier : " + file);
|
|
|
+ // MessageBox.Show(file + "\r\n" + ex.Message, "streamtolist_uniq");
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ //private void traite(Achats ac)
|
|
|
+ //{
|
|
|
+ // if (ac.Volume > 0)
|
|
|
+ // {
|
|
|
+ // tsLbl1.Text = string.Format("Date {0} Bandeau {1} Type {2} Volume {3} Total {4}", ac.Date, ac.Bandeau, ac.KindCarbu, ac.Volume, ac.MontantTotal);
|
|
|
+ // Application.DoEvents();
|
|
|
+ // if (tb_vente.FindByepreuve_vtstation_vtvehi_vtprod_vtdate_vt(Program.key_ope, ac.StationId.ToString(), ac.Bandeau, ac.KindCarbu, ac.Date) == null)
|
|
|
+ // {
|
|
|
+ // DataSet1.tb_venteRow myrow = tb_vente.NewRow() as DataSet1.tb_venteRow;
|
|
|
+
|
|
|
+ // DataSet1.tb_prestaRow mydata = null;
|
|
|
+ // mydata = tb_presta.FindBysta_prprod_pr(ac.StationId.ToString(), ac.KindCarbu);
|
|
|
+ // if (mydata != null)
|
|
|
+ // ac.TxTva = (float)mydata.tva_pr;
|
|
|
+ // else
|
|
|
+ // ac.TxTva = 0;
|
|
|
+
|
|
|
+ // myrow["epreuve_vt"] = Program.key_ope;
|
|
|
+ // myrow["station_vt"] = ac.StationId.ToString();
|
|
|
+ // myrow["vehi_vt"] = ac.Bandeau;
|
|
|
+ // myrow["prod_vt"] = ac.KindCarbu;
|
|
|
+ // myrow["date_vt"] = ac.Date;
|
|
|
+ // myrow["qtt_vt"] = Math.Round(ac.Volume, 2);
|
|
|
+ // myrow["pu_vt"] = Math.Round(ac.PrixCarbu, 3);
|
|
|
+ // myrow["tva_vt"] = ac.TxTva;
|
|
|
+ // myrow["ttc_vt"] = Math.Round(ac.MontantCarbu, 2);
|
|
|
+ // myrow["ht_vt"] = Math.Round(ac.MontantCarbu / (1 + (ac.TxTva / 100)), 2);
|
|
|
+
|
|
|
+ // tb_vente.Addtb_venteRow(myrow);
|
|
|
+ // hasChanged = true;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // foreach (PrestasFournies pf in ac.Prestas)
|
|
|
+ // {
|
|
|
+ // if (pf.Name != null)
|
|
|
+ // {
|
|
|
+ // pf.TxTva = 0;
|
|
|
+ // string newName = pf.Name.ToUpper().Contains("FREE") ? (pf.Libel == null ? "Produit inconnu" : pf.Libel) : pf.Name;
|
|
|
+ // if (tb_vente.FindByepreuve_vtstation_vtvehi_vtprod_vtdate_vt(Program.key_ope, ac.StationId.ToString(), ac.Bandeau, newName, ac.Date) == null)
|
|
|
+ // {
|
|
|
+ // DataSet1.tb_venteRow myrow = tb_vente.NewRow() as DataSet1.tb_venteRow;
|
|
|
+ // myrow["epreuve_vt"] = Program.key_ope;
|
|
|
+ // myrow["station_vt"] = ac.StationId.ToString();
|
|
|
+ // myrow["vehi_vt"] = ac.Bandeau;
|
|
|
+ // myrow["prod_vt"] = newName;
|
|
|
+ // myrow["date_vt"] = ac.Date;
|
|
|
+ // myrow["qtt_vt"] = Math.Round(pf.Quantity, 2);
|
|
|
+ // myrow["pu_vt"] = Math.Round(pf.PrixUnitaire, 2);
|
|
|
+ // myrow["tva_vt"] = pf.TxTva; // pf.TxTva == 0 ? 20 : pf.TxTva; ;
|
|
|
+ // myrow["ttc_vt"] = Math.Round(pf.Total, 2);
|
|
|
+ // myrow["ht_vt"] = Math.Round(pf.Total, 2); // Math.Round(pf.Total / (1 + ( pf.TxTva / 100)), 2);
|
|
|
+
|
|
|
+ // tb_vente.Addtb_venteRow(myrow);
|
|
|
+ // hasChanged = true;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
+ // tsLbl1.Text = "";
|
|
|
+ //}
|
|
|
+
|
|
|
+ private void traite(Vente ac)
|
|
|
{
|
|
|
-
|
|
|
- XmlSerializer xs = new XmlSerializer(typeof(List<Achats>));
|
|
|
- List<Achats> ListAchats = new List<Achats>();
|
|
|
- try
|
|
|
- {
|
|
|
- using (readStream)
|
|
|
- ListAchats = xs.Deserialize(readStream) as List<Achats>;
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- err++;
|
|
|
- line_res("ERREUR Fichier : " + file);
|
|
|
- MessageBox.Show(file + "\r\n" + ex.Message, "streamtolist_glob");
|
|
|
- }
|
|
|
-
|
|
|
- foreach (Achats ac in ListAchats)
|
|
|
- {
|
|
|
- line_res(string.Format("GLOBAL Date {0} Produit {1} PTTC {2}", ac.Date, ac.KindCarbu, ac.MontantCarbu));
|
|
|
- if (ok)
|
|
|
- {
|
|
|
- traite(ac);
|
|
|
- }
|
|
|
- }
|
|
|
- if (ok && err == 0) files2move.Add(file); // Normalement err toujours à zero pour autoriser le traitement cad ok=true;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void streamtolist_uniq(StreamReader readStream, string file)
|
|
|
- {
|
|
|
- XmlSerializer xs = new XmlSerializer(typeof(Achats));
|
|
|
- Achats ac = null;
|
|
|
- try
|
|
|
+ if (ac.qtt_vt > 0)
|
|
|
{
|
|
|
- using (readStream)
|
|
|
- ac = xs.Deserialize(readStream) as Achats;
|
|
|
-
|
|
|
- line_res(string.Format("UNIQ Date {0} Produit {1} PTTC {2}", ac.Date, ac.KindCarbu, ac.MontantCarbu));
|
|
|
- if (ok)
|
|
|
- {
|
|
|
- traite(ac);
|
|
|
- files2move.Add(file);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- err++;
|
|
|
- line_res("ERREUR Fichier : " + file);
|
|
|
- MessageBox.Show(file + "\r\n" + ex.Message, "streamtolist_uniq");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void traite(Achats ac)
|
|
|
- {
|
|
|
- if (ac.Volume > 0)
|
|
|
- {
|
|
|
- tsLbl1.Text = string.Format("Date {0} Bandeau {1} Type {2} Volume {3} Total {4}", ac.Date, ac.Bandeau, ac.KindCarbu, ac.Volume, ac.MontantTotal);
|
|
|
+ tsLbl1.Text = string.Format("Date {0} Bandeau {1} Type {2} Volume {3} Total {4}", ac.date_vt, ac.vehi_vt, ac.prod_vt, ac.qtt_vt, ac.ttc_vt);
|
|
|
Application.DoEvents();
|
|
|
- if (tb_vente.FindByepreuve_vtstation_vtvehi_vtprod_vtdate_vt(Program.key_ope, ac.StationId.ToString(), ac.Bandeau, ac.KindCarbu, ac.Date) == null)
|
|
|
+ if (tb_vente.FindByepreuve_vtstation_vtvehi_vtprod_vtdate_vt(Program.key_ope, ac.station_vt, ac.vehi_vt, ac.prod_vt, ac.date_vt) == null)
|
|
|
{
|
|
|
DataSet1.tb_venteRow myrow = tb_vente.NewRow() as DataSet1.tb_venteRow;
|
|
|
|
|
|
DataSet1.tb_prestaRow mydata = null;
|
|
|
- mydata = tb_presta.FindBysta_prprod_pr(ac.StationId.ToString(), ac.KindCarbu);
|
|
|
- if (mydata != null)
|
|
|
- ac.TxTva = (float)mydata.tva_pr;
|
|
|
+ mydata = tb_presta.FindBysta_prprod_pr(ac.station_vt, ac.prod_vt);
|
|
|
+ if (mydata != null )
|
|
|
+ ac.txtva_vt = (float)mydata.tva_pr;
|
|
|
else
|
|
|
- ac.TxTva = 0;
|
|
|
+ ac.txtva_vt = 0;
|
|
|
|
|
|
myrow["epreuve_vt"] = Program.key_ope;
|
|
|
- myrow["station_vt"] = ac.StationId.ToString();
|
|
|
- myrow["vehi_vt"] = ac.Bandeau;
|
|
|
- myrow["prod_vt"] = ac.KindCarbu;
|
|
|
- myrow["date_vt"] = ac.Date;
|
|
|
- myrow["qtt_vt"] = Math.Round(ac.Volume,2);
|
|
|
- myrow["pu_vt"] = Math.Round(ac.PrixCarbu,3);
|
|
|
- myrow["tva_vt"] = ac.TxTva ;
|
|
|
- myrow["ttc_vt"] = Math.Round(ac.MontantCarbu,2);
|
|
|
- myrow["ht_vt"] = Math.Round( ac.MontantCarbu / ( 1+ ( ac.TxTva/100 ) ) ,2);
|
|
|
+ myrow["station_vt"] = ac.station_vt;
|
|
|
+ myrow["vehi_vt"] = ac.vehi_vt;
|
|
|
+ myrow["prod_vt"] = ac.prod_vt;
|
|
|
+ myrow["date_vt"] = ac.date_vt;
|
|
|
+ myrow["qtt_vt"] = Math.Round(ac.qtt_vt, 2);
|
|
|
+ myrow["pu_vt"] = Math.Round(ac.pu_vt, 3);
|
|
|
+ myrow["tva_vt"] = ac.txtva_vt;
|
|
|
+ myrow["ttc_vt"] = Math.Round(ac.ttc_vt, 2);
|
|
|
+ myrow["ht_vt"] = Math.Round(ac.ttc_vt / (1 + (ac.txtva_vt / 100)), 2);
|
|
|
|
|
|
tb_vente.Addtb_venteRow(myrow);
|
|
|
hasChanged = true;
|
|
|
}
|
|
|
}
|
|
|
- foreach (PrestasFournies pf in ac.Prestas)
|
|
|
- {
|
|
|
- if (pf.Name != null)
|
|
|
- {
|
|
|
- pf.TxTva = 0;
|
|
|
- string newName= pf.Name.ToUpper().Contains("FREE") ? (pf.Libel == null ? "Produit inconnu" : pf.Libel) : pf.Name;
|
|
|
- if (tb_vente.FindByepreuve_vtstation_vtvehi_vtprod_vtdate_vt(Program.key_ope, ac.StationId.ToString(), ac.Bandeau, newName, ac.Date) == null)
|
|
|
- {
|
|
|
- DataSet1.tb_venteRow myrow = tb_vente.NewRow() as DataSet1.tb_venteRow;
|
|
|
- myrow["epreuve_vt"] = Program.key_ope;
|
|
|
- myrow["station_vt"] = ac.StationId.ToString();
|
|
|
- myrow["vehi_vt"] = ac.Bandeau;
|
|
|
- myrow["prod_vt"] = newName;
|
|
|
- myrow["date_vt"] = ac.Date;
|
|
|
- myrow["qtt_vt"] = Math.Round(pf.Quantity,2);
|
|
|
- myrow["pu_vt"] = Math.Round(pf.PrixUnitaire,2);
|
|
|
- myrow["tva_vt"] = pf.TxTva ; // pf.TxTva == 0 ? 20 : pf.TxTva; ;
|
|
|
- myrow["ttc_vt"] = Math.Round(pf.Total,2);
|
|
|
- myrow["ht_vt"] = Math.Round(pf.Total,2); // Math.Round(pf.Total / (1 + ( pf.TxTva / 100)), 2);
|
|
|
-
|
|
|
- tb_vente.Addtb_venteRow(myrow);
|
|
|
- hasChanged = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+ //foreach (PrestasFournies pf in ac.Prestas)
|
|
|
+ //{
|
|
|
+ // if (pf.Name != null)
|
|
|
+ // {
|
|
|
+ // pf.TxTva = 0;
|
|
|
+ // string newName = pf.Name.ToUpper().Contains("FREE") ? (pf.Libel == null ? "Produit inconnu" : pf.Libel) : pf.Name;
|
|
|
+ // if (tb_vente.FindByepreuve_vtstation_vtvehi_vtprod_vtdate_vt(Program.key_ope, ac.StationId.ToString(), ac.Bandeau, newName, ac.Date) == null)
|
|
|
+ // {
|
|
|
+ // DataSet1.tb_venteRow myrow = tb_vente.NewRow() as DataSet1.tb_venteRow;
|
|
|
+ // myrow["epreuve_vt"] = Program.key_ope;
|
|
|
+ // myrow["station_vt"] = ac.StationId.ToString();
|
|
|
+ // myrow["vehi_vt"] = ac.Bandeau;
|
|
|
+ // myrow["prod_vt"] = newName;
|
|
|
+ // myrow["date_vt"] = ac.Date;
|
|
|
+ // myrow["qtt_vt"] = Math.Round(pf.Quantity, 2);
|
|
|
+ // myrow["pu_vt"] = Math.Round(pf.PrixUnitaire, 2);
|
|
|
+ // myrow["tva_vt"] = pf.TxTva; // pf.TxTva == 0 ? 20 : pf.TxTva; ;
|
|
|
+ // myrow["ttc_vt"] = Math.Round(pf.Total, 2);
|
|
|
+ // myrow["ht_vt"] = Math.Round(pf.Total, 2); // Math.Round(pf.Total / (1 + ( pf.TxTva / 100)), 2);
|
|
|
+
|
|
|
+ // tb_vente.Addtb_venteRow(myrow);
|
|
|
+ // hasChanged = true;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ //}
|
|
|
tsLbl1.Text = "";
|
|
|
}
|
|
|
|
|
|
@@ -317,7 +439,7 @@ namespace Fuel01
|
|
|
|
|
|
private void bt_loadVT_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- init_vente();
|
|
|
+ load_vente();
|
|
|
}
|
|
|
|
|
|
private void check_modif_CheckedChanged(object sender, EventArgs e)
|
|
|
@@ -333,8 +455,8 @@ namespace Fuel01
|
|
|
|
|
|
private void f_tools_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
{
|
|
|
- if ( hasChanged)
|
|
|
- if ( MessageBox.Show("Voulez-vous sauvegarder les modifications ?","Modifications non sauvegardées",MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)== System.Windows.Forms.DialogResult.Yes)
|
|
|
+ if (hasChanged)
|
|
|
+ if (MessageBox.Show("Voulez-vous sauvegarder les modifications ?", "Modifications non sauvegardées", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
|
|
|
DbUtil.SaveToJson<DataSet1.tb_venteDataTable>(Program.subfolder + @"\vente.json", tb_vente);
|
|
|
e.Cancel = false;
|
|
|
}
|
|
|
@@ -348,7 +470,7 @@ namespace Fuel01
|
|
|
{
|
|
|
string input = "";
|
|
|
if (Program.ShowInputDialog("Contrôle", "Entrez le mot de passe", ref input, true) == DialogResult.OK)
|
|
|
- splitContainer1.Enabled = (input == "fuel2016");
|
|
|
+ splitContainer1.Enabled = (input == "fuel2016");
|
|
|
}
|
|
|
}
|
|
|
}
|