コード例 #1
0
 public static PieceCaisse getAjoutPieceCaisse(PieceCaisse a)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         string insert = "insert into yvs_base_piece_tresorerie"
                         + "(libelle, description, date_piece, mouvement, montant, id_externe, table_externe, societe, mode_paiement,"
                         + "on_compte, num_piece, num_ref, statut)"
                         + "values ('" + a.Libelle + "', '" + a.Description + "', '" + a.DatePiece + "', '" + Constantes.MOUV_ENTREE + "', " + a.Montant + ","
                         + "" + a.IdExterne + ", '" + a.TableEterne + "', " + Constantes.Societe.Id + ", " + a.Mode.Id + ", " + a.OnCompte + ", '" + a.NumPiece + "',"
                         + "'" + a.NumRef + "', '" + a.Statut + "')";
         NpgsqlCommand cmd = new NpgsqlCommand(insert, con);
         cmd.ExecuteNonQuery();
         a.Id = getCurrent(a);
         return a;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
コード例 #2
0
 public static List<PieceCaisse> getListPieceCaisse(String query)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         List<PieceCaisse> l = new List<PieceCaisse>();
         NpgsqlCommand Lcmd = new NpgsqlCommand(query, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 PieceCaisse a = new PieceCaisse();
                 a.Id = Convert.ToInt64(lect["id"].ToString());
                 a.Description = lect["description"].ToString();
                 a.Libelle = lect["libelle"].ToString();
                 a.Montant = (Double)((lect["montant"] != null) ? ((!lect["montant"].ToString().Trim().Equals("")) ? lect["montant"] : 0) : 0);
                 a.IdExterne = (Int64)((lect["id_externe"] != null) ? ((!lect["id_externe"].ToString().Trim().Equals("")) ? lect["id_externe"] : 0) : 0);
                 a.DatePiece = (DateTime)((lect["date_piece"] != null) ? ((!lect["date_piece"].ToString().Trim().Equals("")) ? lect["date_piece"] : DateTime.Now) : DateTime.Now);
                 a.Mouvement = lect["mouvement"].ToString();
                 a.NumPiece = lect["num_piece"].ToString();
                 a.NumRef = lect["num_ref"].ToString();
                 a.Statut = lect["statut"].ToString();
                 a.TableEterne = lect["table_externe"].ToString();
                 a.Mode = (lect["mode_paiement"] != null
                     ? (!lect["mode_paiement"].ToString().Trim().Equals("")
                     ? BLL.ModePaiementBll.One(Convert.ToInt64(lect["mode_paiement"].ToString()))
                     : new ModePaiement())
                     : new ModePaiement());
                 a.Update = true;
                 l.Add(a);
             }
             lect.Close();
         }
         return l;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
コード例 #3
0
 private void AddRowReglement(PieceCaisse p)
 {
     AddRowReglement(dgv_reglement, p);
 }
コード例 #4
0
 private void AddRowReglement(DataGridView data, PieceCaisse p)
 {
     if (p != null)
     {
         data.Rows.Add(new object[] { p.Id, p.IdExterne, p.DatePiece, p.Montant });
     }
 }
コード例 #5
0
 private void UpdateRowReglement(PieceCaisse c)
 {
     UpdateRowReglement(dgv_reglement, c);
 }
コード例 #6
0
 private void UpdateRowReglement(DataGridView data, PieceCaisse f)
 {
     data.Rows.RemoveAt(Utils.GetRowData(data, f.Id));
     AddRowReglement(data, f);
 }
コード例 #7
0
 private PieceCaisse RecopieViewReglement(Mensualite m, double montant)
 {
     PieceCaisse p = new PieceCaisse();
     p.DatePiece = DateTime.Now;
     p.IdExterne = m.Id;
     p.TableEterne = Constantes.TABLE_EXTERNE_PIECE;
     p.Libelle = "Reglement Facture Vente";
     p.Montant = montant;
     p.Mouvement = Constantes.MOUV_ENTREE;
     p.Mode = reglement.Mode;
     p.OnCompte = reglement.OnCompte;
     p.NumRef = Utils.GenererReference(Constantes.DOC_PIECE);
     p.Statut = Constantes.ETAT_REGLE;
     return p;
 }
