public static Patient LoadPatient(uint PatientId) { Patient patient = null; using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("patient").Where("PatientId", PatientId)) using (var reader = new MySqlReader(cmd)) { if (reader.Read()) { patient = new Patient(reader.ReadInt32("PatientId"), reader.ReadInt32("Age"), (Gender)reader.ReadByte("Gender"), reader.ReadString("PatientName"), reader.ReadString("PhoneNumber"), reader.ReadString("Address")); } } if (patient != null) { using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("history").Where("PatientId", PatientId)) using (var reader = new MySqlReader(cmd)) { while (reader.Read()) { patient.insertNewHistory($"[{DateTime.FromBinary(reader.ReadInt64("Date"))}] ==> {reader.ReadString("History")}"); } } } return(patient); }
private void ItemsList_SelectionChanged(object sender, SelectionChangedEventArgs e) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("medics").Where("Id", ItemsList.SelectedItem.ToString()).And("Name", SearchBox.Text).Execute(); MySqlReader r = new MySqlReader(cmd); Clear(); if (r.Read()) { ItemId = r.ReadInt64("Id"); MName.Text = r.ReadString("Name"); MSS.Text = r.ReadString("ScientificName"); MSUP.Text = r.ReadString("Supplier"); Ptype = r.ReadByte("Type"); MExist.Text = r.ReadDecimal("Total").ToString(); MPrice.Text = r.ReadDecimal("SPrice").ToString(); MEX.Text = r.ReadString("ExpirationDate"); MNotes.Text = r.ReadString("Notes"); SearchBox.Foreground = Brushes.Green; if (Convert.ToDecimal(MExist.Text) < 1) { MExist.Foreground = Brushes.Red; Console.WriteLine("You have no - " + MName.Text + " - I believe that you should get new ones"); } if (Convert.ToDateTime(MEX.Text) <= DateTime.Now.Date) { MEX.Background = Brushes.Red; MEX.Foreground = Brushes.OrangeRed; Console.WriteLine("Exy exy - " + MName.Text + " - I believe that you should get rid of that"); } MTypeFromToNo(); Console.WriteLine("Searched for - " + MName.Text + " -"); } }
public static Reservation LoadReservation(uint ReservationId) { Reservation reservation = null; using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("reservation").Where("ReservationId", ReservationId)) using (var reader = new MySqlReader(cmd)) { if (reader.Read()) { reservation = new Reservation(reader.ReadInt32("PatientId"), reader.ReadInt32("ReservationId"), reader.ReadString("DoctorId"), reader.ReadString("ClinicId"), reader.ReadString("AccountantId"), DateTime.FromBinary(reader.ReadInt64("ReservationDate")) ); } } return(reservation); }
private void SearchButton_Click(object sender, RoutedEventArgs e) { Clear(); try { if (ByBarCode.IsChecked == true) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("medics").Where("Barcode", SearchBox.Text).Execute(); MySqlReader r = new MySqlReader(cmd); if (r.Read()) { ItemId = r.ReadInt64("Id"); MName.Text = r.ReadString("Name"); MSS.Text = r.ReadString("ScientificName"); MSUP.Text = r.ReadString("Supplier"); Ptype = r.ReadByte("Type"); MExist.Text = r.ReadDecimal("Total").ToString(); MPrice.Text = r.ReadDecimal("SPrice").ToString(); MEX.Text = r.ReadString("ExpirationDate"); MNotes.Text = r.ReadString("Notes"); SearchBox.Foreground = Brushes.Green; if (Convert.ToDecimal(MExist.Text) < 1) { MExist.Foreground = Brushes.Red; Console.WriteLine("You have no - " + MName.Text + " - " + ItemId + " - I believe that you should get new ones"); } if (Convert.ToDateTime(MEX.Text) <= DateTime.Now.Date) { MEX.Background = Brushes.Red; MEX.Foreground = Brushes.OrangeRed; Console.WriteLine("bad deadpool - " + MName.Text + " - " + ItemId + " - you should get rid of that"); } Console.WriteLine("Searched for - " + MName.Text + " - " + ItemId + " -"); } else { SearchBox.Foreground = Brushes.Red; Console.WriteLine("Searched for - " + SearchBox.Text + " - with no luck"); } r.Close(); ItemsList.Items.Clear(); while (r.Read()) { ItemsList.Items.Add(r.ReadInt64("Id")); } if (ItemsList.Items.Count < 1) { ItemsList.Items.Clear(); ItemsList.Items.Add("لا يوجد شئ اخر"); } r.Close(); } else if (ByBarCode.IsChecked == false) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("medics").Where("Name", SearchBox.Text).Execute(); MySqlReader r = new MySqlReader(cmd); if (r.Read()) { ItemId = r.ReadInt64("Id"); MName.Text = r.ReadString("Name"); MSS.Text = r.ReadString("ScientificName"); MSUP.Text = r.ReadString("Supplier"); Ptype = r.ReadByte("Type"); MExist.Text = r.ReadDecimal("Total").ToString(); MPrice.Text = r.ReadDecimal("SPrice").ToString(); MEX.Text = r.ReadString("ExpirationDate"); MNotes.Text = r.ReadString("Notes"); SearchBox.Foreground = Brushes.Green; if (Convert.ToDecimal(MExist.Text) < 1) { MExist.Foreground = Brushes.Red; Console.WriteLine("You have no - " + MName.Text + " - I believe that you should get new ones"); } if (Convert.ToDateTime(MEX.Text) <= DateTime.Now.Date) { MEX.Background = Brushes.Red; MEX.Foreground = Brushes.OrangeRed; Console.WriteLine("Red Alert - " + MName.Text + " - you should get rid of that"); } Console.WriteLine("Searched for - " + MName.Text + " -"); } else { SearchBox.Foreground = Brushes.Red; Console.WriteLine("Searched for - " + SearchBox.Text + " - with no luck"); } ItemsList.Items.Clear(); while (r.Read()) { ItemsList.Items.Add(r.ReadInt64("Id")); } if (ItemsList.Items.Count < 1) { ItemsList.Items.Clear(); ItemsList.Items.Add("لا يوجد شئ اخر"); } r.Close(); } MTypeFromToNo(); } catch (Exception ex) { Core.SaveException(ex); } SearchBox.Items.Refresh(); }