Exemple #1
0
        public static List <MouvementStock> listMouvementStock(string query)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                NpgsqlCommand         Lcmd = new NpgsqlCommand(query, con);
                NpgsqlDataReader      lect = Lcmd.ExecuteReader();
                List <MouvementStock> l    = new List <MouvementStock>();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        MouvementStock y = oneMouvementStock((Int32)((lect["id"] != null) ? (!lect["id"].ToString().Trim().Equals("") ? lect["id"] : 0) : 0));
                        l.Add(y);
                    }
                }
                return(l);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Exemple #2
0
        public static MouvementStock oneMouvementStock(Int32 id)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                String           search = "select * from mouvements_stock where id = " + id;
                NpgsqlCommand    Lcmd   = new NpgsqlCommand(search, con);
                NpgsqlDataReader lect   = Lcmd.ExecuteReader();
                MouvementStock   y      = new MouvementStock();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        y.Id       = id;
                        y.Entree   = (Boolean)((lect["entree"] != null) ? (!lect["entree"].ToString().Trim().Equals("") ? lect["entree"] : false) : false);
                        y.Quantite = (Double)((lect["quantite"] != null) ? (!lect["quantite"].ToString().Trim().Equals("") ? lect["quantite"] : 0) : 0);
                        y.Date     = (DateTime)((lect["date_save"] != null) ? (!lect["date_save"].ToString().Trim().Equals("") ? lect["date_save"] : DateTime.Now) : DateTime.Now);
                        y.Article  = BLL.ArticlesBLL.One((Int32)((lect["article"] != null) ? (!lect["article"].ToString().Trim().Equals("") ? lect["article"] : 0) : 0));
                        y.Contenu  = BLL.ContenuStockBLL.One((Int32)((lect["contenu"] != null) ? (!lect["contenu"].ToString().Trim().Equals("") ? lect["contenu"] : 0) : 0));
                        y.Update   = true;
                    }
                }
                return(y);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Exemple #3
0
        public static Int32 currentMouvementStock(MouvementStock f)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                String           search = "select * from mouvements_stock where contenu = " + f.Contenu.Id + " and article = " + f.Article.Id + "";
                NpgsqlCommand    Lcmd   = new NpgsqlCommand(search, con);
                NpgsqlDataReader lect   = Lcmd.ExecuteReader();
                Int32            id     = new Int32();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        id = (Int32)((lect["id"] != null) ? (!lect["id"].ToString().Trim().Equals("") ? lect["id"] : 0) : 0);
                    }
                }
                return(id);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(0);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Exemple #4
