private void dgv_liste_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (dgv_liste.CurrentRow.Cells["id_"].Value != null) { Int32 id = Convert.ToInt32(dgv_liste.CurrentRow.Cells["id_"].Value); if (id > 0) { DocStock f = DocStockBLL.One(id); if (e.ColumnIndex == 5) { if (DialogResult.Yes == Messages.Confirmation(Mots.Supprimer.ToLower())) { if (DocStockBLL.Delete(f)) { DeleteRow(f); Reset(); Messages.Succes(); } } } else { Populate(f); } } } } catch (Exception ex) { Messages.Exception(ex); } }
private void btn_save_Click(object sender, EventArgs e) { Recopie(); if (current.Control()) { if (!current.Update) { DocStock f = DocStockBLL.Save(current); if (f != null ? f.Id > 0 : false) { current.Id = f.Id; current.Update = true; rbtn_entree.Enabled = false; rbtn_sortie.Enabled = false; AddRow(f); Messages.Succes(); } } else { if (DocStockBLL.Update(current)) { UpdateRow(current); Messages.Succes(); } } Reset(); } }
private void LoadGrille() { dgv_liste.Rows.Clear(); string query = "select * from doc_stocks order by id"; List <DocStock> l = DocStockBLL.List(query); foreach (DocStock d in l) { AddRow(d); } Reset(); }
private void btn_delete_Click(object sender, EventArgs e) { if (current != null ? current.Id > 0 : false) { if (DialogResult.Yes == Messages.Confirmation(Mots.Supprimer.ToLower())) { if (DocStockBLL.Delete(current)) { DeleteRow(current); Reset(); Messages.Succes(); } } } }
private void txt_search_TextChanged(object sender, EventArgs e) { string search = txt_search.Text.Trim(); if (search.Length > 0) { dgv_liste.Rows.Clear(); string query = "select * from doc_stocks where reference like '" + search + "%'"; List <DocStock> l = DocStockBLL.List(query); foreach (DocStock f in l) { AddRow(f); } Reset(); } else { LoadGrille(); } }
private void dgv_liste_SelectionChanged(object sender, EventArgs e) { try { if (dgv_liste.Rows.Count > 0) { if (dgv_liste.CurrentRow.Cells["id_"].Value != null) { Int32 id = (Int32)dgv_liste.CurrentRow.Cells["id_"].Value; if (id > 0) { DocStock f = DocStockBLL.One(id); Populate(f); } } } } catch (Exception ex) { Messages.Exception(ex); } }
public static string ReferenceElement(string type) { if (!(type == null || type.Trim().Equals(""))) { String reference = ""; String apercu = type + "/"; if ((int)DateTime.Now.Day > 9) { apercu += (int)DateTime.Now.Day; } if ((int)DateTime.Now.Day < 10) { apercu += ("0" + (int)DateTime.Now.Day); } if ((int)DateTime.Now.Month > 9) { apercu += (int)DateTime.Now.Month; } if ((int)DateTime.Now.Month < 10) { apercu += ("0" + (int)DateTime.Now.Month); } apercu += DateTime.Now.Year.ToString().Substring(2); apercu += "/"; DocStock f = DocStockBLL.One(apercu + "%"); if ((f != null) ? !(f.Reference == null || f.Reference.Trim().Equals("")) : false) { reference = f.Reference; } else { reference = ""; } if (!reference.Trim().Equals("")) { String partieNum = reference.Replace(apercu, ""); if (apercu.Equals(reference.Substring(0, (reference.Length - partieNum.Length)))) { int num = Convert.ToInt16(partieNum); if (Convert.ToString(num + 1).Length > 4) { Messages.ShowErreur("Vous ne pouvez plus ajouter ce type de document"); return(""); } else { for (int i = 0; i < (4 - Convert.ToString(num + 1).Length); i++) { apercu += "0"; } } apercu += Convert.ToString(Convert.ToInt16(partieNum) + 1); } else { for (int i = 0; i < 4 - 1; i++) { apercu += "0"; } apercu += "1"; } } else { for (int i = 0; i < 4 - 1; i++) { apercu += "0"; } apercu += "1"; } return(apercu); } else { Messages.ShowErreur("Le type du document est incorrect!"); } return(null); }