Files
BeWoPlaner/BeWo/View/ChatServiceEmployee.xaml.cs
2016-11-18 17:05:52 +01:00

177 lines
4.9 KiB
C#

using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Threading;
using BeWo.Core;
using BeWo.ViewModel;
using BeWo.ServiceProxy;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
using BS.Shared;
using BS.Shared.Core;
using Microsoft.Win32;
namespace BeWo.View
{
public partial class ChatServiceEmployee
{
private CustomerVM _ViewModel;
long? employeeOid;
public ChatServiceEmployee(TableID pObjectTid, long? oid)
{
InitializeComponent();
employeeOid = oid;
LaodInfostoView();
}
public CustomerVM PublicViewModel { get { return _ViewModel; } }
public override bool IsDirty
{
get
{
return ViewModel != null && ViewModel.IsDirty;
}
}
private CustomerVM ViewModel
{
get { return _ViewModel; }
set
{
DataContext = value;
_ViewModel = value;
}
}
private void GenerateCodeClick(object sender, RoutedEventArgs e)
{
if (!GeneratetTexfield.Text.Equals(""))
{
if (MessageBox.Show("Wollen sie wirklich ihren Code ändern?", "Achtung", MessageBoxButton.YesNo,
MessageBoxImage.Question) == MessageBoxResult.Yes)
{
var result = ServiceFacade.DoOperationsServiceSync(s => s.CreateNewEmployeeAPPCodeDC(employeeOid.Value));
GeneratetTexfield.Text = result.EmployeeCode;
}
}
else
{
var result = ServiceFacade.DoOperationsServiceSync(s => s.CreateNewEmployeeAPPCodeDC(employeeOid.Value));
GeneratetTexfield.Text = result.EmployeeCode;
}
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
ServiceFacade.DoOperationsServiceSync(s => s.UpdateIsChatActiveEmployeeAPPCodeDC(employeeOid.Value, 1));
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
ServiceFacade.DoOperationsServiceSync(s => s.UpdateIsChatActiveEmployeeAPPCodeDC(employeeOid.Value, 0));
}
private void Creat_NotfallMessage(object sender, RoutedEventArgs e)
{
if(!NotfallTexfield.Text.Equals(""))
ServiceFacade.DoOperationsServiceSync(s => s.UpdateNotfallNacrichtEmployeeAPPCodeDC(employeeOid.Value, NotfallTexfield.Text));
}
private void LaodInfostoView()
{
var getEmployeeAppCode = ServiceFacade.DoEmployeeServiceSync(s => s.GetAllEmployeeAppCodes(employeeOid.Value));
/* String a = "";
String b = "";
bool c = false;
*/
int x;
if (getEmployeeAppCode.Count > 0){
x = getEmployeeAppCode[getEmployeeAppCode.Count - 1].IsChatAktive;
GeneratetTexfield.Text = getEmployeeAppCode[getEmployeeAppCode.Count - 1].EmployeeCode;
// a = getEmployeeAppCode[getEmployeeAppCode.Count - 1].EmployeeCode;
NotfallTexfield.Text = getEmployeeAppCode[0].NotfallStatement;
//b = getEmployeeAppCode[0].NotfallStatement;
}
else
x = 0;
if (x == 0)
{
ChatAktive.SetCurrentValue(CheckBox.IsCheckedProperty, false);
//c = false;
}
else
{
ChatAktive.SetCurrentValue(CheckBox.IsCheckedProperty, true);
// c = true;
}
// ChatServiceBuilder builder = new ChatServiceBuilder(c,b,a);
}
}
public class ChatServiceBuilder
{
public ChatServiceBuilder(bool isChecked, string notfallstatement, string code)
{
IsChecked = isChecked;
Notfallstatement = notfallstatement;
Code = code;
}
public bool IsChecked { get; set; }
public string Notfallstatement { get; set; }
/* get { return _Notfallstatement; }
set
{
if (value != _Notfallstatement)
{
_Notfallstatement = value;
OnPropertyChanged("Notfallstatement");
}
}*/
public string Code { get; set; }
}
}