private void buttonUpdate_Click(object sender, EventArgs e) { try { if (this.dataGridViewVaccin.CurrentCell != null) { int RowOldIndex = this.dataGridViewVaccin.CurrentCell.OwningRow.Index; //Sauvegarde de l'ancien index de ligne int CellOldIndex = this.dataGridViewVaccin.CurrentCell.ColumnIndex; BO.Vaccins vaccin = (BO.Vaccins) this.dataGridViewVaccin.CurrentCell.OwningRow.DataBoundItem; BLL.VaccinsMgr.AddQte(vaccin, (int)this.numericUpDownQte.Value); UpdateContent(); //Permet de retourner a la ligne selectionner if (this.dataGridViewVaccin.RowCount > RowOldIndex && this.dataGridViewVaccin.ColumnCount > CellOldIndex) { this.dataGridViewVaccin.CurrentCell = this.dataGridViewVaccin.Rows[RowOldIndex].Cells[CellOldIndex]; } } } catch (Exception ex) { MessageBox.Show(ex.Message, GUI.Lang.FORM_DEFAULT_ERROR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Creer la ligne de consultation passé en params /// </summary> /// <param name="lignesConsultations"></param> /// <returns></returns> public static BO.LignesConsultations Create(BO.LignesConsultations lignesConsultations) { if (lignesConsultations.Consultation == null) { throw new Exception(Lang.LIGNESCONSULTATION_CANT_CREATE_WITHOUT_CONSULTATION); } if (lignesConsultations.Barem == null) { throw new Exception(Lang.LIGNESCONSULTATION_CANT_CREATE_WITHOUT_BAREM); } switch (lignesConsultations.Barem.TypeActe) { case "VACC": BO.Vaccins vacc = lignesConsultations.Barem.Vaccin; if (vacc != null) { VaccinsMgr.Update(vacc, vacc.QuantiteStock--); } break; case "TATO": AnimauxMgr.Update(lignesConsultations.Consultation.Animal); break; } return(DAL.LignesConsultations.Create(lignesConsultations)); }
/// <summary> /// Met a jour le vaccin passé en params a condition que la qte > a la quantite en stock /// </summary> /// <param name="code"></param> /// <param name="Qte"></param> /// <returns></returns> public static bool AddQte(BO.Vaccins vacc, Int32 Qte) { if (vacc.QuantiteStock < Qte) { vacc.QuantiteStock = Qte; return(DAL.Vaccins.Update(vacc)); } else { throw new Exception(Lang.VACCINS_QUANTITY_NEED_BE_SUPP); } }
public static bool Update(BO.Vaccins vac) { try { SqlConnection cnx = DAL.SqlConnexion.OpenConnexion(); var query = @"UPDATE Vaccins SET QuantiteStock=@qte WHERE CodeVaccin=@code"; int rowNb = cnx.Execute(query, new { code = vac.CodeVaccin, qte = vac.QuantiteStock }); SqlConnexion.CloseConnexion(cnx); return(rowNb > 0); } catch (Exception e) { throw e; } }
/// <summary> /// /// </summary> /// <param name="code"></param> /// <param name="Qte"></param> /// <returns></returns> public static bool Update(BO.Vaccins vacc, Int32 Qte) { vacc.QuantiteStock = Qte; return(DAL.Vaccins.Update(vacc)); }