Сделай Сам Свою Работу на 5

листинг основных программных модулей





Интернет сервис PECHService.svc.cs

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.Text;

 

namespace PECHClientApp.Web

{

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "PECHService" in code, svc and config file together.

public class PECHService : IPECHService

{

public string Authorization(string login, string password)

{

return (new PECHDBEntities()).Пользователи.Where(x => x.Логин == login && x.Пароль == password).Select(x => x.Фамилия_и_имя).FirstOrDefault();

}

 

public string Registration(string login, string password, string name)

{

if (login != "" && password != "" && name != "" && login != null && password != null && name != null)

{

if (!(new PECHDBEntities()).Пользователи.Where(x => x.Логин == login).Any())

{

PECHDBEntities ent = new PECHDBEntities();

Пользователи polz = new Пользователи();

polz.Фамилия_и_имя = name;

polz.Логин = login;

polz.Пароль = password;

polz.УИН_Роли = 1;

 

ent.Пользователи.AddObject(polz);

ent.SaveChanges();

 

return name;

}

return "Пользователь уже существует";

}

return "Неверные данные";

}

 

public List<Выполняемые_функции> GetAllFunctions()

{

return (new PECHDBEntities()).Выполняемые_функции.ToList();

}

 

public List<Типы_энергии> GetAllEnergy()

{

return (new PECHDBEntities()).Типы_энергии.ToList();

}

 

public List<Типы_докумннтов> GetAllDocumentType()



{

return (new PECHDBEntities()).Типы_докумннтов.ToList();

}

 

public List<Физические_эффекты> GetPhysicalEffects(int functionId, int EnergyId)

{

PECHDBEntities ent = new PECHDBEntities();

 

if (functionId != 0 && EnergyId != 0)

{

var t = ent.Физические_эффекты.Where(

x => x.Выполняемые_функции_Физических_эффектов.Where(y => y.УИН_Выполняемой_функции == functionId).Count() != 0 &&

x.Типы_энергии_Физических_эффектов.Where(z => z.УИН_Типа_энергии == EnergyId).Count() != 0

);

 

foreach (var item in t)

{

item.Количество_просмотров++;

}

 

ent.SaveChanges();

 

return t.ToList();

}

else if (functionId == 0 && EnergyId != 0)

{

var t = ent.Физические_эффекты.Where(x=>

x.Типы_энергии_Физических_эффектов.Where(z => z.УИН_Типа_энергии == EnergyId).Count() != 0

);

 

foreach (var item in t)

{

item.Количество_просмотров++;

}

 

ent.SaveChanges();

 

return t.ToList();

}

if (functionId != 0 && EnergyId == 0)

{

var t = ent.Физические_эффекты.Where(

x => x.Выполняемые_функции_Физических_эффектов.Where(y => y.УИН_Выполняемой_функции == functionId).Count() != 0

);

 

foreach (var item in t)

{

item.Количество_просмотров++;

}

 

ent.SaveChanges();

 

return t.ToList();

}

else

{

var t = ent.Физические_эффекты;



 

foreach (var item in t)

{

item.Количество_просмотров++;

}

 

ent.SaveChanges();

 

return t.ToList();

}

}

 

public List<Документы> GetDocuments(int physicalEffectId, int documentTypeId)

{

PECHDBEntities ent = new PECHDBEntities();

 

if (physicalEffectId != 0 && documentTypeId != 0)

{

var t=ent.Документы.Where(x => x.Документ_и_Физический_эффект.Where(

y => y.УИН_Физического_эффекта == physicalEffectId).Count() != 0 &&

x.УИН_Типа_документа == documentTypeId

);

 

foreach (var item in t)

{

item.Количество_просмотров++;

}

 

ent.SaveChanges();

 

return t.ToList();

}

else if (physicalEffectId == 0 && documentTypeId != 0)

{

var t = ent.Документы.Where(x =>

x.УИН_Типа_документа == documentTypeId

);

 

foreach (var item in t)

{

item.Количество_просмотров++;

}

 

ent.SaveChanges();

 

return t.ToList();

}

else if (physicalEffectId != 0 && documentTypeId == 0)

{

var t = ent.Документы.Where(x => x.Документ_и_Физический_эффект.Where(

y => y.УИН_Физического_эффекта == physicalEffectId).Count() != 0

);

 

foreach (var item in t)

{

item.Количество_просмотров++;

}

 

ent.SaveChanges();

 

return t.ToList();

}

else

{

var t = ent.Документы;

 

foreach (var item in t)

{

item.Количество_просмотров++;

}

 

ent.SaveChanges();

 

return t.ToList();

}

 

}

 

public List<Физические_эффекты> GetTop10PhysEff()

{

return (new PECHDBEntities()).Физические_эффекты.Top("10").OrderByDescending(x => x.Количество_просмотров).ToList();

}

 

public List<Документы> GetTop10Docs()

{

return (new PECHDBEntities()).Документы.Top("10").OrderByDescending(x => x.Количество_просмотров).ToList();

}

}

}

 

Главная страница приложения Home.xaml.cs

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Navigation;

using System.Windows.Shapes;



using PECHClientApp.PECHServiceReference;

 

namespace PECHClientApp

