Beispiel #1
0
 public CasseteAboutViewModel(int id)
 {
     SaveCommand   = new RelayCommand(o => SaveButtonClick("SaveButton"));
     CancelCommand = new RelayCommand(o => CancelCommandClick("CancelButton"));
     ConnectToDB();
     cat_id = id;
     if (database != null)
     {
         try
         {
             cassetes     = database.Cassetes.Find(id);
             _title       = cassetes.Title;
             _director    = cassetes.Director;
             _departament = cassetes.Departament_Id;
             _cover       = API.Image.ByteArrayToImage(cassetes.Cover);
             _price       = cassetes.Price;
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message);
         }
     }
     else
     {
         MessageBox.Show("Запись не найдена.");
     }
 }
 private void GetTotalInfo()
 {
     try
     {
         ReturnTotal.Clear();
         rs = new Model.RentalShopEntities();
         OrderInfo             orderInfo;
         Model.Cassete_Rentals cassete_Rentals = rs.Cassete_Rentals.Find(int.Parse(OrderID));
         if (cassete_Rentals != null)
         {
             Model.Cassetes cassete = rs.Cassete_Copies.Where(s => s.Copy_Id == cassete_Rentals.Copy_Id).FirstOrDefault <Model.Cassete_Copies>().Cassetes;
             if (rs.Cassete_Copies.Where(s => s.Copy_Id == cassete_Rentals.Copy_Id).FirstOrDefault <Model.Cassete_Copies>().Status == "busy")
             {
                 Cover = API.Image.ByteArrayToImage(cassete.Cover);
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Клиент",
                     Value = cassete_Rentals.Clients.First_Name + " " + cassete_Rentals.Clients.Second_Name
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Номер клиента",
                     Value = cassete_Rentals.Clients.Client_Id.ToString()
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Логин клиента",
                     Value = cassete_Rentals.Clients.Login
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Номер копии",
                     Value = cassete_Rentals.Copy_Id.ToString()
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Кассета",
                     Value = cassete.Title
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Номер кассеты",
                     Value = cassete.Catalog_Id.ToString()
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Дата получения",
                     Value = cassete_Rentals.Give_Date.Date.ToString()
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Дата возврата",
                     Value = cassete_Rentals.Get_Date.Date.ToString()
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Утеряна",
                     Value = IsLose.ToString()
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Номер отдела",
                     Value = cassete_Rentals.Departament_Id.ToString()
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Адрес отдела",
                     Value = cassete_Rentals.Departaments.State + ", " + cassete_Rentals.Departaments.City + ", " + cassete_Rentals.Departaments.Street + ", " + cassete_Rentals.Departaments.Zip
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Цена за кассету в сутки",
                     Value = cassete.Price.ToString()
                 });
                 ReturnTotal.Add(new ReturnInfo
                 {
                     Title = "Цена по договору",
                     Value = (((cassete_Rentals.Get_Date - cassete_Rentals.Give_Date).Days) * Convert.ToInt32(cassete.Price)).ToString()
                 });
                 copy = rs.Cassete_Copies.Where(s => s.Copy_Id == cassete_Rentals.Copy_Id).FirstOrDefault <Model.Cassete_Copies>();
             }
             else
             {
                 MessageBox.Show("Заказ уже завершен");
                 ReturnTotal.Clear();
                 Cover  = null;
                 IsLose = false;
             }
         }
         else
         {
             MessageBox.Show("Заказ не найден");
             Cover  = null;
             IsLose = false;
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }