public static ArticleCom One(Article article) { try { return ArticleComDao.getOneArticleCom(article); } catch (Exception ex) { throw new Exception("Impossible d'atteindre l'enregistrement", ex); } }
public static List<Article> getListArticle(String query) { NpgsqlConnection con = Connexion.Connection(); try { List<Article> l = new List<Article>(); NpgsqlCommand Lcmd = new NpgsqlCommand(query, con); NpgsqlDataReader lect = Lcmd.ExecuteReader(); if (lect.HasRows) { while (lect.Read()) { Article a = new Article(); a.Id = Convert.ToInt64(lect["id"].ToString()); a.Designation = lect["designation"].ToString(); a.CodeBarre = lect["code_barre"].ToString(); a.RefArt = lect["ref_art"].ToString(); a.Photo1 = lect["photo_1"].ToString(); a.Photo2 = lect["photo_2"].ToString(); a.Photo3 = lect["photo_3"].ToString(); a.MethodeVal = ((lect["methode_val"] != null) ? lect["methode_val"].ToString() : Constantes.FIFO); a.Prix = (Double)((lect["puv"] != null) ? (!lect["puv"].ToString().Trim().Equals("") ? lect["puv"] : 0.0) : 0.0); a.Famille = ((lect["famille"] != null) ? (!lect["famille"].ToString().Trim().Equals("") ? new FamilleArticle(Convert.ToInt64(lect["famille"].ToString())) : new FamilleArticle()) : new FamilleArticle()); a.Plans = BLL.PlanTarifaireBll.Liste("select * from yvs_base_plan_tarifaire_article where actif = true and article = " + a.Id); a.Update = true; l.Add(a); } lect.Close(); } return l; } catch (NpgsqlException e) { Messages.Exception(e); return null; } finally { Connexion.Deconnection(con); } }
public static Article getAjoutArticle(Article 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 ArticleDepot getOneArticleDepot(Article article) { NpgsqlConnection con = Connexion.Connection(); try { String search = "select * from yvs_base_article_depot where article = " + article.Id + ""; NpgsqlCommand Lcmd = new NpgsqlCommand(search, con); NpgsqlDataReader lect = Lcmd.ExecuteReader(); ArticleDepot a = new ArticleDepot(); if (lect.HasRows) { while (lect.Read()) { 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> l = BLL.MouvementStockBll.Liste("select * from yvs_base_mouvement_stock where article = " + a.Article.Id + " and depot = " + a.Depot.Id); foreach (MouvementStock m in l) { if ((m.Mouvement != null) ? (m.Mouvement.Equals(Constantes.MOUV_ENTREE)) : false) { stock += m.Quantite; } else { stock -= m.Quantite; } } a.Stock = stock; a.Update = true; } lect.Close(); } return a; } catch (NpgsqlException e) { Messages.Exception(e); return null; } finally { Connexion.Deconnection(con); } }
private void AjoutDatgridArt(Article artDtG, int qte) { string[] row = new string[] { artDtG.Designation, (artDtG.Prix).ToString(), qte.ToString(), (qte * artDtG.Prix).ToString() }; dataGridView1.Rows.Add(row); }
//modification des boutons des articles private void ModifButton(Button ctl, Article cli, Label lbl) { lbl.Visible = true; lbl.Text = cli.Designation; ctl.BackgroundImage = (System.Drawing.Image)cli.Image; ctl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; ctl.Text = ""; ctl.UseVisualStyleBackColor = true; ctl.Visible = true; ctl.Font = new System.Drawing.Font("Trebuchet MS", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); ctl.Click += delegate(object sender, EventArgs e) { contenu = new Contenu(); if ((fact != null) ? fact.Id < 1 : true) { Messages.ShowErreur("Vous devez dabord enregsitrer la facture!"); return; } else { //sauvegarde nouveau contenu contenu.Article = BLL.ArticleComBll.One(cli); contenu.Facture = fact; contenu.Prix = cli.Prix; contenu.New_ = true; //qté article Form_Caisse_Quantite f = new Form_Caisse_Quantite(this); f.Text = "Quantité de: " + cli.Designation; f.ShowDialog(); if ((contenu.Quantite != 0) || (contenu.Quantite == null)) { ctl.BackColor = Color.DarkGray; ctl.Enabled = false; btnReglement.Enabled = true; contenu.PrixTotal = contenu.Quantite * contenu.Prix; //SommSR.Text = Convert.ToString(Convert.ToDouble(SommSR.Text) + contenu.PrixTotal); } } //contenu.Update=true; if (contenu.Control()) { if (!contenu.Update) { contenu.DateContenu = DateTime.Now; Contenu c_ = new BLL.ContenuBll(contenu).Insert(); if ((c_ != null) ? c_.Id > 0 : false) { contenu.Id = c_.Id; contenu.Update = true; fact.Contenus.Add(contenu); AddRowContenu(contenu); contenu.Update = true; Messages.Succes(); } } else { if (new BLL.ContenuBll(contenu).Update()) { contenu.Update = true; fact.Contenus[fact.Contenus.FindIndex(x => x.Id == contenu.Id)] = contenu; UpdateRowContenu(contenu); contenu.Update = true; Messages.Succes(); } } Utils.MontantTotalDoc(fact); configFacture(fact); UpdateCurrentFacture(fact); } }; }
public ArticleBll(Article unArticle) { article = unArticle; }
public static ArticleCom getOneArticleCom(Article article) { NpgsqlConnection con = Connexion.Connection(); try { String search = "select * from yvs_com_article where 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 bool getUpdateArticle(Article 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); } }