{

public partial class Home : Page

{

public Home()

{

InitializeComponent();

}

 

bool one = false;

bool two = false;

bool three = false;

bool four = false;

 

// Executes when the user navigates to this page.

protected override void OnNavigatedTo(NavigationEventArgs e)

{

PECHServiceClient cli = new PECHServiceClient();

 

cli.GetAllFunctionsCompleted += new EventHandler<GetAllFunctionsCompletedEventArgs>(cli_GetAllFunctionsCompleted);

cli.GetAllFunctionsAsync();

 

cli.GetAllEnergyCompleted += new EventHandler<GetAllEnergyCompletedEventArgs>(cli_GetAllEnergyCompleted);

cli.GetAllEnergyAsync();

}

 

void cli_GetAllEnergyCompleted(object sender, GetAllEnergyCompletedEventArgs e)

{

e.Result.Add(new Типы_энергии() { Название = "Все" });

comboBox2.ItemsSource = e.Result;

}

 

void cli_GetAllFunctionsCompleted(object sender, GetAllFunctionsCompletedEventArgs e)

{

e.Result.Add(new Выполняемые_функции() { Название = "Все" });

comboBox1.ItemsSource = e.Result;

}

 

private void button1_Click(object sender, RoutedEventArgs e)

{

PECHServiceClient cli = new PECHServiceClient();

 

cli.GetPhysicalEffectsCompleted += new EventHandler<GetPhysicalEffectsCompletedEventArgs>(cli_GetPhysicalEffectsCompleted);

 

if (comboBox1.SelectedValue.ToString() != "Все" && comboBox2.SelectedValue.ToString() != "Все")

{

cli.GetPhysicalEffectsAsync(((Выполняемые_функции)comboBox1.SelectedValue).УИН_Вполняемой_функции, ((Типы_энергии)comboBox2.SelectedValue).УИН_Типа_эергии);

}

else if (comboBox1.SelectedValue.ToString() == "Все" && comboBox2.SelectedValue.ToString() != "Все")

{

cli.GetPhysicalEffectsAsync(0, ((Типы_энергии)comboBox2.SelectedValue).УИН_Типа_эергии);

}

else if (comboBox1.SelectedValue.ToString() != "Все" && comboBox2.SelectedValue.ToString() == "Все")

{

cli.GetPhysicalEffectsAsync(((Выполняемые_функции)comboBox1.SelectedValue).УИН_Вполняемой_функции, 0);

}

else if (comboBox1.SelectedValue.ToString() == "Все" && comboBox2.SelectedValue.ToString() == "Все")

{

cli.GetPhysicalEffectsAsync(0, 0);

}

 

}

 

void cli_GetPhysicalEffectsCompleted(object sender, GetPhysicalEffectsCompletedEventArgs e)

{

e.Result.Add(new Физические_эффекты() { Название = "Все" });

comboBox3.ItemsSource = e.Result;

comboBox3.IsEnabled = true;

 

PECHServiceClient cli = new PECHServiceClient();

cli.GetAllDocumentTypeCompleted += new EventHandler<GetAllDocumentTypeCompletedEventArgs>(cli_GetAllDocumentTypeCompleted);

cli.GetAllDocumentTypeAsync();

}

 

void cli_GetAllDocumentTypeCompleted(object sender, GetAllDocumentTypeCompletedEventArgs e)

{

e.Result.Add(new Типы_докумннтов() { Назввание = "Все" });

comboBox4.ItemsSource = e.Result;

comboBox4.IsEnabled = true;

}

 

private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)

{

one = true;

 

if (one && two)

{

button1.IsEnabled = true;

}

}

 

private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)

{

two = true;

 

if (one && two)

{

button1.IsEnabled = true;

}

}

 

private void comboBox3_SelectionChanged(object sender, SelectionChangedEventArgs e)

{

three = true;

 

if (three && four)

{

button2.IsEnabled = true;

}

}

 

private void comboBox4_SelectionChanged(object sender, SelectionChangedEventArgs e)

{

four = true;

 

if (three && four)

{

button2.IsEnabled = true;

}

}

 

private void button2_Click(object sender, RoutedEventArgs e)

{

PECHServiceClient cli = new PECHServiceClient();

 

cli.GetDocumentsCompleted += new EventHandler<GetDocumentsCompletedEventArgs>(cli_GetDocumentsCompleted);

if (comboBox3.SelectedValue.ToString() != "Все" && comboBox4.SelectedValue.ToString() != "Все")

{

cli.GetDocumentsAsync(((Физические_эффекты)comboBox3.SelectedValue).УИН_Физического_эффекта, ((Типы_докумннтов)comboBox4.SelectedValue).УИН_Типа_документа);

}

else if (comboBox3.SelectedValue.ToString() == "Все" && comboBox4.SelectedValue.ToString() != "Все")

{

cli.GetDocumentsAsync(0, ((Типы_докумннтов)comboBox4.SelectedValue).УИН_Типа_документа);

}

else if (comboBox3.SelectedValue.ToString() != "Все" && comboBox4.SelectedValue.ToString() == "Все")

{

cli.GetDocumentsAsync(((Физические_эффекты)comboBox3.SelectedValue).УИН_Физического_эффекта, 0);

}

else if (comboBox3.SelectedValue.ToString() == "Все" && comboBox4.SelectedValue.ToString() == "Все")

{

cli.GetDocumentsAsync(0,0);

}

}

 

void cli_GetDocumentsCompleted(object sender, GetDocumentsCompletedEventArgs e)

{

dataGrid1.ItemsSource = e.Result;

}

}

}

 

 

 








Не нашли, что искали? Воспользуйтесь поиском по сайту:



©2015 - 2024 stydopedia.ru Все материалы защищены законодательством РФ.