public static ArticleDepot getAjoutArticleDepot(ArticleDepot 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); } }
public static List<ArticleDepot> getListArticleDepot(String query) { NpgsqlConnection con = Connexion.Connection(); try { List<ArticleDepot> l = new List<ArticleDepot>(); NpgsqlCommand Lcmd = new NpgsqlCommand(query, con); NpgsqlDataReader lect = Lcmd.ExecuteReader(); if (lect.HasRows) { while (lect.Read()) { ArticleDepot a = new ArticleDepot(); a.Id = Convert.ToInt64(lect["id"].ToString()); a.Depot = (lect["depot"] != null ? (!lect["depot"].ToString().Trim().Equals("") ? new Depot(Convert.ToInt64(lect["depot"].ToString())) : new Depot()) : new Depot()); a.Article = (lect["article"] != null ? (!lect["article"].ToString().Trim().Equals("") ? BLL.ArticleBll.One(Convert.ToInt64(lect["article"].ToString())) : new Article()) : new Article()); a.Designation = a.Article.Designation; a.RefArt = a.Article.RefArt; a.CodeBarre = a.Article.CodeBarre; a.ModeAppro = lect["mode_appro"].ToString().Trim(); a.ModeReappro = lect["mode_reappro"].ToString().Trim(); a.StockAlert = (Double)((lect["stock_alert"] != null) ? (!lect["stock_alert"].ToString().Trim().Equals("") ? lect["stock_alert"] : 0.0) : 0.0); a.StockMax = (Double)((lect["stock_max"] != null) ? (!lect["stock_max"].ToString().Trim().Equals("") ? lect["stock_max"] : 0.0) : 0.0); a.StockMin = (Double)((lect["stock_min"] != null) ? (!lect["stock_min"].ToString().Trim().Equals("") ? lect["stock_min"] : 0.0) : 0.0); //Calcul du stock de l'article dans le depot double stock = 0; List<MouvementStock> y = BLL.MouvementStockBll.Liste("select * from yvs_base_mouvement_stock where article = " + a.Article.Id + " and depot = " + a.Depot.Id); foreach (MouvementStock m in y) { if ((m.Mouvement != null) ? (m.Mouvement.Equals(Constantes.MOUV_ENTREE)) : false) { stock += m.Quantite; } else { stock -= m.Quantite; } } a.Stock = stock; a.Update = true; l.Add(a); } lect.Close(); } return l; } catch (NpgsqlException e) { Messages.Exception(e); return null; } finally { Connexion.Deconnection(con); } }
public static bool getUpdateArticleDepot(ArticleDepot 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); } }
public static ArticleCom getOneArticleCom(ArticleDepot article) { NpgsqlConnection con = Connexion.Connection(); try { String search = "select * from yvs_com_article where article = " + article.Article.Id + " limit 1"; NpgsqlCommand Lcmd = new NpgsqlCommand(search, con); NpgsqlDataReader lect = Lcmd.ExecuteReader(); ArticleCom a = new ArticleCom(); 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.Designation = a.Article.Designation; a.RefArt = a.Article.RefArt; a.CodeBarre = a.Article.CodeBarre; a.Image = a.Article.Image; } a.Stock = article.Stock; a.Update = true; lect.Close(); } return a; } catch (NpgsqlException e) { Messages.Exception(e); return null; } finally { Connexion.Deconnection(con); } }
public static ArticleCom One(ArticleDepot article) { try { return ArticleComDao.getOneArticleCom(article); } catch (Exception ex) { throw new Exception("Impossible d'atteindre l'enregistrement", ex); } }
public ArticleDepotBll(ArticleDepot unArticleDepot) { article = unArticleDepot; }