Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BMO.GameDevUnity.CSharp2.Pract5"
mc:Ignorable="d"
Title="Сотрудники организации" Height="450" Width="800">
Title="Сотрудники организации" Height="450" Width="800" Loaded="WndMain_Loaded">
<Window.Resources>
<SolidColorBrush x:Key="Brush1" Color="Azure"/>
</Window.Resources>
Expand All @@ -33,17 +33,17 @@
<MenuItem x:Name="miExit" Header="Exit" Click="MiExit_Click"></MenuItem>
</MenuItem>
</Menu>
<ListView x:Name="lvEmployees" Grid.Column="2" HorizontalAlignment="Stretch" Grid.Row="1" VerticalAlignment="Stretch" Margin="20" SelectionChanged="LbEmployees_SelectionChanged">
<ListView x:Name="lvEmployees" ItemsSource="{Binding}" Grid.Column="2" HorizontalAlignment="Stretch" Grid.Row="1" VerticalAlignment="Stretch" Margin="20" SelectionChanged="LbEmployees_SelectionChanged">
<ListView.View>
<GridView>
<GridViewColumn Header="Имя" Width="125px" DisplayMemberBinding="{Binding FirstName}" />
<GridViewColumn Header="Фамилия" Width="125px" DisplayMemberBinding="{Binding LastName}" />
<GridViewColumn Header="Возраст" Width="100px" DisplayMemberBinding="{Binding Age}" />
<GridViewColumn Header="Профессия" Width="160px" DisplayMemberBinding="{Binding Profession}" />
<GridViewColumn Header="Имя" Width="125px" DisplayMemberBinding="{Binding first_name}" />
<GridViewColumn Header="Фамилия" Width="125px" DisplayMemberBinding="{Binding last_name}" />
<GridViewColumn Header="Возраст" Width="100px" DisplayMemberBinding="{Binding age}" />
<GridViewColumn Header="Профессия" Width="160px" DisplayMemberBinding="{Binding profession}" />
</GridView>
</ListView.View>
</ListView>
<ComboBox x:Name="cbDepartments" Grid.Column="2" VerticalAlignment="Top" FontSize="20" Margin="30" ItemsSource="{Binding ElementName=wndMain, Path=MyOrganization.Keys, Mode=OneWay}" HorizontalContentAlignment="Right" DropDownClosed="CbDepartments_DropDownClosed"/>
<ComboBox x:Name="cbDepartments" ItemsSource="{Binding}" DisplayMemberPath="name" Grid.Column="2" VerticalAlignment="Top" FontSize="20" Margin="30" HorizontalContentAlignment="Right" DropDownClosed="CbDepartments_DropDownClosed"/>
<Button Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="20,20,20,20" Content="Add" Background="{DynamicResource Brush1}" Foreground="Brown" Name="btnAddEmployee" Click="BtnAddEmployee_Click"/>
<Button Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="20,20,20,70" Content="Add" Background="{DynamicResource Brush1}" Foreground="Brown" Name="btnAddDepartment" Click="BtnAddDepartment_Click"/>

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;

