f_verif.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace Fuel01
  12. {
  13. public partial class f_verif : Form
  14. {
  15. DataSet1.tb_venteDataTable tb_vente = new DataSet1.tb_venteDataTable();
  16. public f_verif()
  17. {
  18. InitializeComponent();
  19. }
  20. private void button1_Click(object sender, EventArgs e)
  21. {
  22. init_vente();
  23. }
  24. private void init_vente()
  25. {
  26. tb_vente.Clear();
  27. if (File.Exists(Program.subfolder + @"\vente.json"))
  28. tb_vente = DbUtil.LoadFromJson<DataSet1.tb_venteDataTable>(Program.subfolder + @"\vente.json", tb_vente);
  29. tb_vente.AcceptChanges();
  30. tbventeBindingSource.DataSource = tb_vente;
  31. }
  32. private void splitContainer2_Panel1_Paint(object sender, PaintEventArgs e)
  33. {
  34. }
  35. private void button2_Click(object sender, EventArgs e)
  36. {
  37. decimal puttc, qtt, tva, totht, totttc,calcttcQ,calcttcT,ecart;
  38. ecart = 0.02M;
  39. tbventeBindingSource.MoveFirst();
  40. DataRowView myrow_b = tbventeBindingSource.Current as DataRowView;
  41. DataSet1.tb_venteRow myrow = myrow_b.Row as DataSet1.tb_venteRow;
  42. DataSet1.tb_venteRow oldrow = null;
  43. while ( myrow!=oldrow)
  44. {
  45. Console.WriteLine(myrow.prod_vt.ToString());
  46. puttc = myrow.pu_vt;
  47. qtt = myrow.qtt_vt;
  48. tva = myrow.tva_vt;
  49. totht = myrow.ht_vt;
  50. totttc = Math.Round(myrow.ttc_vt,2);
  51. calcttcQ = Math.Round(qtt * puttc, 2);
  52. calcttcT = Math.Round(totht * (1 + tva / 100), 2);
  53. if (totttc != calcttcQ)
  54. if (Math.Abs(totttc - calcttcQ) > ecart)
  55. {
  56. textErr.Text += string.Format("Err TTC...... ttc={0} calc={1} delta={2}\r\n", totttc, calcttcQ, totttc - calcttcQ);
  57. myrow.ttc_vt = totttc= calcttcQ;
  58. }
  59. if (totttc != calcttcT)
  60. if (Math.Abs(totttc - calcttcT) > ecart)
  61. {
  62. textErr.Text += string.Format("Err TVA...... ttc={0} calc={1} delta={2}\r\n", totttc, calcttcT, totttc - calcttcT);
  63. myrow.ht_vt = Math.Round(totttc / (1 + tva / 100), 2);
  64. }
  65. tbventeBindingSource.MoveNext();
  66. myrow_b = tbventeBindingSource.Current as DataRowView;
  67. oldrow = myrow;
  68. myrow = myrow_b.Row as DataSet1.tb_venteRow;
  69. Application.DoEvents();
  70. }
  71. textErr.Text += "END";
  72. DbUtil.SaveToJson<DataSet1.tb_venteDataTable>(Program.subfolder + @"\vente2.json", tb_vente);
  73. }
  74. }
  75. }