private void LoadGrille() { dgv_liste.Rows.Clear(); string query = "select * from articles order by id"; List <Articles> l = ArticlesBLL.List(query); foreach (Articles a in l) { AddRow(a); } Reset(); }
private void LoadAllArticles() { articles.Clear(); string query = "select * from articles order by id"; articles = ArticlesBLL.List(query); com_article.DisplayMember = "Designation"; com_article.ValueMember = "Id"; com_article.DataSource = new BindingSource(articles, null); foreach (Articles f in articles) { com_article.AutoCompleteCustomSource.Add(f.Designation); } com_article.AutoCompleteMode = AutoCompleteMode.SuggestAppend; com_article.AutoCompleteSource = AutoCompleteSource.CustomSource; }
private void txt_search_famille_TextChanged(object sender, EventArgs e) { string search = txt_search.Text.Trim(); string searchF = txt_search_famille.Text.Trim(); string searchM = txt_search_marque.Text.Trim(); string query = "select a.* from articles a familles_article f on a.famille = f.id where f.reference like '" + searchF + "%' or f.designation like '" + searchF + "%'"; if (searchM.Length > 0) { if (search.Length > 0) { query = "select a.* from articles a inner join familles_article f on a.famille = f.id inner join marque m on a.marque = m.id " + " where a.reference like '" + search + "%' or a.designation like '" + search + "%' or a.description like '" + search + "%' " + " and f.reference like '" + searchF + "%' or f.designation like '" + searchF + "%' or f.description like '" + searchF + "%' " + " and m.reference like '" + searchM + "%' or m.designation like '" + searchM + "%'"; } else { query = "select a.* from articles a inner join familles_article f on a.famille = f.id" + " where a.reference like '" + search + "%' or a.designation like '" + search + "%' or a.description like '" + search + "%' " + " and f.reference like '" + searchF + "%' or f.designation like '" + searchF + "%' or f.description like '" + searchF + "%'"; } } else { if (search.Length > 0) { query = "select a.* from articles a inner join marque m on a.marque = m.id " + " where a.reference like '" + search + "%' or a.designation like '" + search + "%' or a.description like '" + search + "%' " + " and m.reference like '" + searchM + "%' or m.designation like '" + searchM + "%'"; } } dgv_liste.Rows.Clear(); List <Articles> l = ArticlesBLL.List(query); foreach (Articles f in l) { AddRow(f); } Reset(); }
private void LoadCatalogueDetail(string query) { articles = ArticlesBLL.List(query); DataGridViewImageColumn icon_ = new DataGridViewImageColumn(); icon_.Width = 50; //data.Rows.Add(new object[] { c.Id, new Bitmap(c.Article.Image, new Size(16, 16)), c.Article.Designation, c.Prix, c.Quantite, c.Remise, c.PrixTotal, null }); panel_parent.Controls.Clear(); DataGridView data = new DataGridView(); data.AllowUserToAddRows = false; data.SelectionMode = DataGridViewSelectionMode.FullRowSelect; data.AllowUserToDeleteRows = false; data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; data.BackgroundColor = System.Drawing.SystemColors.InactiveCaption; data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; data.Dock = System.Windows.Forms.DockStyle.Fill; data.ReadOnly = true; DataGridViewTextBoxColumn reference_ = new System.Windows.Forms.DataGridViewTextBoxColumn(); reference_.FillWeight = 110.7445F; reference_.HeaderText = Mots.Reference; reference_.Name = "reference_"; reference_.ReadOnly = true; DataGridViewTextBoxColumn designation_ = new System.Windows.Forms.DataGridViewTextBoxColumn(); designation_.FillWeight = 110.7445F; designation_.HeaderText = Mots.Designation; designation_.Name = "designation_"; designation_.ReadOnly = true; DataGridViewTextBoxColumn marque_ = new System.Windows.Forms.DataGridViewTextBoxColumn(); marque_.FillWeight = 110.7445F; marque_.HeaderText = Mots.Marque; marque_.Name = "marque_"; marque_.ReadOnly = true; DataGridViewTextBoxColumn pua_ = new System.Windows.Forms.DataGridViewTextBoxColumn(); pua_.FillWeight = 70.53299F; pua_.HeaderText = Mots.Prix + ".A"; pua_.Name = "pua_"; pua_.ReadOnly = true; DataGridViewTextBoxColumn puv_ = new System.Windows.Forms.DataGridViewTextBoxColumn(); puv_.FillWeight = 70.53299F; puv_.HeaderText = Mots.Prix + ".V"; puv_.Name = "puv_"; puv_.ReadOnly = true; DataGridViewTextBoxColumn stock_ = new System.Windows.Forms.DataGridViewTextBoxColumn(); stock_.FillWeight = 70.53299F; stock_.HeaderText = Mots.Stock; stock_.Name = "stock_"; stock_.ReadOnly = true; DataGridViewTextBoxColumn datesave_ = new System.Windows.Forms.DataGridViewTextBoxColumn(); datesave_.FillWeight = 110.7445F; datesave_.HeaderText = Mots.Date_Creation; datesave_.Name = "datesave_"; datesave_.ReadOnly = true; DataGridViewTextBoxColumn dateupdate_ = new System.Windows.Forms.DataGridViewTextBoxColumn(); dateupdate_.FillWeight = 110.7445F; dateupdate_.HeaderText = "Date Update"; dateupdate_.Name = "dateupdate_"; dateupdate_.ReadOnly = true; DataGridViewTextBoxColumn famille_ = new System.Windows.Forms.DataGridViewTextBoxColumn(); famille_.FillWeight = 110.7445F; famille_.HeaderText = Mots.Famille; famille_.Name = "famille_"; famille_.ReadOnly = true; famille_.Visible = false; data.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { reference_, designation_, marque_, pua_, puv_, stock_, famille_, datesave_, dateupdate_ }); foreach (Articles a in articles) { data.Rows.Add(new object[] { a.Reference, a.Designation, a.Marque, a.Pua, a.Puv, a.Stock, a.Famille != null ? a.Famille.Designation : "", a.DateSave, a.DateUpdate }); } panel_parent.Controls.Add(data); }
private void LoadCatalogueList(string query) { articles = ArticlesBLL.List(query); panel_parent.Controls.Clear(); int i = 0, y = 0; foreach (Articles a in articles) { Panel p = new Panel(); p.BorderStyle = BorderStyle.FixedSingle; p.Size = new Size(777, 160); p.Margin = new Padding(3, 3, 3, 3); p.Location = new Point(12, (13 + y) + (i * 160)); Panel p1 = new Panel(); p1.Size = new Size(140, 118); p1.Margin = new Padding(3, 3, 3, 3); p1.Location = new Point(6, 7); PictureBox b = new PictureBox(); b.BorderStyle = BorderStyle.FixedSingle; if (a.Photos != null ? a.Photos.Count > 0 : false) { string chemin = Chemins.getCheminArticle(a.Id.ToString()); if (System.IO.File.Exists(chemin + a.Photos[0].Nom)) { b.Image = Image.FromFile(chemin + a.Photos[0].Nom); } else { b.Image = global::CATALOGUE_ARTICLE.Properties.Resources.article; } b.Tag = 0; } else { b.Image = global::CATALOGUE_ARTICLE.Properties.Resources.article; } b.SizeMode = PictureBoxSizeMode.StretchImage; b.Size = new Size(140, 118); b.Margin = new Padding(3, 3, 3, 3); b.Location = new Point(0, 0); p1.Controls.Add(b); p.Controls.Add(p1); Panel p2 = new Panel(); p2.BorderStyle = BorderStyle.FixedSingle; p2.Size = new Size(140, 30); p2.Margin = new Padding(3, 3, 3, 3); p2.Location = new Point(6, 127); TextBox ts = new TextBox(); ts.Text = Mots.Stock + " : " + a.Stock; ts.TextAlign = HorizontalAlignment.Center; ts.Size = new Size(80, 20); ts.Margin = new Padding(3, 3, 3, 3); ts.Location = new Point(29, 5); ts.ReadOnly = true; p2.Controls.Add(ts); Button bp = new Button(); bp.Size = new Size(24, 23); bp.Margin = new Padding(3, 3, 3, 3); bp.Location = new Point(3, 4); bp.Image = global::CATALOGUE_ARTICLE.Properties.Resources.prec; bp.Click += delegate(object sender, EventArgs e) { if (b.Tag != null) { int j = (int)b.Tag; if (j > 0) { j--; string chemin = Chemins.getCheminArticle(a.Id.ToString()); if (System.IO.File.Exists(chemin + a.Photos[j].Nom)) { b.Image = Image.FromFile(chemin + a.Photos[j].Nom); } else { b.Image = global::CATALOGUE_ARTICLE.Properties.Resources.ajouter; } b.Tag = j; } } }; p2.Controls.Add(bp); Button bn = new Button(); bn.Size = new Size(24, 23); bn.Margin = new Padding(3, 3, 3, 3); bn.Location = new Point(112, 4); bn.Image = global::CATALOGUE_ARTICLE.Properties.Resources.next; bn.Click += delegate(object sender, EventArgs e) { if (b.Tag != null) { int j = (int)b.Tag; if (j < a.Photos.Count - 1) { j++; string chemin = Chemins.getCheminArticle(a.Id.ToString()); if (System.IO.File.Exists(chemin + a.Photos[0].Nom)) { b.Image = Image.FromFile(chemin + a.Photos[j].Nom); } else { b.Image = global::CATALOGUE_ARTICLE.Properties.Resources.ajouter; } b.Tag = j; } } }; p2.Controls.Add(bn); p.Controls.Add(p2); Label ld = new Label(); ld.Text = Mots.Designation + " : "; ld.Size = new Size(72, 13); ld.Margin = new Padding(3, 0, 3, 0); ld.Location = new Point(152, 7); p.Controls.Add(ld); Label ld_ = new Label(); ld_.Text = a.Designation; ld_.Size = new Size(130, 13); ld_.Margin = new Padding(3, 0, 3, 0); ld_.Location = new Point(236, 7); p.Controls.Add(ld_); Label lm = new Label(); lm.Text = Mots.Marque + " : "; lm.Size = new Size(52, 13); lm.Margin = new Padding(3, 0, 3, 0); lm.Location = new Point(152, 29); p.Controls.Add(lm); Label lm_ = new Label(); if (a.Marque != null ? a.Marque.Id > 0 : false) { lm_.Text = a.Marque.Designation; } lm_.Size = new Size(130, 13); lm_.Margin = new Padding(3, 0, 3, 0); lm_.Location = new Point(236, 29); p.Controls.Add(lm_); Label lc = new Label(); lc.Text = Mots.Date_Creation + " : "; lc.Size = new Size(81, 13); lc.Margin = new Padding(3, 0, 3, 0); lc.Location = new Point(152, 52); p.Controls.Add(lc); Label lc_ = new Label(); lc_.Text = a.DateSave.ToShortDateString(); lc_.Size = new Size(130, 13); lc_.Margin = new Padding(3, 0, 3, 0); lc_.Location = new Point(236, 52); p.Controls.Add(lc_); Label lp = new Label(); lp.Text = Mots.Prix_Vente + " : "; lp.Size = new Size(64, 13); lp.Margin = new Padding(3, 0, 3, 0); lp.Location = new Point(152, 77); p.Controls.Add(lp); Label lp_ = new Label(); lp_.Text = string.Format("{0:#,##0}", a.Puv); lp_.Size = new Size(130, 13); lp_.Margin = new Padding(3, 0, 3, 0); lp_.Location = new Point(236, 77); p.Controls.Add(lp_); Label lf = new Label(); lf.Text = Mots.Famille + " : "; lf.Size = new Size(48, 13); lf.Margin = new Padding(3, 0, 3, 0); lf.Location = new Point(152, 101); p.Controls.Add(lf); Label lf_ = new Label(); lf_.Text = a.Famille != null ? a.Famille.Designation : ""; lf_.Size = new Size(130, 13); lf_.Margin = new Padding(3, 0, 3, 0); lf_.Location = new Point(236, 101); p.Controls.Add(lf_); GroupBox g = new GroupBox(); g.Text = Mots.Description; g.Size = new Size(375, 100); g.Margin = new Padding(3, 3, 3, 3); g.Location = new Point(391, 7); RichTextBox r = new RichTextBox(); r.Text = a.Description; r.Size = new Size(363, 75); r.Margin = new Padding(3, 3, 3, 3); r.Location = new Point(6, 19); r.ReadOnly = true; g.Controls.Add(r); p.Controls.Add(g); panel_parent.Controls.Add(p); i++; y += 5; } }
private void LoadCatalogueMosaique(string query) { articles = ArticlesBLL.List(query); panel_parent.Controls.Clear(); int x = 0, y = 0, x_ = 0, y_ = 0, c = 0; for (int i = 0; i < articles.Count; i++) { Articles a = articles[i]; Panel p = new Panel(); p.BorderStyle = BorderStyle.FixedSingle; p.Margin = new Padding(3, 3, 3, 3); p.Size = new Size(154, 180); p.Location = new Point(x_ + 12, y_ + 4); TextBox t = new TextBox(); t.Text = a.Designation; t.TextAlign = HorizontalAlignment.Center; t.Size = new Size(140, 20); t.Margin = new Padding(3, 3, 3, 3); t.Location = new Point(6, 3); t.ReadOnly = true; p.Controls.Add(t); Panel p1 = new Panel(); p1.Size = new Size(140, 118); p1.Margin = new Padding(3, 3, 3, 3); p1.Location = new Point(6, 26); PictureBox b = new PictureBox(); b.BorderStyle = BorderStyle.FixedSingle; if (a.Photos != null ? a.Photos.Count > 0 : false) { string chemin = Chemins.getCheminArticle(a.Id.ToString()); if (System.IO.File.Exists(chemin + a.Photos[0].Nom)) { b.Image = Image.FromFile(chemin + a.Photos[0].Nom); } else { b.Image = global::CATALOGUE_ARTICLE.Properties.Resources.article; } b.Tag = 0; } else { b.Image = global::CATALOGUE_ARTICLE.Properties.Resources.article; } b.SizeMode = PictureBoxSizeMode.StretchImage; b.Size = new Size(140, 118); b.Margin = new Padding(3, 3, 3, 3); b.Location = new Point(0, 0); ContextMenuStrip co = new System.Windows.Forms.ContextMenuStrip(this.components); ToolStripMenuItem to = new ToolStripMenuItem(); to.Text = Mots.Vue; to.Image = global::CATALOGUE_ARTICLE.Properties.Resources.vue; to.Click += delegate(object sender, EventArgs e) { if (a != null ? a.Id > 0 : false) { new _2ND.Form_View(a).ShowDialog(); } }; co.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { to }); b.ContextMenuStrip = co; p1.Controls.Add(b); p.Controls.Add(p1); Panel p2 = new Panel(); p2.BorderStyle = BorderStyle.FixedSingle; p2.Size = new Size(140, 30); p2.Margin = new Padding(3, 3, 3, 3); p2.Location = new Point(6, 147); TextBox ts = new TextBox(); ts.Text = "Stock : " + a.Stock; ts.TextAlign = HorizontalAlignment.Center; ts.Size = new Size(80, 20); ts.Margin = new Padding(3, 3, 3, 3); ts.Location = new Point(29, 5); ts.ReadOnly = true; p2.Controls.Add(ts); Button bp = new Button(); bp.Size = new Size(24, 23); bp.Margin = new Padding(3, 3, 3, 3); bp.Location = new Point(3, 4); bp.Image = global::CATALOGUE_ARTICLE.Properties.Resources.prec; bp.Click += delegate(object sender, EventArgs e) { if (b.Tag != null) { int j = (int)b.Tag; if (j > 0) { j--; string chemin = Chemins.getCheminArticle(a.Id.ToString()); if (System.IO.File.Exists(chemin + a.Photos[j].Nom)) { b.Image = Image.FromFile(chemin + a.Photos[j].Nom); } else { b.Image = global::CATALOGUE_ARTICLE.Properties.Resources.ajouter; } b.Tag = j; } } }; p2.Controls.Add(bp); Button bn = new Button(); bn.Size = new Size(24, 23); bn.Margin = new Padding(3, 3, 3, 3); bn.Location = new Point(112, 4); bn.Image = global::CATALOGUE_ARTICLE.Properties.Resources.next; bn.Click += delegate(object sender, EventArgs e) { if (b.Tag != null) { int j = (int)b.Tag; if (j < a.Photos.Count - 1) { j++; string chemin = Chemins.getCheminArticle(a.Id.ToString()); if (System.IO.File.Exists(chemin + a.Photos[j].Nom)) { b.Image = Image.FromFile(chemin + a.Photos[j].Nom); } else { b.Image = global::CATALOGUE_ARTICLE.Properties.Resources.ajouter; } b.Tag = j; } } }; p2.Controls.Add(bn); p.Controls.Add(p2); if (c < 3) { x_ += 200; c++; } else { x_ = 0; y_ += 205; c = 0; } panel_parent.Controls.Add(p); } }