12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using Microsoft.Win32;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace ServiceDEMO.Win
- {
- /// <summary>
- /// Логика взаимодействия для AddServiseWin.xaml
- /// </summary>
- public partial class AddServiseWin : Window
- {
- Goiman_A_AEntities1 db = new Goiman_A_AEntities1 ();
- public AddServiseWin()
- {
- InitializeComponent();
- }
- public string path = "";
- public List<string> pathList = new List<string>();
- private void AddImageB_Click(object sender, RoutedEventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Multiselect = true;
- if (ofd.ShowDialog() == true)
- {
- for (int i = 0; i <ofd.FileName.Count(); i++)
- {
- pathList.Add("\\Услуги школы\\" + ofd.SafeFileNames[i]);
- File.Copy(ofd.FileNames[i], Environment.CurrentDirectory + "\\Услуги школы\\Дополнительные фото\\" + ofd.SafeFileNames[i], true);
- }
- }
- }
- private void AddServiseB_Click(object sender, RoutedEventArgs e)
- {
- if (Decimal.TryParse(tb_Cost.Text, out decimal cost) && int.TryParse(tb_Duration.Text, out int duration)
- && Double.TryParse(tb_Discount.Text, out double discount))
- {
- Service entity = new Service
- {
- Title = tb_Name.Text,
- Cost = cost,
- DurationInSeconds = duration,
- Description = tb_Discription.Text,
- Discount = discount,
- MainImagePath = path
- };
- db.Service.Add(entity);
- db.SaveChanges();
- MessageBox.Show("Alert");
- }
- else
- {
- MessageBox.Show("Mega Alert");
- }
- }
- }
- }
|