public async Task <IActionResult> Put(int id, [FromBody] BonLivraisonViewModel bonLivraison) { if (ModelState.IsValid) { try { BonLivraison _bonLivraison = Mapper.Map <BonLivraison>(bonLivraison); Demandes _demande = _unitOfWork.Demandes.GetSingleOrDefault(e => e.Id == bonLivraison.DemandesId); ApplicationUser controleur = await _accountManager.GetUserByIdAsync(bonLivraison.ControleurId); _bonLivraison.Controleur = controleur; _bonLivraison.Demandes = _demande; //_bonLivraison.Name = _bonLivraison.Name.ToUpper (); _unitOfWork.BonLivraison.Update(_bonLivraison); await _unitOfWork.SaveChangesAsync(); return(Ok("OK")); } catch (Exception ex) { return(BadRequest(ex.Data)); } } else { return(BadRequest(ModelState)); } }
public async Task <IActionResult> Delete(int id) { if (ModelState.IsValid) { try { BonLivraison _bonLivraison = _unitOfWork.BonLivraison.GetSingleOrDefault(e => e.Id == id); if (_bonLivraison != null) { _unitOfWork.BonLivraison.Remove(_bonLivraison); await _unitOfWork.SaveChangesAsync(); return(Ok("OK")); } else { return(BadRequest()); } } catch (Exception ex) { return(BadRequest(ex.Data)); } } else { return(BadRequest(ModelState)); } }
/// <summary> /// Create delivery note from invoice /// </summary> /// <param name="mode">Creating mode</param> /// <returns>Created Delivery Note</returns> public BonLivraison CreateBonLivraison(CreateModes mode) { if (EnsureIsSavedSubmit() && IsReturn == false) { if (this.RefBonLivraison.IsValideAndSubmited <BonLivraison>()) { var res = MessageBox.Show($"Facture déja fait référencer a un Bon de livraison #{this.RefBonLivraison.GetObject("BonLivraison")?.Name}! Annuler ce document avant de continuer!", "Confirmation", MessageBoxButton.OK); return(null); } BonLivraison f = new BonLivraison(); f = DataHelpers.MapProperties(f, this) as BonLivraison; f.DateBL = DateTime.Now; f.RefFacture = this.Id; foreach (var item in this.ArticleFacture) { var line = new LigneEcritureStock(); line = DataHelpers.MapProperties(line, item) as LigneEcritureStock; f.Articles.Add(line); } f = this.MapRefsTo(f) as BonLivraison; f = CreateModesHandler.Handle(f, mode) as BonLivraison; return(f); } return(null); }
private void button1_Click(object sender, EventArgs e) { try { data = new SqlDataAdapter("select * from Livraison where CodeLivr=" + textBox8.Text, con); data.Fill(set, "Livraison"); data = new SqlDataAdapter("select cha.* from Charge_Commande as cha inner join Chargement as ch on ch.CodeChargement=cha.CodeChargement inner Join Livraison as l on l.CodeChargement=ch.CodeChargement where l.CodeLivr=" + textBox8.Text, con); data.Fill(set, "Charge_Commande"); data = new SqlDataAdapter("select ch.* from Chargement as ch inner Join Livraison as l on l.CodeChargement=ch.CodeChargement where l.CodeLivr=" + textBox8.Text, con); data.Fill(set, "Chargement"); data = new SqlDataAdapter("select chau.* from chauffeur as chau inner join Chargement as ch on chau.CodeChauffeur=ch.CodeChauf inner Join Livraison as l on l.CodeChargement=ch.CodeChargement where l.CodeLivr=" + textBox8.Text, con); data.Fill(set, "Chauffeur"); data = new SqlDataAdapter("select C.* from Commande as C inner Join Charge_Commande as char on C.Codecommande=char.CodeCommande inner join Chargement as ch on ch.CodeChargement=char.CodeChargement inner Join Livraison as l on l.CodeChargement=ch.CodeChargement where l.CodeLivr=" + textBox8.Text, con); data.Fill(set, "Commande"); data = new SqlDataAdapter("select Cl.* from Client as Cl inner Join Commande as C on C.CodeClient=Cl.Codeclient inner Join Charge_Commande as char on C.Codecommande=char.CodeCommande inner join Chargement as ch on ch.CodeChargement=char.CodeChargement inner Join Livraison as l on l.CodeChargement=ch.CodeChargement where l.CodeLivr=" + textBox8.Text, con); data.Fill(set, "Client"); BonLivraison b = new BonLivraison(); b.SetDataSource(set); Report_Viewer_Form r = new Report_Viewer_Form(); r.Text = "Bon de Livraison N° " + textBox8.Text; r.crystalReportViewer1.ReportSource = b; r.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void LivrerCommande_Print(int CodeCommande) { try { int CodeTournee = int.Parse(ExecuteScalar("select numTournee from Commande where Codecommande = '" + CodeCommande + "'").ToString()); int CodeChargement = int.Parse(ExecuteScalar("select CodeChargement from Chargement where CodeTournee = '" + CodeTournee + "'").ToString()); ExecuteQuery("insert into Livraison(CodeChargement) values('" + CodeChargement + "')"); int CodeLivraison = int.Parse(ExecuteScalar("select IDENT_CURRENT('Livraison')").ToString()); DataSet Data_Set = getBonLivraison(CodeLivraison); BonLivraison reportCommande = new BonLivraison(); reportCommande.SetDataSource(Data_Set); Report_Viewer_Form frm = new Report_Viewer_Form(); frm.Text = "Bon De Livraison N°: " + CodeLivraison + " pour la commande N°: " + CodeCommande; frm.crystalReportViewer1.ReportSource = reportCommande; frm.Show(); } catch (Exception Err) { MessageBox.Show(Err.Message, "Un Erreur est survenue", MessageBoxButtons.OK, MessageBoxIcon.Error); } }