コード例 #8
0
 public PieceCaisseBll(PieceCaisse unPieceCaisse)
 {
     piece = unPieceCaisse;
 }
コード例 #9
0
 private static long getCurrent(PieceCaisse a)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         String search = "select id from yvs_base_piece_tresorerie where id_externe = " + a.IdExterne + " and table_externe = '" + a.TableEterne + "' order by id desc limit 1";
         NpgsqlCommand Lcmd = new NpgsqlCommand(search, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         long id = 0;
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 id = Convert.ToInt64(lect["id"].ToString());
             }
             lect.Close();
         }
         return id;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return 0;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
コード例 #10
0
 public static bool getUpdatePieceCaisse(PieceCaisse a)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         string update = "update yvs_base_piece_tresorerie set"
                         + " libelle = '" + a.Libelle + "', description = '" + a.Description + "', date_piece = '" + a.DatePiece + "', montant = " + a.Montant + ","
                         + " mode_paiement = " + a.Mode.Id + ", on_compte = " + a.OnCompte + ", num_piece = '" + a.NumPiece + "'"
                         + " num_ref = '" + a.NumRef + "', statut = '" + a.Statut + "' where id = " + a.Id;
         NpgsqlCommand Ucmd = new NpgsqlCommand(update, con);
         Ucmd.ExecuteNonQuery();
         return true;
     }
     catch (Exception e)
     {
         Messages.Exception(e);
         return false;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
コード例 #11
0
 public static PieceCaisse getOnePieceCaisse(long id)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         String search = "select * from yvs_base_piece_tresorerie where id = " + id + "";
         NpgsqlCommand Lcmd = new NpgsqlCommand(search, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         PieceCaisse a = new PieceCaisse();
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 a.Id = Convert.ToInt64(lect["id"].ToString());
                 a.Description = lect["description"].ToString();
                 a.Libelle = lect["libelle"].ToString();
                 a.Montant = (Double)((lect["montant"] != null) ? ((!lect["montant"].ToString().Trim().Equals("")) ? lect["montant"] : 0) : 0);
                 a.IdExterne = (Int64)((lect["id_externe"] != null) ? ((!lect["id_externe"].ToString().Trim().Equals("")) ? lect["id_externe"] : 0) : 0);
                 a.DatePiece = (DateTime)((lect["date_piece"] != null) ? ((!lect["date_piece"].ToString().Trim().Equals("")) ? lect["date_piece"] : DateTime.Now) : DateTime.Now);
                 a.Mouvement = lect["mouvement"].ToString();
                 a.NumPiece = lect["num_piece"].ToString();
                 a.NumRef = lect["num_ref"].ToString();
                 a.Statut = lect["statut"].ToString();
                 a.TableEterne = lect["table_externe"].ToString();
                 a.Mode = (lect["mode_paiement"] != null
                     ? (!lect["mode_paiement"].ToString().Trim().Equals("")
                     ? BLL.ModePaiementBll.One(Convert.ToInt64(lect["mode_paiement"].ToString()))
                     : new ModePaiement())
                     : new ModePaiement());
                 a.Update = true;
             }
             lect.Close();
         }
         return a;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
コード例 #12
0
 private void configReglement(PieceCaisse p)
 {
     if ((p != null) ? p.Id > 0 : false)
     {
         txt_numPiece.Text = p.NumPiece;
         txt_montant.Value = (Decimal)p.Montant;
         if (p.OnCompte)
         {
             rbtn_yes.Checked = true;
         }
         else
         {
             rbtn_no.Checked = true;
         }
     }
 }
コード例 #13
0
 private void AddRowReglement(PieceCaisse m)
 {
     dgv_reglement.Rows.Add(new object[] { m.Id, m.DatePiece, m.Montant, m.Mode.TypePaiement });
 }