public ActionResult AddStudent(Student s) { AdmissionRecord rec = new AdmissionRecord { AdmissionDate = DateTime.Today, PreviousSchool = "", RollNumber = s.RollNumber, Status = true }; try { db.Students.Add(s); db.AdmissionRecords.Add(rec); db.SaveChanges(); }catch (Exception e) { if (db.AdmissionRecords.Find(rec.RecordID) != null) { db.AdmissionRecords.Remove(db.AdmissionRecords.Find(rec.RecordID)); } ViewBag.ErrorMessage = "Student couldn't be added\n" + e.Data; return(View("Error")); } return(RedirectToAction("ViewStudent", new { RollNumber = s.RollNumber })); }
public Facture(AdmissionRecord myfacture, string ladescitem, string lemontant) { InitializeComponent(); string nomClient = myfacture.Patient.FirstName.TrimEnd() + " " + myfacture.Patient.LastName.TrimEnd(); LabelNomPatient.Content = nomClient; LabelAddressPatient.Content = myfacture.Patient.Address; LabelVillePatient.Content = myfacture.Patient.City; lableDescFacture.Content = ladescitem; LabelMontantFacture.Content = lemontant; }
// ****************************************************// // Trait le congé d'un patient // // ****************************************************// private void Button_Click(object sender, RoutedEventArgs e) // Congé Patient { AdmissionRecord MyPatienConge = new AdmissionRecord(); MyPatienConge = (AdmissionRecord)ListePatientHositaliser.SelectedItem; try { context.CongePatient(MyPatienConge.AdmissionID, MyPatienConge.BedNumber); MessageBox.Show("Le congé du patient a été traité"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { var query = from p in context.AdmissionRecords where p.DischargeDate == null select p; ListePatientHositaliser.DataContext = query; } }
// Bouton re-impression facture private void Button_Click_2(object sender, RoutedEventArgs e) { AdmissionRecord mySelectedAfacture = (AdmissionRecord)ListAFactureTermine.SelectedItem; String DescItem = ""; String MontantFacture = "0.00"; String DescTV = ""; String DescTel = ""; String DescTarif = " tarif chambre Standard"; TimeSpan difference = new TimeSpan(); decimal extTelRate = 0; decimal extTVRate = 0; decimal extRoomRate = 0; decimal Total = 0; difference = (TimeSpan)(mySelectedAfacture.DischargeDate - mySelectedAfacture.AdmitDate); int totjours = Convert.ToInt32(difference.TotalDays); if (mySelectedAfacture.Extra.Phone == true) { decimal telrate = 0; var gettelrate = (from p in context.Extra_Rates where p.AmenityName == "PHONE" select p).First().DailyCost; DescTel = " - Option téléphone - " + gettelrate + "$ par jours "; telrate = Convert.ToDecimal(gettelrate); extTelRate = totjours * telrate; } if (mySelectedAfacture.Extra.TV == true) { decimal tvrate = 0; var gettvrate = (from p in context.Extra_Rates where p.AmenityName == "TV" select p).First().DailyCost; DescTV = " - Option télévision - " + gettvrate + "$ par jours "; tvrate = Convert.ToDecimal(gettvrate); extTVRate = totjours * tvrate; } if (mySelectedAfacture.Extra.SemiPriivate == true) { decimal roomrate = 0; var getroomrate = (from p in context.Extra_Rates where p.AmenityName == "SEMI" select p).First().DailyCost; roomrate = Convert.ToDecimal(getroomrate); extRoomRate = roomrate * totjours; DescTarif = " tarif chambre Semi-Privé " + getroomrate + "$"; } if (mySelectedAfacture.Extra.Private == true) { decimal roomrate = 0; var getroomrate = (from p in context.Extra_Rates where p.AmenityName == "PRIVÉ" select p).First().DailyCost; roomrate = Convert.ToDecimal(getroomrate); extRoomRate = roomrate * totjours; DescTarif = " tarif chambre Privé " + getroomrate + "$"; } DescItem = "Hospitalisation de " + totjours.ToString() + " jours" + DescTel + DescTV + DescTarif; Total = extRoomRate + extTelRate + extTVRate; MontantFacture = Total.ToString() + "$"; Facture myfacture = new Facture(mySelectedAfacture, DescItem, MontantFacture); myfacture.ShowDialog(); }
// Bouton genere Facture private void Button_Click_1(object sender, RoutedEventArgs e) { AdmissionRecord mySelectedAfacture = (AdmissionRecord)ListAFacture.SelectedItem; String DescItem = ""; String MontantFacture = "0.00"; String DescTV = ""; String DescTel = ""; String DescTarif = " tarif chambre Standard"; decimal extTelRate = 0; decimal extTVRate = 0; decimal extRoomRate = 0; decimal Total = 0; TimeSpan difference = (TimeSpan)(mySelectedAfacture.DischargeDate - mySelectedAfacture.AdmitDate); int totjours = Convert.ToInt32(difference.TotalDays); if (mySelectedAfacture.Extra.Phone == true) { decimal telrate = 0; var gettelrate = (from p in context.Extra_Rates where p.AmenityName == "PHONE" select p).First().DailyCost; DescTel = " - Option téléphone - " + gettelrate + "$ par jours "; telrate = Convert.ToDecimal(gettelrate); extTelRate = totjours * telrate; } if (mySelectedAfacture.Extra.TV == true) { decimal tvrate = 0; var gettvrate = (from p in context.Extra_Rates where p.AmenityName == "TV" select p).First().DailyCost; DescTV = " - Option télévision - " + gettvrate + "$ par jours "; tvrate = Convert.ToDecimal(gettvrate); extTVRate = totjours * tvrate; } if (mySelectedAfacture.Extra.SemiPriivate == true) { decimal roomrate = 0; var getroomrate = (from p in context.Extra_Rates where p.AmenityName == "SEMI" select p).First().DailyCost; roomrate = Convert.ToDecimal(getroomrate); extRoomRate = roomrate * totjours; DescTarif = " tarif chambre Semi-Privé " + getroomrate + "$"; } if (mySelectedAfacture.Extra.Private == true) { decimal roomrate = 0; var getroomrate = (from p in context.Extra_Rates where p.AmenityName == "PRIVÉ" select p).First().DailyCost; roomrate = Convert.ToDecimal(getroomrate); extRoomRate = roomrate * totjours; DescTarif = " tarif chambre Privé " + getroomrate + "$"; } DescItem = "Hospitalisation de " + totjours.ToString() + " jours" + DescTel + DescTV + DescTarif; Total = extRoomRate + extTelRate + extTVRate; MontantFacture = Total.ToString() + "$"; Facture myfacture = new Facture(mySelectedAfacture, DescItem, MontantFacture); myfacture.ShowDialog(); mySelectedAfacture.Facture = true; context.SubmitChanges(); var query = from a in context.AdmissionRecords where a.Facture == false && a.DischargeDate != null select a; ObservableCollection <AdmissionRecord> myFactureList = new ObservableCollection <AdmissionRecord>(); var getlist = query; foreach (var item in getlist) { myFactureList.Add(item); } var queryTemine = from a in context.AdmissionRecords where a.Facture == true select a; ObservableCollection <AdmissionRecord> myFactureListTermnine = new ObservableCollection <AdmissionRecord>(); var getlisttermine = queryTemine; foreach (var item in getlisttermine) { myFactureListTermnine.Add(item); } ListAFacture.DataContext = myFactureList; ListAFactureTermine.DataContext = myFactureListTermnine; }