namespace BMO.GameDevUnity.CSharp2.Pract5
{
Expand All @@ -19,17 +20,20 @@ namespace BMO.GameDevUnity.CSharp2.Pract5
/// </summary>
public partial class wndChangeDepartment : Window
{
public string Department { get; set; }
public wndChangeDepartment()
public DataRow resultRow { get; set; }

public wndChangeDepartment(DataRow newRow)
{
InitializeComponent();

this.DataContext = this;

resultRow = newRow;
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
tbNameDepartment.Text = Department;
tbNameDepartment.Text = resultRow["name"].ToString();
}

private void BtnOK_Click(object sender, RoutedEventArgs e)
Expand All @@ -40,7 +44,7 @@ private void BtnOK_Click(object sender, RoutedEventArgs e)
}
else
{
Department = tbNameDepartment.Text;
resultRow["name"] = tbNameDepartment.Text;
this.DialogResult = true;
}

Expand All @@ -55,7 +59,7 @@ private void BtnCancel_Click(object sender, RoutedEventArgs e)

private void BtnReset_Click(object sender, RoutedEventArgs e)
{
tbNameDepartment.Text = Department;
tbNameDepartment.Text = resultRow["name"].ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Label Content="Age"/>
<TextBox Name="tbAge" Width="300" HorizontalAlignment="Left"/>
<Label Content="Department"/>
<ComboBox x:Name="cbDepartments"></ComboBox>
<ComboBox x:Name="cbDepartments" ItemsSource="{Binding}" DisplayMemberPath="name"></ComboBox>
<Grid>
<Button Name="btnOK" Content="OK" Margin="5" HorizontalAlignment="Right" Click="BtnOK_Click"/>
<Button x:Name="btnCancel" Content="Cancel" Margin="5,5,120,5" HorizontalAlignment="Right" Click="BtnCancel_Click"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;

namespace BMO.GameDevUnity.CSharp2.Pract5
{
Expand All @@ -19,23 +20,15 @@ namespace BMO.GameDevUnity.CSharp2.Pract5
/// </summary>
public partial class wndChangeEmployee : Window
{
public string LastName { get; set; }
public string FirstName { get; set; }
public string Profession { get; set; }
public int Age { get; set; }
public string Department { get; set; }
public Employee ForExchange { get; set; }
public DataRow resultRow { get; set; }

public wndChangeEmployee()
public wndChangeEmployee(DataRow newRow)
{
InitializeComponent();

this.DataContext = this;

foreach (var department in MainWindow.MyOrganization)
{
cbDepartments.Items.Add(department.Key);
}
resultRow = newRow;
}

private void BtnCancel_Click(object sender, RoutedEventArgs e)
Expand All @@ -48,34 +41,39 @@ private void BtnOK_Click(object sender, RoutedEventArgs e)
{
try
{
ForExchange = new Employee(tbLastName.Text, tbFirstName.Text, tbProfession.Text, Convert.ToInt32(tbAge.Text));
Department = cbDepartments.Text;
resultRow["first_name"] = tbFirstName.Text;
resultRow["last_name"] = tbLastName.Text;
resultRow["profession"] = tbProfession.Text;
resultRow["age"] = tbAge.Text;
DataRowView department = (DataRowView)cbDepartments.SelectedItem;
resultRow["id_department"] = department.Row.ItemArray[0];
this.DialogResult = true;
}
catch (Exception)
{

MessageBox.Show("Введены некорректные данные", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
this.Close();
}

private void BtnReset_Click(object sender, RoutedEventArgs e)
{
tbLastName.Text = LastName;
tbFirstName.Text = FirstName;
tbProfession.Text = Profession;
tbAge.Text = Age.ToString();
cbDepartments.Text = Department;
tbFirstName.Text = resultRow["first_name"].ToString();
tbLastName.Text = resultRow["last_name"].ToString();
tbProfession.Text = resultRow["profession"].ToString();
tbAge.Text = resultRow["age"].ToString();
cbDepartments.Text = MainWindow.dtDepartments.Rows.Find((int)resultRow["id_department"]).ItemArray[1].ToString();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
tbLastName.Text = LastName;
tbFirstName.Text = FirstName;
tbProfession.Text = Profession;
tbAge.Text = Age.ToString();
cbDepartments.Text = Department;
tbFirstName.Text = resultRow["first_name"].ToString();
tbLastName.Text = resultRow["last_name"].ToString();
tbProfession.Text = resultRow["profession"].ToString();
tbAge.Text = resultRow["age"].ToString();
cbDepartments.DataContext = MainWindow.dtDepartments.DefaultView;
cbDepartments.Text = MainWindow.dtDepartments.Rows.Find((int)resultRow["id_department"]).ItemArray[1].ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BMO.GameDevUnity.CSharp2.Pract5"
mc:Ignorable="d"
Title="Добавление нового департамента" Height="120" Width="310">
Title="Добавление нового департамента" Height="120" Width="310" Loaded="Window_Loaded">
<StackPanel Margin="0,0,0,0">
<Label Content="Name department"/>
<TextBox Name="tbNameDepartment" Width="300" HorizontalAlignment="Left"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;

namespace BMO.GameDevUnity.CSharp2.Pract5
{
Expand All @@ -19,13 +20,13 @@ namespace BMO.GameDevUnity.CSharp2.Pract5
/// </summary>
public partial class wndNewDepartment : Window
{
public string NameOfDepartment { get; set; }
public DataRow resultRow { get; set; }

public wndNewDepartment()
public wndNewDepartment(DataRow newRow)
{
InitializeComponent();

this.DataContext = this;
resultRow = newRow;
}

private void BtnOK_Click(object sender, RoutedEventArgs e)
Expand All @@ -36,11 +37,16 @@ private void BtnOK_Click(object sender, RoutedEventArgs e)
}
else
{
NameOfDepartment = tbNameDepartment.Text;
resultRow["name"] = tbNameDepartment.Text;

this.DialogResult = true;
}
this.Close();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
tbNameDepartment.Text = resultRow["name"].ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BMO.GameDevUnity.CSharp2.Pract5"
mc:Ignorable="d"
Title="Добавление нового сотрудника" Height="300" Width="350">
Title="Добавление нового сотрудника" Height="300" Width="350" Loaded="Window_Loaded">
<StackPanel Margin="0,0,0,0">
<Label Content="First Name"/>
<TextBox Name="tbFirstName" Width="300" HorizontalAlignment="Left"/>
Expand All @@ -16,7 +16,7 @@
<Label Content="Age"/>
<TextBox Name="tbAge" Width="300" HorizontalAlignment="Left"/>
<Label Content="Department"/>
<ComboBox x:Name="cbDepartments"></ComboBox>
<ComboBox x:Name="cbDepartments" ItemsSource="{Binding}" DisplayMemberPath="name"></ComboBox>
<Button Name="btnOK" Content="OK" Margin="5" HorizontalAlignment="Right" Click="BtnOK_Click"/>
</StackPanel>
</Window>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;

namespace BMO.GameDevUnity.CSharp2.Pract5
{
Expand All @@ -19,28 +21,27 @@ namespace BMO.GameDevUnity.CSharp2.Pract5
/// </summary>
public partial class wndNewEmployee : Window
{
public Employee ForExchange { get; set; }
public string NameOfDepartment { get; set; }
public DataRow resultRow { get; set; }

public wndNewEmployee()
public wndNewEmployee(DataRow newRow)
{
InitializeComponent();

this.DataContext = this;

foreach (var department in MainWindow.MyOrganization)
{
cbDepartments.Items.Add(department.Key);
}
cbDepartments.Text = cbDepartments.Items[0].ToString();
resultRow = newRow;
}

private void BtnOK_Click(object sender, RoutedEventArgs e)
{
try
{
ForExchange = new Employee(tbLastName.Text, tbFirstName.Text, tbProfession.Text, Convert.ToInt32(tbAge.Text));
NameOfDepartment = cbDepartments.Text;
resultRow["first_name"] = tbFirstName.Text;
resultRow["last_name"] = tbLastName.Text;
resultRow["profession"] = tbProfession.Text;
resultRow["age"] = tbAge.Text;
DataRowView department = (DataRowView)cbDepartments.SelectedItem;
resultRow["id_department"] = department.Row.ItemArray[0];
this.DialogResult = true;
}
catch (Exception)
Expand All @@ -50,5 +51,15 @@ private void BtnOK_Click(object sender, RoutedEventArgs e)
}
this.Close();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
tbFirstName.Text = resultRow["first_name"].ToString();
tbLastName.Text = resultRow["last_name"].ToString();
tbProfession.Text = resultRow["profession"].ToString();
tbAge.Text = resultRow["age"].ToString();
cbDepartments.DataContext = MainWindow.dtDepartments.DefaultView;
cbDepartments.Text = MainWindow.dtDepartments.Rows[0].ItemArray[1].ToString();
}
}
}
Binary file not shown.
Binary file not shown.