using ZooMail.Models;
using System;
using System.Collections.Generic;
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 ZooMail.AddAnimal
{
/// <summary>
/// Логика взаимодействия для AddAnimalsWindow.xaml
/// </summary>
public partial class AddAnimalWindow : Window
{
public AddAnimalWindow()
{
InitializeComponent();
}
List<Models.ModelSupplierDetail> listSupplier;
private void updateData()
{
listSupplier = (new DBManager()).getSupplierListDetail();
dataGridAddAnimals.ItemsSource = listSupplier;
}
private void Window_Activated(object sender, EventArgs e)
{
updateData();
}
private void ButtonEdit_Click(object sender, RoutedEventArgs e)
{
int selectedIndex = dataGridAddAnimals.SelectedIndex;
if (selectedIndex < 0)
{
MessageBox.Show("Не выбрано животное для редактирования");
return;
}
var ap = new DBManager().getSupplierList();
Models.ModelSupplier modelSupplier = null;
foreach (var it in ap)
{
if (it.Id_Supplier == listSupplier[selectedIndex].Id_Supplier)
{
modelSupplier = it;
break;
}
}
var ce = new AddAnimalEditWindow(modelSupplier);
ce.ShowDialog();
}
private void ButtonAdd_Click(object sender, RoutedEventArgs e)
{
var ce = new AddAnimalEditWindow(null);
ce.ShowDialog();
}
private void ButtonClose_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void ButtonDelete_Click(object sender, RoutedEventArgs e)
{
int selectedIndex = dataGridAddAnimals.SelectedIndex;
if (selectedIndex < 0)
{
MessageBox.Show("Не выбрано животное для редактирования");
return;
}
if (MessageBox.Show("Вы уверены?", "", MessageBoxButton.YesNo) == MessageBoxResult.No)
{
return;
}
new DBManager().deleteSupplier(listSupplier[selectedIndex].Id_Supplier);
MessageBox.Show("Операция выполнена");
updateData();
}
}
}
using ZooMail.Models;
using ZooMail.AnimalAccounting;
using System;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using Xceed.Words.NET;
using Xceed.Document.NET;
using Word = Microsoft.Office.Interop.Word;
using Excel = Microsoft.Office.Interop.Excel;
using System.Threading;
using System.Windows.Controls;
namespace ZooMail.AnimalAccounting
{
/// <summary>
/// Логика взаимодействия для AnimalAccountingWindow.xaml
/// </summary>
public partial class AnimalAccountingWindow : Window
{
async Task<bool> Symb(string str)
{
bool znach = false;
await Task.Run(() =>
{
if (
str.Contains("?") || str.Contains("!") || str.Contains("@") ||
str.Contains("#") || str.Contains("№") || str.Contains("~") ||
str.Contains(";") || str.Contains("%") || str.Contains("$") ||
str.Contains("^") || str.Contains("&") || str.Contains(":") ||
str.Contains("*") || str.Contains("(") || str.Contains(")") ||
str.Contains("_") || str.Contains("=") || str.Contains("+") ||
str.Contains("/") || str.Contains("|") || str.Contains("[") ||
str.Contains("]") || str.Contains("{") || str.Contains("}") ||
str.Contains("<") || str.Contains(">") || str.Contains("-") ||
str.Contains(",") || str.Contains("`") || str.Contains("."))
znach = true;
});
return znach;
}
bool IsValidEmail(string email)
{
try
{
var addr = new System.Net.Mail.MailAddress(email);
return addr.Address == email;
}
catch
{
return false;
}
}
List<Models.ModelAnimalparkDetail> listAnimal;
public string extension = string.Empty;
public AnimalAccountingWindow()
{
InitializeComponent();
}
private void ButtonEdit_Click(object sender, RoutedEventArgs e)
{
int selectedIndex = dataGridCars.SelectedIndex;
if (selectedIndex < 0)
{
MessageBox.Show("Не выбран товар для редактирования");
return;
}
var ap = new DBManager().getAnimalparkList();
Models.ModelAnimalpark modelAnimalpark = null;
foreach (var it in ap)
{
if (it.ID_animalpark == listAnimal[selectedIndex].ID_animalpark)
{
modelAnimalpark = it;
break;
}
}
var ce = new AnimalEdit(modelAnimalpark);
ce.ShowDialog();
}
private void ButtonAdd_Click(object sender, RoutedEventArgs e)
{
var ce = new AnimalEdit(null);
ce.ShowDialog();
}
private void ButtonClose_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void Window_Activated(object sender, EventArgs e)
{
listAnimal = (new DBManager()).getAnimalparkListDetail();
dataGridCars.ItemsSource = listAnimal;
}
private void ButtonDelete_Click(object sender, RoutedEventArgs e)
{
int selectedIndex = dataGridCars.SelectedIndex;
if (selectedIndex < 0)
{
MessageBox.Show("Не выбран товар для редактирования");
return;
}
if (MessageBox.Show("Вы уверены?", "", MessageBoxButton.YesNo) == MessageBoxResult.No)
{
return;
}
new DBManager().deleteAnimalpark(listAnimal[selectedIndex].ID_animalpark);
MessageBox.Show("Операция выполнена");
listAnimal = (new DBManager()).getAnimalparkListDetail();
dataGridCars.ItemsSource = listAnimal;
}
private void createExportDoc()
{
try
{
DBManager con = new DBManager();
var modelAnimalpark = con.getAnimalparkList();
if (extension == string.Empty)
{
MessageBox.Show("Не выбран тип экспортруемого файла");
return;
}
switch (extension)
{
case (".docx"):
string pathDocumentDOCX = Session.baseDir + "Учет товар" + extension;
DocX document = DocX.Create(pathDocumentDOCX);
Xceed.Document.NET.Paragraph paragraph = document.InsertParagraph();
paragraph.
AppendLine("Документ '" + "Отчет о учете автомобилей" + "' создан " + DateTime.Now.ToShortDateString()).
Font("Time New Roman").
FontSize(16).Bold().Alignment = Alignment.left;
paragraph.AppendLine();
Xceed.Document.NET.Table doctable = document.AddTable(modelAnimalpark.Count + 1, 2);
doctable.Design = TableDesign.TableGrid;
doctable.TableCaption = "учет товара";
doctable.Rows[0].Cells[0].Paragraphs[0].Append("Учет товара").Font("Times New Roman").FontSize(14);
for (int i = 0; i < modelAnimalpark.Count; i++)
{
doctable.Rows[i + 1].Cells[0].Paragraphs[0].Append(modelAnimalpark[i].Number).Font("Times New Roman").FontSize(14);
}
document.InsertParagraph().InsertTableAfterSelf(doctable);
document.Save();
MessageBox.Show("Отчет успешно сформирован!");
Process.Start(pathDocumentDOCX);
break;
case (".xlsx"):
Excel.Application excel;
Excel.Workbook worKbooK;
Excel.Worksheet worKsheeT;
Excel.Range celLrangE;
string pathDocumentXLSX = Session.baseDir + "Учет о животных" + extension;
try
{
excel = new Excel.Application();
excel.Visible = false;
excel.DisplayAlerts = false;
worKbooK = excel.Workbooks.Add(Type.Missing);
worKsheeT = (Microsoft.Office.Interop.Excel.Worksheet)worKbooK.ActiveSheet;
worKsheeT.Name = "Учет о животных";
worKsheeT.Range[worKsheeT.Cells[1, 1], worKsheeT.Cells[1, 8]].Merge();
worKsheeT.Cells[1, 1] = "Учет о животных";
worKsheeT.Cells.Font.Size = 15;
for (int i = 0; i < modelAnimalpark.Count; i++)
{
worKsheeT.Cells[i + 3, 1] = modelAnimalpark[i].Number;
}
worKbooK.SaveAs(pathDocumentXLSX); ;
worKbooK.Close();
excel.Quit();
MessageBox.Show("Отчет успешно сформирован!");
Process.Start(pathDocumentXLSX);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
worKsheeT = null;
celLrangE = null;
worKbooK = null;
}
break;
case (".pdf"):
string pathDocumentPDF = Session.baseDir + "Учет о животных" + extension;
if (File.Exists(Session.baseDir + "Учет о животных.docx"))
{
Word.Application appWord = new Word.Application();
var wordDocument = appWord.Documents.Open(Session.baseDir + "Учет о животных.docx");
wordDocument.ExportAsFixedFormat(pathDocumentPDF, Word.WdExportFormat.wdExportFormatPDF);
MessageBox.Show("Отчет успешно сформирован!");
wordDocument.Close();
Process.Start(pathDocumentPDF);
}
else
MessageBox.Show("Сначала сформируйте отчет .docx");
break;
}
}
catch (Exception)
{
MessageBox.Show("Отсутсвие Ms Office на компьютере. Пожалуйста скачайте его.");
Process.Start("https://www.microsoft.com/ru-ru/microsoft-365/compare-all-microsoft-365-products?tab=1&rtc=1");
}
}
private void ButtonExport_Click(object sender, RoutedEventArgs e)
{
Thread t = new Thread(new ThreadStart(createExportDoc));
t.Start();
}
private void ComboBoxExport_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBoxItem typeItem = (ComboBoxItem)comboBoxExport.SelectedItem;
extension = typeItem.Content.ToString();
}
}
}
using ZooMail.Models;
using ZooMail.AnimalAccounting;
using System;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using Xceed.Words.NET;
using Xceed.Document.NET;
using Word = Microsoft.Office.Interop.Word;
using Excel = Microsoft.Office.Interop.Excel;
using System.Threading;
using System.Windows.Controls;
namespace ZooMail.AnimalAccounting
{
/// <summary>
/// Логика взаимодействия для AnimalAccountingWindow.xaml
/// </summary>
public partial class AnimalAccountingWindow : Window
{
async Task<bool> Symb(string str)
{
bool znach = false;
await Task.Run(() =>
{
if (
str.Contains("?") || str.Contains("!") || str.Contains("@") ||
str.Contains("#") || str.Contains("№") || str.Contains("~") ||
str.Contains(";") || str.Contains("%") || str.Contains("$") ||
str.Contains("^") || str.Contains("&") || str.Contains(":") ||
str.Contains("*") || str.Contains("(") || str.Contains(")") ||
str.Contains("_") || str.Contains("=") || str.Contains("+") ||
str.Contains("/") || str.Contains("|") || str.Contains("[") ||
str.Contains("]") || str.Contains("{") || str.Contains("}") ||
str.Contains("<") || str.Contains(">") || str.Contains("-") ||
str.Contains(",") || str.Contains("`") || str.Contains("."))
znach = true;
});
return znach;
}
bool IsValidEmail(string email)
{
try
{
var addr = new System.Net.Mail.MailAddress(email);
return addr.Address == email;
}
catch
{
return false;
}
}
List<Models.ModelAnimalparkDetail> listAnimal;
public string extension = string.Empty;
public AnimalAccountingWindow()
{
InitializeComponent();
}
private void ButtonEdit_Click(object sender, RoutedEventArgs e)
{
int selectedIndex = dataGridCars.SelectedIndex;
if (selectedIndex < 0)
{
MessageBox.Show("Не выбран товар для редактирования");
return;
}
var ap = new DBManager().getAnimalparkList();
Models.ModelAnimalpark modelAnimalpark = null;
foreach (var it in ap)
{
if (it.ID_animalpark == listAnimal[selectedIndex].ID_animalpark)
{
modelAnimalpark = it;
break;
}
}
var ce = new AnimalEdit(modelAnimalpark);
ce.ShowDialog();
}
private void ButtonAdd_Click(object sender, RoutedEventArgs e)
{
var ce = new AnimalEdit(null);
ce.ShowDialog();
}
private void ButtonClose_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void Window_Activated(object sender, EventArgs e)
{
listAnimal = (new DBManager()).getAnimalparkListDetail();
dataGridCars.ItemsSource = listAnimal;
}
private void ButtonDelete_Click(object sender, RoutedEventArgs e)
{
int selectedIndex = dataGridCars.SelectedIndex;
if (selectedIndex < 0)
{
MessageBox.Show("Не выбран товар для редактирования");
return;
}
if (MessageBox.Show("Вы уверены?", "", MessageBoxButton.YesNo) == MessageBoxResult.No)
{
return;
}
new DBManager().deleteAnimalpark(listAnimal[selectedIndex].ID_animalpark);
MessageBox.Show("Операция выполнена");
listAnimal = (new DBManager()).getAnimalparkListDetail();
dataGridCars.ItemsSource = listAnimal;
}
private void createExportDoc()
{
try
{
DBManager con = new DBManager();
var modelAnimalpark = con.getAnimalparkList();
if (extension == string.Empty)
{
MessageBox.Show("Не выбран тип экспортруемого файла");
return;
}
switch (extension)
{
case (".docx"):
string pathDocumentDOCX = Session.baseDir + "Учет товар" + extension;
DocX document = DocX.Create(pathDocumentDOCX);
Xceed.Document.NET.Paragraph paragraph = document.InsertParagraph();
paragraph.
AppendLine("Документ '" + "Отчет о учете автомобилей" + "' создан " + DateTime.Now.ToShortDateString()).
Font("Time New Roman").
FontSize(16).Bold().Alignment = Alignment.left;
paragraph.AppendLine();
Xceed.Document.NET.Table doctable = document.AddTable(modelAnimalpark.Count + 1, 2);
doctable.Design = TableDesign.TableGrid;
doctable.TableCaption = "учет товара";
doctable.Rows[0].Cells[0].Paragraphs[0].Append("Учет товара").Font("Times New Roman").FontSize(14);
for (int i = 0; i < modelAnimalpark.Count; i++)
{
doctable.Rows[i + 1].Cells[0].Paragraphs[0].Append(modelAnimalpark[i].Number).Font("Times New Roman").FontSize(14);
}
document.InsertParagraph().InsertTableAfterSelf(doctable);
document.Save();
MessageBox.Show("Отчет успешно сформирован!");
Process.Start(pathDocumentDOCX);
break;
case (".xlsx"):
Excel.Application excel;
Excel.Workbook worKbooK;
Excel.Worksheet worKsheeT;
Excel.Range celLrangE;
string pathDocumentXLSX = Session.baseDir + "Учет о животных" + extension;
try
{
excel = new Excel.Application();
excel.Visible = false;
excel.DisplayAlerts = false;
worKbooK = excel.Workbooks.Add(Type.Missing);
worKsheeT = (Microsoft.Office.Interop.Excel.Worksheet)worKbooK.ActiveSheet;
worKsheeT.Name = "Учет о животных";
worKsheeT.Range[worKsheeT.Cells[1, 1], worKsheeT.Cells[1, 8]].Merge();
worKsheeT.Cells[1, 1] = "Учет о животных";
worKsheeT.Cells.Font.Size = 15;
for (int i = 0; i < modelAnimalpark.Count; i++)
{
worKsheeT.Cells[i + 3, 1] = modelAnimalpark[i].Number;
}
worKbooK.SaveAs(pathDocumentXLSX); ;
worKbooK.Close();
excel.Quit();
MessageBox.Show("Отчет успешно сформирован!");
Process.Start(pathDocumentXLSX);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
worKsheeT = null;
celLrangE = null;
worKbooK = null;
}
break;
case (".pdf"):
string pathDocumentPDF = Session.baseDir + "Учет о животных" + extension;
if (File.Exists(Session.baseDir + "Учет о животных.docx"))
{
Word.Application appWord = new Word.Application();
var wordDocument = appWord.Documents.Open(Session.baseDir + "Учет о животных.docx");
wordDocument.ExportAsFixedFormat(pathDocumentPDF, Word.WdExportFormat.wdExportFormatPDF);
MessageBox.Show("Отчет успешно сформирован!");
wordDocument.Close();
Process.Start(pathDocumentPDF);
}
else
MessageBox.Show("Сначала сформируйте отчет .docx");
break;
}
}
catch (Exception)
{
MessageBox.Show("Отсутсвие Ms Office на компьютере. Пожалуйста скачайте его.");
Process.Start("https://www.microsoft.com/ru-ru/microsoft-365/compare-all-microsoft-365-products?tab=1&rtc=1");
}
}
private void ButtonExport_Click(object sender, RoutedEventArgs e)
{
Thread t = new Thread(new ThreadStart(createExportDoc));
t.Start();
}
private void ComboBoxExport_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBoxItem typeItem = (ComboBoxItem)comboBoxExport.SelectedItem;
extension = typeItem.Content.ToString();
}
}
}
using ZooMail.Models;
using System;
using Microsoft.Win32;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;
using ZooMail.PersonalAccounting;
namespace ZooMail
{
/// <summary>
/// Логика взаимодействия для AuthorizationWindow.xaml
/// </summary>
public partial class AuthorizationWindow : Window
{
public AuthorizationWindow()
{
InitializeComponent();
}
private void Button_Test_Click(object sender, RoutedEventArgs e)
{
Session.currentUser = null;
var users = new DBManager().getAuthorizationList();
foreach (var user in users)
{
if (user.Login == txtBoxLog.Text && user.Password == txtBoxPas.Password)
{
Session.currentUser = user;
PersonalAccountWindow clientPersonal = new PersonalAccountWindow();
clientPersonal.Show();
if (Session.mainWindow != null)
{
Session.mainWindow.Close();
}
Close();
return;
}
}
MessageBox.Show("Ошибка в логине или пароле!");
}
private void Button_Registarion_Click(object sender, RoutedEventArgs e)
{
new RegistrationWindow(null).ShowDialog();
}
}
}
using ZooMail.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Xceed.Words.NET;
using Xceed.Document.NET;
using Word = Microsoft.Office.Interop.Word;
using Excel = Microsoft.Office.Interop.Excel;
using System.Threading;
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;
using System.Diagnostics;
using System.IO;
using ZooMail.PersonalAccounting;
namespace ZooMail
{
/// <summary>
/// Логика взаимодействия для ClientListWindow.xaml
/// </summary>
public partial class ClientListWindow : Window
{
public ClientListWindow()
{
InitializeComponent();
}
List<Models.ModelClientDetail> listClient;
public string extension = string.Empty;
private void updateData()
{
listClient = (new DBManager()).getClientListDetail();
dataGridClients.ItemsSource = listClient;
}
private void Window_Activated(object sender, EventArgs e)
{
updateData();
}
private void ButtonDetail_Click(object sender, RoutedEventArgs e)
{
int selectedIndex = dataGridClients.SelectedIndex;
if (selectedIndex < 0)
{
MessageBox.Show("Не выбран клиент");
return;
}
var ap = new DBManager().getClientList();
Models.ModelClient modelClient = null;
foreach (var it in ap)
{
if (it.ID_Authorization == listClient[selectedIndex].ID_Authorization)
{
modelClient = it;
break;
}
}
var ce = new RegistrationWindow(modelClient, true);
ce.ShowDialog();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.IO;
using System.Diagnostics;
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;
using System.Data.SqlClient;
using Xceed.Words.NET;
using Xceed.Document.NET;
using Word = Microsoft.Office.Interop.Word;
using Excel = Microsoft.Office.Interop.Excel;
using System.Threading;
namespace ZooMail.EmployeeSpravochnik
{
/// <summary>
/// Логика взаимодействия для EmployeeSpravochnik.xaml
/// </summary>
public partial class EmployeeSpravochnik : Window
{
List<Models.ModelEmployee> Employees;
public string extension = string.Empty;
private string QR = "";
public EmployeeSpravochnik()
{
InitializeComponent();
}
private void Window_Activated(object sender, EventArgs e)
{
Employees = (new DBManager()).getEmployeeList();
dataGridEmployeeSpravichnic.ItemsSource = Employees;
}
private void ButtonEdit_Click(object sender, RoutedEventArgs e)
{
int selectedIndex = dataGridEmployeeSpravichnic.SelectedIndex;
if (selectedIndex < 0)
{
MessageBox.Show("Не выбран сотрудник для редактирования");
return;
}
var ap = new DBManager().getEmployeeList();
Models.ModelEmployee modelEmployee = null;
foreach (var it in ap)
{
if (it.ID_Authorization == Employees[selectedIndex].ID_Authorization)
{
modelEmployee = it;
break;
}
}
var ce = new EmployeeSpravochnikEdit(modelEmployee);
ce.ShowDialog();
}
private void ButtonAdd_Click(object sender, RoutedEventArgs e)
{
var ce = new EmployeeSpravochnikEdit(null);
ce.ShowDialog();
}
public class ModelAnimalpark