public void Button_Save(object sender, RoutedEventArgs e) { List <BD.Managers> manager = new List <BD.Managers>(); using (CRMContext dbContext = new CRMContext()) { foreach (var item in dbContext.Managers) { manager.Add(item); } } XMLE.XML.Save_Managers(manager); }
private void Button_Save(object sender, RoutedEventArgs e) { List <BD.Tasks> task = new List <BD.Tasks>(); using (CRMContext dbContext = new CRMContext()) { foreach (var item in dbContext.Tasks) { task.Add(item); } } XMLE.XML.Save_Tasks(task); }
private void Button_Save(object sender, RoutedEventArgs e) { List <BD.Clients> clients = new List <BD.Clients>(); using (CRMContext dbContext = new CRMContext()) { foreach (var item in dbContext.Clients) { clients.Add(item); } } XMLE.XML.Save_Clients(clients); }
private void button_Click(object sender, RoutedEventArgs e) { try { using (CRMContext dbContext = new CRMContext()) { var position = new BD.CatalogPositions(); position.Position = l_position.Text; if (l_pay.Text != "") { position.Pay = Convert.ToDecimal(l_pay.Text); } else { position.Pay = Convert.ToDecimal(1); } var results = new List <System.ComponentModel.DataAnnotations.ValidationResult>(); var context = new ValidationContext(position); if (!Validator.TryValidateObject(position, context, results, true)) { foreach (var error in results) { MessageBox.Show(error.ErrorMessage); } } else { try { dbContext.CatalogPositions.Add(position); dbContext.SaveChanges(); } catch { MessageBox.Show("Ошибка"); } } if (Validator.TryValidateObject(position, context, results, true)) { this.Close(); } } this.Close(); } catch { MessageBox.Show("Неверно введены данные"); } }
/// <summary> /// Удаление клиента из базы /// </summary> /// <param name="client"></param> private void DeleteClient(Client client) { using (var dataBase = new CRMContext()) { Client tempClient = dataBase.Clients .Where(o => o.Id == client.Id) .FirstOrDefault(); if (tempClient != null) { dataBase.Clients.Remove(tempClient); dataBase.SaveChanges(); } } }
private List <Person> GenerateData() { using (CRMContext dbContext = new CRMContext()) { List <Person> personList = new List <Person>(); foreach (var item in dbContext.Managers) { personList.Add(new Person { Name = item.Name.ToString() }); } return(personList); } }
public Clients(ref Grid rG) { InitializeComponent(); Menu m = new Menu(rG, p_Clients); G1.Children.Add(m); using (CRMContext dbContext = new CRMContext()) { foreach (var item in dbContext.Clients) { dg_Clients.Items.Add(item); } } }
public Add_Manager() { InitializeComponent(); using (CRMContext dbContext = new CRMContext()) { foreach (var item in dbContext.CatalogPositions) { cb_position.Items.Add(item.Position); } foreach (var item in dbContext.CatalogGroupManagers) { cb_group.Items.Add(item.Group); } } }
/// <summary> /// Удаление заказа из базы /// </summary> /// <param name="order"></param> private void DeleteOrder(Order order) { using (var dataBase = new CRMContext()) { Order tempOrder = dataBase.Orders .Where(o => o.Id == order.Id) .FirstOrDefault(); if (tempOrder != null) { dataBase.Orders.Remove(tempOrder); dataBase.SaveChanges(); } } }
public Change_Client(BD.Clients client) { InitializeComponent(); using (CRMContext dbContext = new CRMContext()) { tb_name.Text = client.Name; tb_address.Text = client.Address; tb_phone.Text = client.Phone; tb_email.Text = client.Email; tb_checkingAccoubt.Text = client.CheckingAccount; tb_bank.Text = client.Bank; tb_director.Text = client.Director; tb_acccountant.Text = client.Accountant; tb_info.Text = client.Info; del_client = client; } }
public Tasks(ref Grid rG) { InitializeComponent(); Menu m = new Menu(rG, p_Tasks); G1.Children.Add(m); using (CRMContext dbContext = new CRMContext()) { foreach (var item in dbContext.Tasks) { if (IAm.isAdmin || IAm.myName == item.Manager) { dg_Tasks.Items.Add(item); } } } }
private void button_Click(object sender, RoutedEventArgs e) { try { if (del_obj != null) { using (CRMContext dbContext = new CRMContext()) { dbContext.Entry(del_obj).State = System.Data.Entity.EntityState.Deleted; dbContext.SaveChanges(); } } this.Close(); } catch (Exception) { MessageBox.Show("Ошибка! Имеются записи, которые зависят от этой записи!"); } }
private void button_Click(object sender, RoutedEventArgs e) { using (CRMContext dbContext = new CRMContext()) { var task = new BD.Tasks(); Random rnd = new Random(); try { int i = 1 + rnd.Next(10000); task.Id = i; } catch (Exception) { MessageBox.Show("Повторите попытку"); } task.Client = l_client.Text; task.Manager = l_manager.Text; task.Task = l_task.Text; task.Info = l_info.Text; task.Status = l_status.Text; task.DateStart = d_start.SelectedDate; task.DateComplete = d_complete.SelectedDate; var results = new List <System.ComponentModel.DataAnnotations.ValidationResult>(); var context = new ValidationContext(task); if (!Validator.TryValidateObject(task, context, results, true)) { foreach (var error in results) { MessageBox.Show(error.ErrorMessage); } } else { dbContext.Tasks.Add(task); dbContext.SaveChanges(); } if (Validator.TryValidateObject(task, context, results, true)) { this.Close(); } } }
private void button_Click(object sender, RoutedEventArgs e) { using (CRMContext dbContext = new CRMContext()) { var group = new BD.CatalogGroupManagers(); Random rnd = new Random(); try { int i = 1 + rnd.Next(10000); group.Group = l_id.Text; group.Id = i; } catch (Exception) { MessageBox.Show("Повторите попытку"); } var results = new List <System.ComponentModel.DataAnnotations.ValidationResult>(); var context = new ValidationContext(group); if (!Validator.TryValidateObject(group, context, results, true)) { foreach (var error in results) { MessageBox.Show(error.ErrorMessage); } } else { try { dbContext.CatalogGroupManagers.Add(group); dbContext.SaveChanges(); } catch { MessageBox.Show("Ошибка"); } } if (Validator.TryValidateObject(group, context, results, true)) { this.Close(); } } }
/// <summary> /// Начальное заполнение списков данными из базы /// </summary> private void Connect() { ClientsList.Clear(); OrdersList.Clear(); using (var dataBase = new CRMContext()) { var Clients = dataBase.Clients; var Orders = dataBase.Orders; foreach (Client client in Clients) { ClientsList.Add(client); } foreach (Order order in Orders) { OrdersList.Add(order); } } }
private void button_Click(object sender, RoutedEventArgs e) { using (CRMContext dbContext = new CRMContext()) { del_client.Name = tb_name.Text; del_client.Address = tb_address.Text; del_client.Phone = tb_phone.Text; del_client.Email = tb_email.Text; del_client.CheckingAccount = tb_checkingAccoubt.Text; del_client.Bank = tb_bank.Text; del_client.Director = tb_director.Text; del_client.Accountant = tb_acccountant.Text; del_client.Info = tb_info.Text; var results = new List <System.ComponentModel.DataAnnotations.ValidationResult>(); var context = new ValidationContext(del_client); if (!Validator.TryValidateObject(del_client, context, results, true)) { foreach (var error in results) { MessageBox.Show(error.ErrorMessage); } } else { try { dbContext.Entry(del_client).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); } catch { MessageBox.Show("Ошибка!"); } } if (Validator.TryValidateObject(del_client, context, results, true)) { this.Close(); } } }
private void Button_Click_1(object sender, RoutedEventArgs e) { using (CRMContext dbContext = new CRMContext()) { foreach (var item in dbContext.Tasks) { dbContext.Entry(item).State = System.Data.Entity.EntityState.Deleted; } foreach (var item in dbContext.Managers) { if (item.Name != "Харсеко Никита Игоревич") { dbContext.Entry(item).State = System.Data.Entity.EntityState.Deleted; } } foreach (var item in dbContext.Clients) { dbContext.Entry(item).State = System.Data.Entity.EntityState.Deleted; } dbContext.SaveChanges(); } }
private void button_Click(object sender, RoutedEventArgs e) { using (CRMContext dbContext = new CRMContext()) { del_task.Client = l_client.Text; del_task.Manager = l_manager.Text; del_task.Task = l_task.Text; del_task.Info = l_info.Text; del_task.Status = l_status.Text; del_task.DateStart = d_start.SelectedDate; del_task.DateComplete = d_complete.SelectedDate; var results = new List <System.ComponentModel.DataAnnotations.ValidationResult>(); var context = new ValidationContext(del_task); if (!Validator.TryValidateObject(del_task, context, results, true)) { foreach (var error in results) { MessageBox.Show(error.ErrorMessage); } } else { try { dbContext.Entry(del_task).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); } catch { MessageBox.Show("Ошибка!"); } } if (Validator.TryValidateObject(del_task, context, results, true)) { this.Close(); } } }
public ChangeCatalog() { InitializeComponent(); using (CRMContext dbContext = new CRMContext()) { foreach (var item in dbContext.CatalogGroupManagers) { dg_cGroup.Items.Add(item); } foreach (var item in dbContext.CatalogPositions) { dg_cPositions.Items.Add(item); } foreach (var item in dbContext.CatalogStatus) { dg_cStatus.Items.Add(item); } foreach (var item in dbContext.CatalogTasks) { dg_cTask.Items.Add(item); } } }
public Add() { InitializeComponent(); using (CRMContext dbContext = new CRMContext()) { foreach (var item in dbContext.CatalogTasks) { l_task.Items.Add(item.Task); } foreach (var item in dbContext.CatalogStatus) { l_status.Items.Add(item.Status); } foreach (var item in dbContext.Managers) { l_manager.Items.Add(item.Name); } foreach (var item in dbContext.Clients) { l_client.Items.Add(item.Name); } } }
private void button_Click(object sender, RoutedEventArgs e) { using (CRMContext dbContext = new CRMContext()) { position.Position = l_id.Text; position.Pay = Convert.ToInt16(l_id_Copy.Text); var results = new List <System.ComponentModel.DataAnnotations.ValidationResult>(); var context = new ValidationContext(position); if (!Validator.TryValidateObject(position, context, results, true)) { foreach (var error in results) { MessageBox.Show(error.ErrorMessage); } } else { try { dbContext.Entry(position).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); } catch { MessageBox.Show("Ошибка!"); } } if (Validator.TryValidateObject(position, context, results, true)) { this.Close(); } } this.Close(); }
public CustomerController(CRMContext context) { _context = context; }
public EmployeeController(CRMContext context) { _context = context; }
public LeadController(CRMContext context) { _context = context; }
public Param(ref Grid rG) { InitializeComponent(); Menu m = new Menu(rG, p_Param); G1.Children.Add(m); using (CRMContext dbContext = new CRMContext()) { int cl = 0, ma = 0, ta = 0, tcp = 0, tnp = 0, tp = 0, tc = 0, mt = 0, mw = 0, mm = 0; foreach (var item in dbContext.Clients) { cl++; } foreach (var item in dbContext.Managers) { ma++; if (item.DateRecruitment <= DateTime.Today && item.DateRecruitment > (DateTime.Today).AddDays(-1)) { mt++; } if (item.DateRecruitment <= (DateTime.Today).AddDays(-1) && item.DateRecruitment >= (DateTime.Today).AddDays(-7)) { mw++; } if (item.DateRecruitment <= (DateTime.Today).AddDays(-7) && item.DateRecruitment >= (DateTime.Today).AddMonths(-1)) { mm++; } } foreach (var item in dbContext.Tasks) { ta++; if (item.CatalogStatus.Status == "Выполнена") { tcp++; } if (item.CatalogStatus.Status == "Отменена") { tc++; } if (item.CatalogStatus.Status == "Не выполнена") { tnp++; } if (item.CatalogStatus.Status == "В процессе") { tp++; } } countTask.Content = ta; countClients.Content = cl; countManagers.Content = ma; countComplete.Content = tcp; countCancel.Content = tc; countNoComplete.Content = tnp; countInProcess.Content = tp; countManToday.Content = mt; countManWeek.Content = mw; countManMonth.Content = mm; } }
private void search_task_TextChanged(object sender, TextChangedEventArgs e) { using (CRMContext dbContext = new CRMContext()) { dg_Tasks.Items.Clear(); foreach (var item in dbContext.Tasks) { string search = Convert.ToString(search_task.Text).ToLower(); if (search_task.Text == "") { dg_Tasks.Visibility = Visibility.Collapsed; } else if ((item.Task.ToString().ToLower()).Contains(search) || (item.Id.ToString()).Contains(search) || (item.Client.ToString().ToLower()).Contains(search) || (item.Manager.ToString().ToLower()).Contains(search) || (item.Info.ToString().ToLower()).Contains(search) || (item.DateStart.ToString().ToLower()).Contains(search) || (item.DateComplete.ToString().Contains(search)) || (item.Status.ToString().ToLower()).Contains(search)) { dg_Tasks.Visibility = Visibility.Visible; dg_Tasks.Items.Add(item); } else if (dg_Tasks.Items.Count == 0) { dg_Tasks.Visibility = Visibility.Collapsed; } } dg_Clients.Items.Clear(); foreach (var item in dbContext.Clients) { string search = Convert.ToString(search_task.Text).ToLower(); if (search_task.Text == "") { dg_Clients.Visibility = Visibility.Collapsed; } else if (item.Name.ToString().ToLower().Contains(search) || (item.Address.ToString().ToLower()).Contains(search) || (item.Phone.ToString().ToLower()).Contains(search) || (item.Email.ToString().ToLower()).Contains(search) || (item.CheckingAccount.ToString().ToLower()).Contains(search) || (item.Bank.ToString().ToLower()).Contains(search) || (item.Director.ToString().ToLower()).Contains(search) || (item.Accountant.ToString().ToLower()).Contains(search)) //|| (item.Info.ToString().ToLower()).Contains(search)) { dg_Clients.Visibility = Visibility.Visible; dg_Clients.Items.Add(item); } else if (dg_Clients.Items.Count == 0) { dg_Clients.Visibility = Visibility.Collapsed; } } dg_Managers.Items.Clear(); foreach (var item in dbContext.Managers) { string search = Convert.ToString(search_task.Text).ToLower(); if (search_task.Text == "") { dg_Managers.Visibility = Visibility.Collapsed; } else if (item.Name.ToString().ToLower().Contains(search) || (item.Login.ToString().ToLower()).Contains(search) || (item.Password.ToString().ToLower()).Contains(search) || (item.Position.ToString().ToLower()).Contains(search) || (item.Group.ToString().ToLower()).Contains(search) || (item.Address.ToString().ToLower()).Contains(search) || (item.Phone.ToString().ToLower()).Contains(search) || (item.Passport.ToString().ToLower()).Contains(search) || (item.DateOfBirth.ToString().ToLower()).Contains(search) || (item.DateRecruitment.ToString().ToLower()).Contains(search) || (item.Email.ToString().ToLower()).Contains(search) || (item.Info.ToString().ToLower()).Contains(search)) { dg_Managers.Visibility = Visibility.Visible; dg_Managers.Items.Add(item); } else if (dg_Managers.Items.Count == 0) { dg_Managers.Visibility = Visibility.Collapsed; } } } }