0
 public static bool Delete(MouvementStock y)
 {
     try
     {
         return(MouvementStockDAO.deleteMouvementStock(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Suppression Impossible", ex);
     }
 }
Exemple #5
0
 public static bool Update(MouvementStock y)
 {
     try
     {
         return(MouvementStockDAO.updateMouvementStock(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Modification Impossible", ex);
     }
 }
Exemple #6
0
 public static Int32 Current(MouvementStock y)
 {
     try
     {
         return(MouvementStockDAO.currentMouvementStock(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Retour Impossible", ex);
     }
 }
Exemple #7
0
 public static MouvementStock Save(MouvementStock y)
 {
     try
     {
         return(MouvementStockDAO.saveMouvementStock(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Insertion Impossible", ex);
     }
 }
        public static List <MouvementStock> getListMouvementStock(String query)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                List <MouvementStock> l    = new List <MouvementStock>();
                NpgsqlCommand         Lcmd = new NpgsqlCommand(query, con);
                NpgsqlDataReader      lect = Lcmd.ExecuteReader();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        MouvementStock a = new MouvementStock();
                        a.Id      = Convert.ToInt64(lect["id"].ToString());
                        a.Article = (lect["article"] != null
                            ? (!lect["article"].ToString().Trim().Equals("")
                            ? BLL.ArticleBll.One(Convert.ToInt64(lect["article"].ToString()))
                            : new Article())
                            : new Article());
                        a.Mouvement = lect["mouvement"].ToString();
                        a.Quantite  = (Double)((lect["quantite"] != null) ? (!lect["quantite"].ToString().Trim().Equals("") ? lect["quantite"] : 0) : 0);
                        a.DateDoc   = (DateTime)((lect["date_doc"] != null) ? (!lect["date_doc"].ToString().Trim().Equals("") ? lect["date_doc"] : DateTime.Now) : DateTime.Now);
                        a.Depot     = (lect["depot"] != null
                            ? (!lect["depot"].ToString().Trim().Equals("")
                            ? new Depot(Convert.ToInt64(lect["depot"].ToString()))
                            : new Depot())
                            : new Depot());
                        l.Add(a);
                    }
                    lect.Close();
                }
                return(l);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
        public static MouvementStock getOneMouvementStock(long id)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                String           search = "select * from yvs_base_mouvement_stock where id = " + id + "";
                NpgsqlCommand    Lcmd   = new NpgsqlCommand(search, con);
                NpgsqlDataReader lect   = Lcmd.ExecuteReader();
                MouvementStock   a      = new MouvementStock();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        a.Id      = Convert.ToInt64(lect["id"].ToString());
                        a.Article = (lect["article"] != null
                            ? (!lect["article"].ToString().Trim().Equals("")
                            ? BLL.ArticleBll.One(Convert.ToInt64(lect["article"].ToString()))
                            : new Article())
                            : new Article());
                        a.Mouvement = lect["mouvement"].ToString();
                        a.Quantite  = (Double)((lect["quantite"] != null) ? (!lect["quantite"].ToString().Trim().Equals("") ? lect["quantite"] : 0) : 0);
                        a.DateDoc   = (DateTime)((lect["date_doc"] != null) ? (!lect["date_doc"].ToString().Trim().Equals("") ? lect["date_doc"] : DateTime.Now) : DateTime.Now);
                        a.Depot     = (lect["depot"] != null
                            ? (!lect["depot"].ToString().Trim().Equals("")
                            ? new Depot(Convert.ToInt64(lect["depot"].ToString()))
                            : new Depot())
                            : new Depot());
                    }
                    lect.Close();
                }
                return(a);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
        public static bool getUpdateMouvementStock(MouvementStock a)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        update = "";
                NpgsqlCommand Ucmd   = new NpgsqlCommand(update, con);
                Ucmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception e)
            {
                Messages.Exception(e);
                return(false);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Exemple #11
0
        public static bool updateMouvementStock(MouvementStock f)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        update = "update mouvements_stock set quantite =" + f.Quantite + " , article =" + f.Article.Id + " , contenu =" + f.Contenu.Id + " where id = " + f.Id;
                NpgsqlCommand cmd    = new NpgsqlCommand(update, con);
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(false);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
        public static MouvementStock getAjoutMouvementStock(MouvementStock a)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        insert = "";
                NpgsqlCommand cmd    = new NpgsqlCommand(insert, con);
                cmd.ExecuteNonQuery();
                a.Id = getCurrent();
                return(a);
            }
            catch
            {
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Exemple #13
0
        public static bool  deleteMouvementStock(MouvementStock f)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        delete = "delete from mouvements_stock where id = " + f.Id;
                NpgsqlCommand cmd    = new NpgsqlCommand(delete, con);
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(false);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Exemple #14
0
        public static MouvementStock saveMouvementStock(MouvementStock f)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        insert = "insert into mouvements_stock (entree, quantite, article, contenu) values (" + f.Entree + "," + f.Quantite + "," + f.Article.Id + "," + f.Contenu.Id + ")";
                NpgsqlCommand cmd    = new NpgsqlCommand(insert, con);
                cmd.ExecuteNonQuery();
                f.Id = currentMouvementStock(f);
                return(f);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
 private void AddRowApprovision(MouvementStock m)
 {
     dgv_approvision.Rows.Add(new object[] { m.Id, m.Article.Designation, m.Quantite, m.Image });
 }
Exemple #16
0
 private void AddRow(MouvementStock m)
 {
     dgv_liste.Rows.Add(new object[] { m.Id, m.Article != null ? m.Article.Designation : "", m.Quantite > -1 ? m.Quantite : -(m.Quantite), m.Date, m.Icon });
 }
Exemple #17
0
 public MouvementStockBll(MouvementStock unMouvementStock)
 {
     mouv = unMouvementStock;
 }