add ComboBox and ListBox
This commit is contained in:
parent
b617f2e014
commit
4f43df675b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -4,11 +4,20 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="demo_blagodat.ChangeServices"
|
x:Class="demo_blagodat.ChangeServices"
|
||||||
|
xmlns:vm="using:demo_blagodat.Models"
|
||||||
Title="Изменить услугу">
|
Title="Изменить услугу">
|
||||||
<ScrollViewer>
|
<ScrollViewer>
|
||||||
<StackPanel Spacing="15" Orientation="Vertical">
|
<StackPanel Spacing="15" Orientation="Vertical">
|
||||||
<TextBlock Text="Введите код сервиса:"/>
|
<TextBlock Text="Выберите Сервис"/>
|
||||||
<TextBox x:Name="Name"/>
|
<ComboBox Name="ListServices" SelectionChanged="ComboBox_SelectionChanged">
|
||||||
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="vm:Service">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="{Binding ServiceName}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Horizontal">
|
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Horizontal">
|
||||||
|
|
||||||
|
@ -5,38 +5,40 @@ using Avalonia.Markup.Xaml;
|
|||||||
using demo_blagodat.Models;
|
using demo_blagodat.Models;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace demo_blagodat;
|
namespace demo_blagodat;
|
||||||
|
|
||||||
public partial class ChangeServices : Window
|
public partial class ChangeServices : Window
|
||||||
{
|
{
|
||||||
public Employee User;
|
public Employee User;
|
||||||
|
static User11Context db = new User11Context();
|
||||||
|
ObservableCollection<Service> ServiceitemSource = new ObservableCollection<Service>(db.Services);
|
||||||
|
|
||||||
public ChangeServices(Employee user)
|
public ChangeServices(Employee user)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
User = user;
|
User = user;
|
||||||
|
ListServices.ItemsSource = ServiceitemSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ComboBox_SelectionChanged(object? sender, Avalonia.Controls.SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender != null) { }
|
||||||
|
}
|
||||||
private void changeClient(object sender, RoutedEventArgs e)
|
private void changeClient(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try // Êîíñòðóêöèÿ äëÿ îáðàáîòêè èñêëþ÷åíèé
|
try // Êîíñòðóêöèÿ äëÿ îáðàáîòêè èñêëþ÷åíèé
|
||||||
{
|
{
|
||||||
// Îáîçíà÷àåì êîíêðåòíîãî ïîëüçîâàòåëÿ
|
|
||||||
string? name = Name.Text;
|
|
||||||
|
|
||||||
// Ñîáèðàåì âñå äàííûå ñ ýêðàíà
|
// Ñîáèðàåì âñå äàííûå ñ ýêðàíà
|
||||||
string? newname = TextNewName.Text;
|
string? newname = TextNewName.Text;
|
||||||
string? newcode = TextNewCode.Text;
|
string? newcode = TextNewCode.Text;
|
||||||
decimal? newprice = Math.Round(decimal.TryParse(TextNewPrice.Text.Replace(".", ","), out decimal resalt) ? resalt : -1 , 2);
|
decimal? newprice = Math.Round(decimal.TryParse(TextNewPrice.Text.Replace(".", ","), out decimal resalt) ? resalt : -1 , 2);
|
||||||
|
|
||||||
|
|
||||||
if (name != "")
|
if (ListServices.SelectedItem != null)
|
||||||
{
|
|
||||||
using (User11Context db = new User11Context()) // Ïîäêëþ÷åíèå ê ÁÄ
|
|
||||||
{
|
|
||||||
Service? service = db.Services.Where(it => it.ServiceName == name).FirstOrDefault();
|
|
||||||
if (service != null)
|
|
||||||
{
|
{
|
||||||
|
Service service = db.Services.Where(it => it == ListServices.SelectedItem).FirstOrDefault();
|
||||||
if (TextNewName.Text != "")
|
if (TextNewName.Text != "")
|
||||||
{
|
{
|
||||||
service.ServiceName = newname; // Ìåíÿåì ïàðàìåíò "Íàçâàíèå"
|
service.ServiceName = newname; // Ìåíÿåì ïàðàìåíò "Íàçâàíèå"
|
||||||
@ -66,7 +68,7 @@ public partial class ChangeServices : Window
|
|||||||
}
|
}
|
||||||
else if (TextNewPrice.Text != "")
|
else if (TextNewPrice.Text != "")
|
||||||
{
|
{
|
||||||
service.ServiceCostPerHour = (decimal) newprice;// Ìåíÿåì ïàðàìåíò "öåíà â ÷àñû"
|
service.ServiceCostPerHour = (decimal)newprice;// Ìåíÿåì ïàðàìåíò "öåíà â ÷àñû"
|
||||||
|
|
||||||
db.SaveChanges(); // Ñîõðàíÿåì èçìåíåíèÿ
|
db.SaveChanges(); // Ñîõðàíÿåì èçìåíåíèÿ
|
||||||
|
|
||||||
@ -75,7 +77,7 @@ public partial class ChangeServices : Window
|
|||||||
MesAddError.Text = "";
|
MesAddError.Text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TextNewName.Text == "" && TextNewCode.Text == "" && TextNewPrice.Text == "")
|
if (TextNewName.Text == "" && TextNewCode.Text == "" && TextNewPrice.Text == "")
|
||||||
{
|
{
|
||||||
// Ñîîáùåíèå
|
// Ñîîáùåíèå
|
||||||
MesAdd.Text = "";
|
MesAdd.Text = "";
|
||||||
@ -84,13 +86,6 @@ public partial class ChangeServices : Window
|
|||||||
check(service);
|
check(service);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
MesAdd.Text = "";
|
|
||||||
MesAddError.Text = "Òàêîãî ñåðâèñà íåò";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
MesAddError.Text = "Ñíà÷àëà îáîçíà÷üòå èçìåíÿåìûé ñåðâèñ";
|
MesAddError.Text = "Ñíà÷àëà îáîçíà÷üòå èçìåíÿåìûé ñåðâèñ";
|
||||||
}
|
}
|
||||||
@ -114,8 +109,6 @@ public partial class ChangeServices : Window
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void check(Service service)
|
private void check(Service service)
|
||||||
{
|
|
||||||
using (User11Context db = new User11Context()) // Ïîäêëþ÷åíèå ê ÁÄ
|
|
||||||
{
|
{
|
||||||
Service checkService = db.Services.Where(it => it.ServiceName == service.ServiceName).FirstOrDefault();
|
Service checkService = db.Services.Where(it => it.ServiceName == service.ServiceName).FirstOrDefault();
|
||||||
|
|
||||||
@ -123,7 +116,6 @@ public partial class ChangeServices : Window
|
|||||||
SelectCode.Text = checkService.ServiceCode;
|
SelectCode.Text = checkService.ServiceCode;
|
||||||
SelectPrice.Text = checkService.ServiceCostPerHour.ToString();
|
SelectPrice.Text = checkService.ServiceCostPerHour.ToString();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ExitClik(object sender, RoutedEventArgs e)
|
private void ExitClik(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -4,25 +4,40 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="demo_blagodat.DeleteServices"
|
x:Class="demo_blagodat.DeleteServices"
|
||||||
|
xmlns:vm="using:demo_blagodat.Models"
|
||||||
Title="Удалить Сервис">
|
Title="Удалить Сервис">
|
||||||
<ScrollViewer>
|
<ScrollViewer>
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Vertical">
|
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Vertical">
|
||||||
|
|
||||||
<StackPanel Orientation="Vertical">
|
<Border Background="Red"
|
||||||
<TextBlock Text="Введите название"/>
|
CornerRadius="10"
|
||||||
<TextBox Width="300" x:Name="TextName"/>
|
Padding="20"
|
||||||
</StackPanel>
|
Margin="20"
|
||||||
|
Width="400"
|
||||||
<StackPanel Orientation="Vertical">
|
Height="300"
|
||||||
<TextBlock Text="Введите код услуги"/>
|
>
|
||||||
<TextBox Width="300" x:Name="TextCode"/>
|
<ScrollViewer>
|
||||||
|
<ListBox Name="ListServices" SelectionChanged="ListBox_SelectionChanged">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="vm:Service">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="{Binding ServiceName}"/>
|
||||||
|
<TextBlock Text=" : "/>
|
||||||
|
<TextBlock Text="{Binding ServiceCode}"/>
|
||||||
|
<TextBlock Text=" : "/>
|
||||||
|
<TextBlock Text="{Binding ServiceCostPerHour}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Center" Orientation="Vertical" VerticalAlignment="Center">
|
<StackPanel HorizontalAlignment="Center" Orientation="Vertical" VerticalAlignment="Center">
|
||||||
<Button Content="Удвлить Сервис" Click="deleteclient"/>
|
<Button Content="Удалить Сервис" Click="deleteService"/>
|
||||||
<Button Content="Вернуться назад" Click="ExitClik"/>
|
<Button Content="Вернуться назад" Click="ExitClik"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel HorizontalAlignment="Center" Orientation="Vertical">
|
<StackPanel HorizontalAlignment="Center" Orientation="Vertical">
|
||||||
|
@ -5,58 +5,56 @@ using Avalonia.Markup.Xaml;
|
|||||||
using demo_blagodat.Models;
|
using demo_blagodat.Models;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace demo_blagodat;
|
namespace demo_blagodat;
|
||||||
|
|
||||||
public partial class DeleteServices : Window
|
public partial class DeleteServices : Window
|
||||||
{
|
{
|
||||||
public Employee User;
|
public Employee User;
|
||||||
|
static User11Context db = new User11Context();
|
||||||
|
ObservableCollection<Service> ServicesitemSource = new ObservableCollection<Service>(db.Services);
|
||||||
|
|
||||||
public DeleteServices(Employee user)
|
public DeleteServices(Employee user)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
User = user;
|
User = user;
|
||||||
|
ListServices.ItemsSource = ServicesitemSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteclient(object sender, RoutedEventArgs e)
|
private void ListBox_SelectionChanged(object? sender, Avalonia.Controls.SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if(sender != null) { }
|
||||||
|
}
|
||||||
|
private void deleteService(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try // Êîíñòðóêöèÿ äëÿ îáðàáîòêè èñêëþ÷åíèé
|
try // Êîíñòðóêöèÿ äëÿ îáðàáîòêè èñêëþ÷åíèé
|
||||||
{
|
{
|
||||||
using (User11Context db = new User11Context()) // Ïîäêëþ÷åíèå ê ÁÄ
|
if (ListServices.SelectedItem != null) // Ïðîâåðÿåì íàëè÷èå âàæíûõ äàííûõ
|
||||||
{
|
{
|
||||||
// Ñîáèðàåì äàííûå ñ ýêðàíà
|
Service service = db.Services.Where(it => it == ListServices.SelectedItem).FirstOrDefault(); // ñîçäà¸ì ýêçåìïëÿð êëàññà Service
|
||||||
string? name = TextName.Text;
|
|
||||||
string? code = TextCode.Text;
|
|
||||||
|
|
||||||
if (name != null) // Ïðîâåðÿåì íàëè÷èå âàæíûõ äàííûõ
|
|
||||||
{
|
|
||||||
Service? service = db.Services.Where(it => it.ServiceName == name).FirstOrDefault(); // ñîçäà¸ì ýêçåìïëÿð êëàññà Service
|
|
||||||
|
|
||||||
if (service != null)
|
|
||||||
{
|
|
||||||
// Óäàëÿåì ïîëüçîâàòåëÿ èç ÁÄ
|
// Óäàëÿåì ïîëüçîâàòåëÿ èç ÁÄ
|
||||||
db.Services.Remove(service);
|
db.Services.Remove(service);
|
||||||
|
|
||||||
// Ñîõðàíÿåì èçìåíåíèÿ ÁÄ
|
// Ñîõðàíÿåì èçìåíåíèÿ ÁÄ
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
|
|
||||||
|
// Óäàëÿåì èç ñïèñêà
|
||||||
|
ServicesitemSource.Remove(ListServices.SelectedItem as Service);
|
||||||
|
|
||||||
// Ìåíÿåì ñîîáùåíèå
|
// Ìåíÿåì ñîîáùåíèå
|
||||||
MesDelError.Text = "";
|
MesDelError.Text = "";
|
||||||
MesDel.Text = "Ñåðâèñ óäàë¸í";
|
MesDel.Text = "Ñåðâèñ óäàë¸í";
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MesDel.Text = "Òàêîãî ñåðâèñà íåò";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ñòåðàåì âñå äàííûå
|
// Ñòåðàåì âñå äàííûå
|
||||||
TextName.Text = "";
|
ListServices.SelectedItem = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ìåíÿåì ñîîáùåíèå
|
// Ìåíÿåì ñîîáùåíèå
|
||||||
MesDel.Text = "";
|
MesDel.Text = "";
|
||||||
MesDelError.Text = "Íóæíî äîáàâèòü íàçâàíèå èëè êîä!";
|
MesDelError.Text = "Íóæíî âûáðàòü ñåðâèñ";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("demo_blagodat")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("demo_blagodat")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f63e4d41bce29f31e8cca027a20f1c4f0ddbad69")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b617f2e014bf246ac7062520a6d4188404b9fb0d")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("demo_blagodat")]
|
[assembly: System.Reflection.AssemblyProductAttribute("demo_blagodat")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("demo_blagodat")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("demo_blagodat")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
d63b72aa80eb2f6a00640f99908a69b82a4fdfcb728d063234bb70a027739d4a
|
0f35feb508f4935218343a3a6854920d6f75ce11fafc95b97d8ed014f11dd19f
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user