mirror of
https://github.com/DevExpress/netcore-winforms-demos.git
synced 2025-12-29 12:59:21 +00:00
19.1.3-ctp
This commit is contained in:
committed by
GitHub
parent
2e45b5d38f
commit
a2371dfb0b
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class TaskAttachedFile : DatabaseObject {
|
||||
public virtual EmployeeTask EmployeeTask { get; set; }
|
||||
public long? EmployeeTaskId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public byte[] Content { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
#if !REALTORWORLDDEMO
|
||||
#if !DXCORE3
|
||||
using System.Deployment.Application;
|
||||
#endif
|
||||
using System.Windows.Interop;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Security;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32;
|
||||
#endif
|
||||
|
||||
namespace DevExpress.Internal {
|
||||
#if DEVAV
|
||||
public class DevAVDataDirectoryHelper {
|
||||
#else
|
||||
public class DataDirectoryHelper {
|
||||
#endif
|
||||
#if !REALTORWORLDDEMO && !DXCORE3
|
||||
static bool? _isClickOnce = null;
|
||||
|
||||
public static bool IsClickOnce {
|
||||
get {
|
||||
if(_isClickOnce == null) {
|
||||
#if DEBUG && !CLICKONCE
|
||||
_isClickOnce = false;
|
||||
#else
|
||||
_isClickOnce = !BrowserInteropHelper.IsBrowserHosted && ApplicationDeployment.IsNetworkDeployed;
|
||||
#endif
|
||||
}
|
||||
return (bool)_isClickOnce;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
public static string GetDataDirectory() {
|
||||
#if DXCORE3
|
||||
return GetEntryAssemblyDirectory();
|
||||
#else
|
||||
#if REALTORWORLDDEMO
|
||||
return AppDomain.CurrentDomain.BaseDirectory;
|
||||
#else
|
||||
return IsClickOnce
|
||||
? ApplicationDeployment.CurrentDeployment.DataDirectory
|
||||
: GetEntryAssemblyDirectory();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
public const string DataFolderName = "Data";
|
||||
public static string GetFile(string fileName, string directoryName) {
|
||||
if(DataPath != null)
|
||||
return Path.Combine(DataPath, fileName);
|
||||
string dataDirectory = GetDataDirectory();
|
||||
if(dataDirectory == null) return null;
|
||||
string dirName = Path.GetFullPath(dataDirectory);
|
||||
for(int n = 0; n < 9; n++) {
|
||||
string path = dirName + "\\" + directoryName + "\\" + fileName;
|
||||
try {
|
||||
if(File.Exists(path) || Directory.Exists(path))
|
||||
return path;
|
||||
} catch { }
|
||||
dirName += @"\..";
|
||||
}
|
||||
throw new FileNotFoundException(string.Format("{0} not found. ({1})", fileName, dirName));
|
||||
}
|
||||
public static string GetDirectory(string directoryName) {
|
||||
string dataDirectory = GetDataDirectory();
|
||||
if(dataDirectory == null) return null;
|
||||
string dirName = Path.GetFullPath(dataDirectory);
|
||||
for(int n = 0; n < 9; n++) {
|
||||
string path = dirName + "\\" + directoryName;
|
||||
try {
|
||||
if(Directory.Exists(path))
|
||||
return path;
|
||||
} catch { }
|
||||
dirName += @"\..";
|
||||
}
|
||||
throw new DirectoryNotFoundException(directoryName + " not found");
|
||||
}
|
||||
#if !REALTORWORLDDEMO
|
||||
public static void SetWebBrowserMode() {
|
||||
try {
|
||||
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
|
||||
if(key == null)
|
||||
key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION");
|
||||
if(key != null)
|
||||
key.SetValue(Path.GetFileName(Process.GetCurrentProcess().ProcessName + ".exe"), 0, RegistryValueKind.DWord); //Latest IE
|
||||
} catch { }
|
||||
}
|
||||
public static string LocalPrefix { get; set; }
|
||||
public static string DataPath { get; set; }
|
||||
public static string GetFileLocalCopy(string fileName, string directoryName) {
|
||||
if(string.IsNullOrEmpty(LocalPrefix))
|
||||
throw new InvalidOperationException();
|
||||
string localName = LocalPrefix + fileName;
|
||||
string filePath = GetFile(fileName, directoryName);
|
||||
string fileDirectoryPath = Path.GetDirectoryName(filePath);
|
||||
string localFilePath = Path.Combine(fileDirectoryPath, localName);
|
||||
if(File.Exists(localFilePath)) return localFilePath;
|
||||
File.Copy(filePath, localFilePath);
|
||||
FileAttributes attributes = File.GetAttributes(localFilePath);
|
||||
if((attributes & FileAttributes.ReadOnly) != 0)
|
||||
File.SetAttributes(localFilePath, attributes & ~FileAttributes.ReadOnly);
|
||||
return localFilePath;
|
||||
}
|
||||
public static IDisposable SingleInstanceApplicationGuard(string applicationName, out bool exit) {
|
||||
Mutex mutex = new Mutex(true, applicationName + AssemblyInfo.VersionShort);
|
||||
if(mutex.WaitOne(0, false)) {
|
||||
exit = false;
|
||||
} else {
|
||||
Process current = Process.GetCurrentProcess();
|
||||
foreach(Process process in Process.GetProcessesByName(current.ProcessName)) {
|
||||
if(process.Id != current.Id && process.MainWindowHandle != IntPtr.Zero) {
|
||||
WinApiHelper.SetForegroundWindow(process.MainWindowHandle);
|
||||
WinApiHelper.RestoreWindowAsync(process.MainWindowHandle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
exit = true;
|
||||
}
|
||||
return mutex;
|
||||
}
|
||||
static class WinApiHelper {
|
||||
[SecuritySafeCritical]
|
||||
public static bool SetForegroundWindow(IntPtr hwnd) {
|
||||
return Import.SetForegroundWindow(hwnd);
|
||||
}
|
||||
[SecuritySafeCritical]
|
||||
public static bool RestoreWindowAsync(IntPtr hwnd) {
|
||||
return Import.ShowWindowAsync(hwnd, IsMaxmimized(hwnd) ? (int)Import.ShowWindowCommands.ShowMaximized : (int)Import.ShowWindowCommands.Restore);
|
||||
}
|
||||
[SecuritySafeCritical]
|
||||
public static bool IsMaxmimized(IntPtr hwnd) {
|
||||
Import.WINDOWPLACEMENT placement = new Import.WINDOWPLACEMENT();
|
||||
placement.length = Marshal.SizeOf(placement);
|
||||
if(!Import.GetWindowPlacement(hwnd, ref placement)) return false;
|
||||
return placement.showCmd == Import.ShowWindowCommands.ShowMaximized;
|
||||
}
|
||||
static class Import {
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct WINDOWPLACEMENT {
|
||||
public int length;
|
||||
public int flags;
|
||||
public ShowWindowCommands showCmd;
|
||||
public System.Drawing.Point ptMinPosition;
|
||||
public System.Drawing.Point ptMaxPosition;
|
||||
public System.Drawing.Rectangle rcNormalPosition;
|
||||
}
|
||||
public enum ShowWindowCommands : int {
|
||||
Hide = 0,
|
||||
Normal = 1,
|
||||
ShowMinimized = 2,
|
||||
ShowMaximized = 3,
|
||||
ShowNoActivate = 4,
|
||||
Show = 5,
|
||||
Minimize = 6,
|
||||
ShowMinNoActive = 7,
|
||||
ShowNA = 8,
|
||||
Restore = 9,
|
||||
ShowDefault = 10,
|
||||
ForceMinimize = 11
|
||||
}
|
||||
}
|
||||
}
|
||||
static string GetEntryAssemblyDirectory() {
|
||||
Assembly entryAssembly = Assembly.GetEntryAssembly();
|
||||
if(entryAssembly == null) return null;
|
||||
string appPath = entryAssembly.Location;
|
||||
return Path.GetDirectoryName(appPath);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DevExpress.Common {
|
||||
public static class IDataErrorInfoHelper {
|
||||
public static string GetErrorText(object owner, string propertyName) {
|
||||
string[] path = propertyName.Split('.');
|
||||
if(path.Length > 1)
|
||||
return GetErrorText(owner, path);
|
||||
PropertyInfo propertyInfo = owner.GetType().GetProperty(propertyName);
|
||||
if (propertyInfo == null) return null;
|
||||
object propertyValue = propertyInfo.GetValue(owner, null);
|
||||
ValidationContext validationContext = new ValidationContext(owner, null, null) { MemberName = propertyName };
|
||||
string[] errors = propertyInfo
|
||||
.GetCustomAttributes(false)
|
||||
.OfType<ValidationAttribute>()
|
||||
.Select(x => x.GetValidationResult(propertyValue, validationContext))
|
||||
.Where(x => x != null)
|
||||
.Select(x => x.ErrorMessage)
|
||||
.Where(x => !string.IsNullOrEmpty(x))
|
||||
.ToArray();
|
||||
return string.Join(" ", errors);
|
||||
}
|
||||
static string GetErrorText(object owner, string[] path) {
|
||||
string nestedPropertyName = string.Join(".", path.Skip(1));
|
||||
string propertyName = path[0];
|
||||
PropertyInfo propertyInfo = owner.GetType().GetProperty(propertyName);
|
||||
if(propertyInfo == null)
|
||||
return null;
|
||||
object propertyValue = propertyInfo.GetValue(owner, null);
|
||||
IDataErrorInfo nestedDataErrorInfo = propertyValue as IDataErrorInfo;
|
||||
return nestedDataErrorInfo == null ? string.Empty : nestedDataErrorInfo[nestedPropertyName];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Resources;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
// This demo targets .NET Framework 4.0. A number of validation attributes that exist in .NET Framework 4.5 cannot be used.
|
||||
// That is why we have created our own counterparts of these attributes for this demo.
|
||||
// If your application targets .NET Framework 4.5, use default validation attributes.
|
||||
// If your application targets .NET Framework 4.0, you can copy and use these attributes or use DevExpress Validation Fluent API instead.
|
||||
|
||||
namespace DevExpress.DataAnnotations {
|
||||
public abstract class RegexAttributeBase : DataTypeAttribute {
|
||||
protected const RegexOptions DefaultRegexOptions = RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase;
|
||||
|
||||
readonly Regex regex;
|
||||
|
||||
public RegexAttributeBase(string regex, string defaultErrorMessage, DataType dataType)
|
||||
: this(new Regex(regex, DefaultRegexOptions), defaultErrorMessage, dataType) {
|
||||
}
|
||||
public RegexAttributeBase(Regex regex, string defaultErrorMessage, DataType dataType)
|
||||
: base(dataType) {
|
||||
this.regex = (Regex)regex;
|
||||
this.ErrorMessage = defaultErrorMessage;
|
||||
}
|
||||
public sealed override bool IsValid(object value) {
|
||||
if(value == null)
|
||||
return true;
|
||||
string input = value as string;
|
||||
return input != null && regex.Match(input).Length > 0;
|
||||
}
|
||||
}
|
||||
public sealed class ZipCodeAttribute : RegexAttributeBase {
|
||||
static Regex regex = new Regex(@"^[0-9][0-9][0-9][0-9][0-9]$", DefaultRegexOptions);
|
||||
const string Message = "The {0} field is not a valid ZIP code.";
|
||||
public ZipCodeAttribute()
|
||||
: base(regex, Message, DataType.Url) {
|
||||
}
|
||||
}
|
||||
public sealed class CreditCardAttribute : DataTypeAttribute {
|
||||
const string Message = "The {0} field is not a valid credit card number.";
|
||||
public CreditCardAttribute()
|
||||
: base(DataType.Custom) {
|
||||
this.ErrorMessage = Message;
|
||||
}
|
||||
public override bool IsValid(object value) {
|
||||
if(value == null)
|
||||
return true;
|
||||
string stringValue = value as string;
|
||||
if(stringValue == null)
|
||||
return false;
|
||||
stringValue = stringValue.Replace("-", "").Replace(" ", "");
|
||||
int number = 0;
|
||||
bool oddEvenFlag = false;
|
||||
foreach(char ch in stringValue.Reverse()) {
|
||||
if(ch < '0' || ch > '9')
|
||||
return false;
|
||||
int digitValue = (ch - '0') * (oddEvenFlag ? 2 : 1);
|
||||
oddEvenFlag = !oddEvenFlag;
|
||||
while(digitValue > 0) {
|
||||
number += digitValue % 10;
|
||||
digitValue = digitValue / 10;
|
||||
}
|
||||
}
|
||||
return (number % 10) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using DevExpress.Utils;
|
||||
using DevExpress.XtraEditors.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class Crest : DatabaseObject {
|
||||
public string CityName { get; set; }
|
||||
public byte[] SmallImage { get; set; }
|
||||
public byte[] LargeImage { get; set; }
|
||||
public virtual ICollection<CustomerStore> CustomerStores { get; set; }
|
||||
Image img;
|
||||
public Image LargeImageEx {
|
||||
get {
|
||||
if(img == null)
|
||||
if(LargeImage == null)
|
||||
return ResourceImageHelper.CreateImageFromResourcesEx("DevExpress.DevAV.Resources.Unknown-user.png", typeof(Employee).Assembly);
|
||||
else
|
||||
img = ByteImageConverter.FromByteArray(LargeImage);
|
||||
return img;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Drawing;
|
||||
using System.Runtime.Serialization;
|
||||
using DevExpress.DataAnnotations;
|
||||
using DevExpress.Utils;
|
||||
using DevExpress.XtraEditors.Controls;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public enum CustomerStatus {
|
||||
Active,
|
||||
Suspended
|
||||
}
|
||||
public partial class Customer : DatabaseObject {
|
||||
public Customer() {
|
||||
Employees = new List<CustomerEmployee>();
|
||||
Orders = new List<Order>();
|
||||
#if DXCORE3
|
||||
_homeOffice = new Address();
|
||||
_billingAddress = new Address();
|
||||
_homeOffice.PropertyChanged += (s, e) => SetPropertyValue(e.PropertyName, "HomeOffice", (Address)s);
|
||||
_billingAddress.PropertyChanged += (s, e) => SetPropertyValue(e.PropertyName, "BillingAddress", (Address)s);
|
||||
#else
|
||||
HomeOffice = new Address();
|
||||
BillingAddress = new Address();
|
||||
#endif
|
||||
}
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
#if DXCORE3
|
||||
Address _homeOffice;
|
||||
[NotMapped]
|
||||
public Address HomeOffice {
|
||||
get {
|
||||
AddressHelper.UpdateAddress(_homeOffice, HomeOfficeLine, HomeOfficeCity, HomeOfficeState, HomeOfficeZipCode, HomeOfficeLatitude, HomeOfficeLongitude);
|
||||
return _homeOffice;
|
||||
}
|
||||
set { AddressHelper.UpdateAddress(_homeOffice, value.Line, value.City, value.State, value.ZipCode, value.Latitude, value.Longitude); }
|
||||
}
|
||||
|
||||
|
||||
Address _billingAddress;
|
||||
[NotMapped]
|
||||
public Address BillingAddress {
|
||||
get {
|
||||
AddressHelper.UpdateAddress(_billingAddress, BillingAddressLine, BillingAddressCity, BillingAddressState, BillingAddressZipCode, BillingAddressLatitude, BillingAddressLongitude);
|
||||
return _billingAddress;
|
||||
}
|
||||
set { AddressHelper.UpdateAddress(_billingAddress, value.Line, value.City, value.State, value.ZipCode, value.Latitude, value.Longitude); }
|
||||
}
|
||||
#else
|
||||
public Address HomeOffice { get; set; }
|
||||
public Address BillingAddress { get; set; }
|
||||
#endif
|
||||
#if ONGENERATEDATABASE || DXCORE3
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string HomeOfficeLine { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string HomeOfficeCity { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public StateEnum HomeOfficeState { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string HomeOfficeZipCode { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public double HomeOfficeLatitude { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public double HomeOfficeLongitude { get; set; }
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string BillingAddressLine { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string BillingAddressCity { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public StateEnum BillingAddressState { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string BillingAddressZipCode { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public double BillingAddressLatitude { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public double BillingAddressLongitude { get; set; }
|
||||
#endif
|
||||
public virtual List<CustomerEmployee> Employees { get; set; }
|
||||
[Phone]
|
||||
public string Phone { get; set; }
|
||||
[Phone]
|
||||
public string Fax { get; set; }
|
||||
[Url]
|
||||
public string Website { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal AnnualRevenue { get; set; }
|
||||
[Display(Name = "Total Stores")]
|
||||
public int TotalStores { get; set; }
|
||||
[Display(Name = "Total Employees")]
|
||||
public int TotalEmployees { get; set; }
|
||||
public CustomerStatus Status { get; set; }
|
||||
[InverseProperty("Customer")]
|
||||
public virtual List<Order> Orders { get; set; }
|
||||
[InverseProperty("Customer")]
|
||||
public virtual List<Quote> Quotes { get; set; }
|
||||
[InverseProperty("Customer")]
|
||||
public virtual List<CustomerStore> CustomerStores { get; set; }
|
||||
public virtual string Profile { get; set; }
|
||||
public byte[] Logo { get; set; }
|
||||
Image img = null;
|
||||
public Image Image {
|
||||
get {
|
||||
if(img == null)
|
||||
img = CreateImage(Logo);
|
||||
return img;
|
||||
}
|
||||
}
|
||||
internal static Image CreateImage(byte[] data) {
|
||||
if(data == null)
|
||||
return ResourceImageHelper.CreateImageFromResourcesEx("DevExpress.DevAV.Resources.Unknown-user.png", typeof(Employee).Assembly);
|
||||
else
|
||||
return ByteImageConverter.FromByteArray(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class CustomerCommunication : DatabaseObject {
|
||||
public virtual Employee Employee { get; set; }
|
||||
public long? EmployeeId { get; set; }
|
||||
public virtual CustomerEmployee CustomerEmployee { get; set; }
|
||||
public long? CustomerEmployeeId { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Purpose { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Drawing;
|
||||
using System.Runtime.Serialization;
|
||||
using DevExpress.DataAnnotations;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class CustomerEmployee : DatabaseObject {
|
||||
[Required, Display(Name = "First Name")]
|
||||
public string FirstName { get; set; }
|
||||
[Required, Display(Name = "Last Name")]
|
||||
public string LastName { get; set; }
|
||||
[Display(Name = "Full Name")]
|
||||
public string FullName { get; set; }
|
||||
public PersonPrefix Prefix { get; set; }
|
||||
[Required, Phone, Display(Name = "Mobile Phone")]
|
||||
public string MobilePhone { get; set; }
|
||||
[Required, EmailAddress]
|
||||
public string Email { get; set; }
|
||||
public virtual Picture Picture { get; set; }
|
||||
public long? PictureId { get; set; }
|
||||
public virtual Customer Customer { get; set; }
|
||||
public long? CustomerId { get; set; }
|
||||
public virtual CustomerStore CustomerStore { get; set; }
|
||||
public long? CustomerStoreId { get; set; }
|
||||
public string Position { get; set; }
|
||||
public bool IsPurchaseAuthority { get; set; }
|
||||
public virtual ICollection<CustomerCommunication> CustomerCommunications { get; set; }
|
||||
public Address Address {
|
||||
get { return (CustomerStore != null) ? CustomerStore.Address : null; }
|
||||
}
|
||||
public virtual ICollection<EmployeeTask> EmployeeTasks { get; set; }
|
||||
Image _photo = null;
|
||||
[NotMapped]
|
||||
public Image Photo {
|
||||
get {
|
||||
if(_photo == null)
|
||||
_photo = Picture.CreateImage();
|
||||
return _photo;
|
||||
}
|
||||
set {
|
||||
_photo = value;
|
||||
Picture = PictureExtension.FromImage(value);
|
||||
}
|
||||
}
|
||||
public override string ToString() {
|
||||
return FullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using DevExpress.Utils;
|
||||
using DevExpress.XtraEditors.Controls;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class CustomerStore : DatabaseObject {
|
||||
public virtual Customer Customer { get; set; }
|
||||
public long? CustomerId { get; set; }
|
||||
#if DXCORE3
|
||||
public CustomerStore() {
|
||||
_address = new Address();
|
||||
_address.PropertyChanged += (s, e) => SetPropertyValue(e.PropertyName, "Address_", (Address)s);
|
||||
}
|
||||
Address _address;
|
||||
[NotMapped]
|
||||
public Address Address {
|
||||
get {
|
||||
AddressHelper.UpdateAddress(_address, Address_Line, Address_City, Address_State, Address_ZipCode, Address_Latitude, Address_Longitude);
|
||||
return _address;
|
||||
}
|
||||
set { AddressHelper.UpdateAddress(_address, value.Line, value.City, value.State, value.ZipCode, value.Latitude, value.Longitude); }
|
||||
}
|
||||
#else
|
||||
public Address Address { get; set; }
|
||||
#endif
|
||||
#if ONGENERATEDATABASE || DXCORE3
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string Address_Line { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string Address_City { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public StateEnum Address_State { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string Address_ZipCode { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public double Address_Latitude { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public double Address_Longitude { get; set; }
|
||||
#endif
|
||||
public string Phone { get; set; }
|
||||
public string Fax { get; set; }
|
||||
public int TotalEmployees { get; set; }
|
||||
public int SquereFootage { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal AnnualSales { get; set; }
|
||||
public virtual Crest Crest { get; set; }
|
||||
public long? CrestId { get; set; }
|
||||
public string Location { get; set; }
|
||||
public string City { get { return Address == null ? "" : Address.City; } }
|
||||
public StateEnum State { get { return Address == null ? StateEnum.CA : Address.State; } }
|
||||
public virtual ICollection<CustomerEmployee> CustomerEmployees { get; set; }
|
||||
public virtual ICollection<Order> Orders { get; set; }
|
||||
public virtual ICollection<Quote> Quotes { get; set; }
|
||||
public string CustomerName {
|
||||
get { return (Customer != null) ? Customer.Name : null; }
|
||||
}
|
||||
public string AddressLine {
|
||||
get { return (Address != null) ? Address.ToString() : null; }
|
||||
}
|
||||
public string AddressLines {
|
||||
get { return (Address != null) ? string.Format("{0}\r\n{1} {2}", Address.Line, Address.State, Address.ZipCode) : null; }
|
||||
}
|
||||
public string CrestCity {
|
||||
get { return (Crest != null) ? Crest.CityName : null; }
|
||||
}
|
||||
Image smallImg;
|
||||
public Image CrestSmallImage {
|
||||
get {
|
||||
if(smallImg == null && Crest != null)
|
||||
smallImg = CreateImage(Crest.SmallImage);
|
||||
return smallImg;
|
||||
}
|
||||
}
|
||||
Image largeImg;
|
||||
public Image CrestLargeImage {
|
||||
get {
|
||||
if(largeImg == null && Crest != null)
|
||||
largeImg = CreateImage(Crest.LargeImage);
|
||||
return largeImg;
|
||||
}
|
||||
}
|
||||
Image CreateImage(byte[] data) {
|
||||
if(data == null)
|
||||
return ResourceImageHelper.CreateImageFromResourcesEx("DevExpress.DevAV.Resources.Unknown-user.png", typeof(Employee).Assembly);
|
||||
else
|
||||
return ByteImageConverter.FromByteArray(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
using DevExpress.Common;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public abstract class DatabaseObject : IDataErrorInfo {
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
#region IDataErrorInfo
|
||||
string IDataErrorInfo.Error { get { return null; } }
|
||||
string IDataErrorInfo.this[string columnName] {
|
||||
get { return IDataErrorInfoHelper.GetErrorText(this, columnName); }
|
||||
}
|
||||
#endregion
|
||||
#if DXCORE3
|
||||
protected void SetPropertyValue<T>(string sourcePropertyName, string targetPrefix, T source) {
|
||||
string actualTargetName = targetPrefix + sourcePropertyName;
|
||||
var sourceProperty = source.GetType().GetProperty(sourcePropertyName);
|
||||
var targetProperty = GetType().GetProperty(actualTargetName);
|
||||
var sourceValue = sourceProperty.GetValue(source);
|
||||
targetProperty.SetValue(this, sourceValue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<EnableDefaultItems>false</EnableDefaultItems>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<RootNamespace>DevExpress.DevAV</RootNamespace>
|
||||
<AssemblyName>DevExpress.DevAV.v19.1.Data</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>..\..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;DEVAV;DXCORE3</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>..\..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE;DEVAV;DXCORE3</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AttachedFile.cs" />
|
||||
<Compile Include="Common\DataDirectoryHelper.cs" />
|
||||
<Compile Include="Common\IDataErrorInfoHelper.cs" />
|
||||
<Compile Include="Common\ValidationAttributes.cs" />
|
||||
<Compile Include="Crest.cs" />
|
||||
<Compile Include="CustomerComminication.cs" />
|
||||
<Compile Include="CustomerStore.cs" />
|
||||
<Compile Include="Evaluation.cs" />
|
||||
<Compile Include="NetCore\Address.cs" />
|
||||
<Compile Include="NetCore\DevAVDb.cs" />
|
||||
<Compile Include="NetCore\ObservableObject.cs" />
|
||||
<Compile Include="Order.cs" />
|
||||
<Compile Include="OrderItem.cs" />
|
||||
<Compile Include="Picture.cs" />
|
||||
<Compile Include="Probation.cs" />
|
||||
<Compile Include="ProductCatalog.cs" />
|
||||
<Compile Include="ProductImage.cs" />
|
||||
<Compile Include="Quote.cs" />
|
||||
<Compile Include="QuoteItem.cs" />
|
||||
<Compile Include="Queries.cs" />
|
||||
<Compile Include="State.cs" />
|
||||
<Compile Include="StateEnum.cs" />
|
||||
<Compile Include="Customer.cs" />
|
||||
<Compile Include="CustomerEmployee.cs" />
|
||||
<Compile Include="DatabaseObject.cs" />
|
||||
<Compile Include="Employee.cs" />
|
||||
<Compile Include="Person.cs" />
|
||||
<Compile Include="Product.cs" />
|
||||
<Compile Include="Task.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\Unknown-user.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DevExpress.WindowsDesktop.Core" Version="19.1.3-ctp" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview3.19153.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.0.0-preview3.19153.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0-preview3.19153.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,170 @@
|
||||
using DevExpress.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Drawing;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public enum EmployeeStatus {
|
||||
[Display(Name = "Salaried")]
|
||||
Salaried,
|
||||
[Display(Name = "Commission")]
|
||||
Commission,
|
||||
[Display(Name = "Contract")]
|
||||
Contract,
|
||||
[Display(Name = "Terminated")]
|
||||
Terminated,
|
||||
[Display(Name = "On Leave")]
|
||||
OnLeave
|
||||
}
|
||||
public enum EmployeeDepartment {
|
||||
[Display(Name = "Sales")]
|
||||
Sales = 1,
|
||||
[Display(Name = "Support")]
|
||||
Support,
|
||||
[Display(Name = "Shipping")]
|
||||
Shipping,
|
||||
[Display(Name = "Engineering")]
|
||||
Engineering,
|
||||
[Display(Name = "Human Resources")]
|
||||
HumanResources,
|
||||
[Display(Name = "Management")]
|
||||
Management,
|
||||
[Display(Name = "IT")]
|
||||
IT
|
||||
}
|
||||
public enum PersonPrefix {
|
||||
Dr,
|
||||
Mr,
|
||||
Ms,
|
||||
Miss,
|
||||
Mrs
|
||||
}
|
||||
public partial class Employee : DatabaseObject {
|
||||
public Employee() {
|
||||
AssignedTasks = new List<EmployeeTask>();
|
||||
OwnedTasks = new List<EmployeeTask>();
|
||||
#if DXCORE3
|
||||
_address = new Address();
|
||||
_address.PropertyChanged += (s, e) => SetPropertyValue(e.PropertyName, "Address", (Address)s);
|
||||
#else
|
||||
Address = new Address();
|
||||
#endif
|
||||
AssignedEmployeeTasks = new List<EmployeeTask>();
|
||||
}
|
||||
[InverseProperty("AssignedEmployees")]
|
||||
public virtual List<EmployeeTask> AssignedEmployeeTasks { get; set; }
|
||||
public EmployeeDepartment Department { get; set; }
|
||||
[Required]
|
||||
public string Title { get; set; }
|
||||
public EmployeeStatus Status { get; set; }
|
||||
[Display(Name = "Hire Date")]
|
||||
public DateTime? HireDate { get; set; }
|
||||
[InverseProperty("AssignedEmployee")]
|
||||
public virtual List<EmployeeTask> AssignedTasks { get; set; }
|
||||
[InverseProperty("Owner")]
|
||||
public virtual List<EmployeeTask> OwnedTasks { get; set; }
|
||||
[InverseProperty("Employee")]
|
||||
public virtual List<Evaluation> Evaluations { get; set; }
|
||||
public string PersonalProfile { get; set; }
|
||||
public long? ProbationReason_Id { get; set; }
|
||||
public virtual Probation ProbationReason { get; set; }
|
||||
[Required, Display(Name = "First Name")]
|
||||
public string FirstName { get; set; }
|
||||
[Required, Display(Name = "Last Name")]
|
||||
public string LastName { get; set; }
|
||||
[Display(Name = "Full Name")]
|
||||
public string FullName { get; set; }
|
||||
public PersonPrefix Prefix { get; set; }
|
||||
[Phone, Display(Name = "Home Phone")]
|
||||
public string HomePhone { get; set; }
|
||||
[Required, Phone, Display(Name = "Mobile Phone")]
|
||||
public string MobilePhone { get; set; }
|
||||
[Required, EmailAddress]
|
||||
public string Email { get; set; }
|
||||
public string Skype { get; set; }
|
||||
[Display(Name = "Birth Date")]
|
||||
public DateTime? BirthDate { get; set; }
|
||||
public virtual Picture Picture { get; set; }
|
||||
public long? PictureId { get; set; }
|
||||
#if DXCORE3
|
||||
Address _address;
|
||||
[NotMapped]
|
||||
public Address Address {
|
||||
get {
|
||||
AddressHelper.UpdateAddress(_address, AddressLine, AddressCity, AddressState, AddressZipCode, AddressLatitude, AddressLongitude);
|
||||
return _address;
|
||||
}
|
||||
set { AddressHelper.UpdateAddress(_address, value.Line, value.City, value.State, value.ZipCode, value.Latitude, value.Longitude); }
|
||||
}
|
||||
#else
|
||||
public Address Address { get; set; }
|
||||
#endif
|
||||
#if ONGENERATEDATABASE || DXCORE3
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string AddressLine { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string AddressCity { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public StateEnum AddressState { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string AddressZipCode { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public double AddressLatitude { get; set; }
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public double AddressLongitude { get; set; }
|
||||
#endif
|
||||
|
||||
Image _photo = null;
|
||||
[NotMapped]
|
||||
public Image Photo {
|
||||
get {
|
||||
if(_photo == null)
|
||||
_photo = Picture.CreateImage();
|
||||
return _photo;
|
||||
}
|
||||
set {
|
||||
if(_photo == value) return;
|
||||
if(_photo != null)
|
||||
_photo.Dispose();
|
||||
_photo = value;
|
||||
Picture = PictureExtension.FromImage(value);
|
||||
}
|
||||
}
|
||||
bool unsetFullName = false;
|
||||
public virtual ICollection<Evaluation> EvaluationsCreatedBy { get; set; }
|
||||
public virtual ICollection<Order> Orders { get; set; }
|
||||
public virtual ICollection<Product> Products { get; set; }
|
||||
public virtual ICollection<Product> SupportedProducts { get; set; }
|
||||
public virtual ICollection<Quote> Quotes { get; set; }
|
||||
public virtual ICollection<CustomerCommunication> Employees { get; set; }
|
||||
[NotMapped, Display(Name = "Full Name")]
|
||||
public string FullNameBindable {
|
||||
get {
|
||||
return string.IsNullOrEmpty(FullName) || unsetFullName ? GetFullName() : FullName;
|
||||
}
|
||||
set {
|
||||
unsetFullName = string.IsNullOrEmpty(value);
|
||||
if(unsetFullName)
|
||||
FullName = GetFullName();
|
||||
else
|
||||
FullName = value;
|
||||
}
|
||||
}
|
||||
public void ResetBindable() {
|
||||
if(_photo != null)
|
||||
_photo.Dispose();
|
||||
_photo = null;
|
||||
unsetFullName = false;
|
||||
}
|
||||
string GetFullName() {
|
||||
return string.Format("{0} {1}", FirstName, LastName);
|
||||
}
|
||||
public override string ToString() {
|
||||
return FullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public enum EvaluationRating {
|
||||
Unset,
|
||||
Good,
|
||||
Average,
|
||||
Poor
|
||||
}
|
||||
public partial class Evaluation : DatabaseObject {
|
||||
public virtual Employee CreatedBy { get; set; }
|
||||
public long? CreatedById { get; set; }
|
||||
public DateTime CreatedOn { get; set; }
|
||||
public virtual Employee Employee { get; set; }
|
||||
public long? EmployeeId { get; set; }
|
||||
public string Subject { get; set; }
|
||||
public string Details { get; set; }
|
||||
public virtual EvaluationRating Rating { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DevExpress.Common;
|
||||
using DevExpress.DataAnnotations;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public partial class Address : ObservableObject, IDataErrorInfo {
|
||||
string line;
|
||||
[Display(Name = "Address")]
|
||||
public string Line {
|
||||
get { return line; }
|
||||
set { SetPropertyValue(ref line, value); }
|
||||
}
|
||||
string city;
|
||||
public string City {
|
||||
get { return city; }
|
||||
set { SetPropertyValue(ref city, value); }
|
||||
}
|
||||
StateEnum state;
|
||||
public StateEnum State {
|
||||
get { return state; }
|
||||
set { SetPropertyValue(ref state, value); }
|
||||
}
|
||||
string zipCode;
|
||||
[ZipCode, Display(Name = "Zip code")]
|
||||
public string ZipCode {
|
||||
get { return zipCode; }
|
||||
set { SetPropertyValue(ref zipCode, value); }
|
||||
}
|
||||
|
||||
double latitude;
|
||||
public double Latitude {
|
||||
get { return latitude; }
|
||||
set { SetPropertyValue(ref latitude, value); }
|
||||
}
|
||||
double longitude;
|
||||
public double Longitude {
|
||||
get { return longitude; }
|
||||
set { SetPropertyValue(ref longitude, value); }
|
||||
}
|
||||
public string CityLine {
|
||||
get { return GetCityLine(City, State, ZipCode); }
|
||||
}
|
||||
public override string ToString() {
|
||||
return string.Format("{0}, {1}", Line, CityLine);
|
||||
}
|
||||
#region IDataErrorInfo
|
||||
string IDataErrorInfo.Error { get { return null; } }
|
||||
string IDataErrorInfo.this[string columnName] {
|
||||
get { return IDataErrorInfoHelper.GetErrorText(this, columnName); }
|
||||
}
|
||||
#endregion
|
||||
internal static string GetCityLine(string city, StateEnum state, string zipCode) {
|
||||
return string.Format("{0}, {1} {2}", city, state, zipCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class AddressHelper {
|
||||
public static void UpdateAddress(Address address, string line, string city, StateEnum state, string zipCode, double latitude, double longtitude) {
|
||||
address.Line = line;
|
||||
address.City = city;
|
||||
address.State = state;
|
||||
address.ZipCode = zipCode;
|
||||
address.Latitude = latitude;
|
||||
address.Longitude = longtitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
[CLSCompliant(false)]
|
||||
public class DevAVDb : DbContext {
|
||||
public DevAVDb(string connectionStringOrName) {
|
||||
connectionString = connectionStringOrName;
|
||||
}
|
||||
|
||||
string connectionString = string.Empty;
|
||||
|
||||
public DevAVDb() : base() {
|
||||
}
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionbuilder) {
|
||||
optionbuilder.UseLazyLoadingProxies().UseSqlite(connectionString);
|
||||
}
|
||||
|
||||
public DbSet<Customer> Customers { get; set; }
|
||||
public DbSet<Employee> Employees { get; set; }
|
||||
public DbSet<Product> Products { get; set; }
|
||||
public DbSet<Crest> Crests { get; set; }
|
||||
public DbSet<CustomerStore> CustomerStores { get; set; }
|
||||
public DbSet<Order> Orders { get; set; }
|
||||
public DbSet<OrderItem> OrderItems { get; set; }
|
||||
public DbSet<Probation> Probations { get; set; }
|
||||
public DbSet<ProductCatalog> ProductCatalogs { get; set; }
|
||||
public DbSet<ProductImage> ProductImages { get; set; }
|
||||
public DbSet<Quote> Quotes { get; set; }
|
||||
public DbSet<QuoteItem> QuoteItems { get; set; }
|
||||
public DbSet<State> States { get; set; }
|
||||
public DbSet<CustomerEmployee> CustomerEmployees { get; set; }
|
||||
public DbSet<Evaluation> Evaluations { get; set; }
|
||||
public DbSet<Picture> Pictures { get; set; }
|
||||
|
||||
public DbSet<EmployeeTask> EmployeeTasks { get; set; }
|
||||
public DbSet<CustomerCommunication> CustomerCommunications { get; set; }
|
||||
public DbSet<TaskAttachedFile> TaskAttachedFiles { get; set; }
|
||||
public DbSet<DatabaseVersion> DatabaseVersions { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder) {
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<Employee>()
|
||||
.Ignore(x => x.AssignedEmployeeTasks);
|
||||
modelBuilder.Entity<EmployeeTask>()
|
||||
.Ignore(x => x.AssignedEmployees);
|
||||
|
||||
modelBuilder.Entity<TaskAttachedFile>()
|
||||
.HasOne(t => t.EmployeeTask)
|
||||
.WithMany(p => p.AttachedFiles)
|
||||
.HasForeignKey(t => t.EmployeeTaskId);
|
||||
|
||||
modelBuilder.Entity<EmployeeTask>()
|
||||
.HasOne(x => x.AssignedEmployee)
|
||||
.WithMany(x => x.AssignedTasks);
|
||||
|
||||
modelBuilder.Entity<EmployeeTask>()
|
||||
.HasOne(x => x.Owner)
|
||||
.WithMany(x => x.OwnedTasks);
|
||||
|
||||
modelBuilder.Entity<EmployeeTask>()
|
||||
.HasOne(x => x.CustomerEmployee)
|
||||
.WithMany(x => x.EmployeeTasks);
|
||||
|
||||
modelBuilder.Entity<Employee>()
|
||||
.HasOne(x => x.Picture)
|
||||
.WithMany(x => x.Employees);
|
||||
|
||||
modelBuilder.Entity<Employee>()
|
||||
.HasOne(x => x.ProbationReason)
|
||||
.WithMany(x => x.Employees)
|
||||
.HasForeignKey(x => x.ProbationReason_Id);
|
||||
|
||||
modelBuilder.Entity<Evaluation>()
|
||||
.HasOne(x => x.CreatedBy)
|
||||
.WithMany(x => x.EvaluationsCreatedBy);
|
||||
|
||||
modelBuilder.Entity<CustomerEmployee>()
|
||||
.HasOne(x => x.CustomerStore)
|
||||
.WithMany(x => x.CustomerEmployees);
|
||||
|
||||
modelBuilder.Entity<CustomerEmployee>()
|
||||
.HasOne(x => x.Picture)
|
||||
.WithMany(x => x.CustomerEmployees);
|
||||
|
||||
modelBuilder.Entity<CustomerStore>()
|
||||
.HasOne(x => x.Crest)
|
||||
.WithMany(x => x.CustomerStores);
|
||||
|
||||
modelBuilder.Entity<Order>()
|
||||
.HasOne(x => x.Employee)
|
||||
.WithMany(x => x.Orders);
|
||||
|
||||
modelBuilder.Entity<Order>()
|
||||
.HasOne(x => x.Store)
|
||||
.WithMany(x => x.Orders);
|
||||
|
||||
modelBuilder.Entity<Product>()
|
||||
.HasOne(x => x.Engineer)
|
||||
.WithMany(x => x.Products);
|
||||
|
||||
modelBuilder.Entity<Product>()
|
||||
.HasOne(x => x.PrimaryImage)
|
||||
.WithMany(x => x.Products);
|
||||
|
||||
modelBuilder.Entity<Product>()
|
||||
.HasOne(x => x.Support)
|
||||
.WithMany(x => x.SupportedProducts);
|
||||
|
||||
modelBuilder.Entity<ProductImage>()
|
||||
.HasOne(x => x.Picture)
|
||||
.WithMany(x => x.ProductImages);
|
||||
|
||||
modelBuilder.Entity<Quote>()
|
||||
.HasOne(x => x.CustomerStore)
|
||||
.WithMany(x => x.Quotes);
|
||||
|
||||
modelBuilder.Entity<Quote>()
|
||||
.HasOne(x => x.Employee)
|
||||
.WithMany(x => x.Quotes);
|
||||
|
||||
modelBuilder.Entity<QuoteItem>()
|
||||
.HasOne(x => x.Product)
|
||||
.WithMany(x => x.QuoteItems);
|
||||
|
||||
modelBuilder.Entity<CustomerCommunication>()
|
||||
.HasOne(x => x.CustomerEmployee)
|
||||
.WithMany(x => x.CustomerCommunications);
|
||||
|
||||
modelBuilder.Entity<CustomerCommunication>()
|
||||
.HasOne(x => x.Employee)
|
||||
.WithMany(x => x.Employees);
|
||||
}
|
||||
}
|
||||
public class DatabaseVersion : DatabaseObject {
|
||||
public DateTime Date { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class ObservableObject : INotifyPropertyChanged {
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
void RaisePropertyChangedEvent(string propertyName) {
|
||||
var handler = PropertyChanged;
|
||||
if(handler != null)
|
||||
handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
protected void SetPropertyValue<T>(ref T valueHolder, T newValue, [CallerMemberName]string propertyName = null) {
|
||||
if(object.Equals(valueHolder, newValue))
|
||||
return;
|
||||
valueHolder = newValue;
|
||||
RaisePropertyChangedEvent(propertyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public enum OrderShipMethod {
|
||||
[Display(Name = "Ground")]
|
||||
Ground,
|
||||
[Display(Name = "Air")]
|
||||
Air
|
||||
}
|
||||
public enum ShipmentCourier {
|
||||
None,
|
||||
[Display(Name = "FedEx")]
|
||||
FedEx,
|
||||
[Display(Name = "UPS")]
|
||||
UPS,
|
||||
[Display(Name = "DHL")]
|
||||
DHL
|
||||
}
|
||||
public enum ShipmentStatus {
|
||||
[Display(Name = "Awaiting")]
|
||||
Awaiting,
|
||||
[Display(Name = "Transit")]
|
||||
Transit,
|
||||
[Display(Name = "Received")]
|
||||
Received
|
||||
}
|
||||
public enum PaymentStatus {
|
||||
[Display(Name = "Unpaid")]
|
||||
Unpaid,
|
||||
[Display(Name = "Paid in full")]
|
||||
PaidInFull,
|
||||
[Display(Name = "Refund in full")]
|
||||
RefundInFull,
|
||||
[Display(Name = "")]
|
||||
Other
|
||||
}
|
||||
//
|
||||
public class Order : DatabaseObject {
|
||||
public Order() {
|
||||
OrderItems = new List<OrderItem>();
|
||||
}
|
||||
public string InvoiceNumber { get; set; }
|
||||
public virtual Customer Customer { get; set; }
|
||||
public long? CustomerId { get; set; }
|
||||
public virtual CustomerStore Store { get; set; }
|
||||
public long? StoreId { get; set; }
|
||||
public string PONumber { get; set; }
|
||||
public virtual Employee Employee { get; set; }
|
||||
public long? EmployeeId { get; set; }
|
||||
public DateTime OrderDate { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal SaleAmount { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal ShippingAmount { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal TotalAmount { get; set; }
|
||||
public DateTime? ShipDate { get; set; }
|
||||
public OrderShipMethod ShipMethod { get; set; }
|
||||
public string OrderTerms { get; set; }
|
||||
public virtual List<OrderItem> OrderItems { get; set; }
|
||||
public ShipmentCourier ShipmentCourier { get; set; }
|
||||
public string ShipmentCourierId { get; set; }
|
||||
public ShipmentStatus ShipmentStatus { get; set; }
|
||||
public string Comments { get; set; }
|
||||
// Payment/Refund
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal RefundTotal { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal PaymentTotal { get; set; }
|
||||
[NotMapped]
|
||||
public PaymentStatus PaymentStatus {
|
||||
get {
|
||||
if(PaymentTotal == decimal.Zero && RefundTotal == decimal.Zero)
|
||||
return DevAV.PaymentStatus.Unpaid;
|
||||
if(RefundTotal == TotalAmount)
|
||||
return DevAV.PaymentStatus.RefundInFull;
|
||||
if(PaymentTotal == TotalAmount)
|
||||
return DevAV.PaymentStatus.PaidInFull;
|
||||
return DevAV.PaymentStatus.Other;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public double ActualWeight {
|
||||
get {
|
||||
var weight = 0.0;
|
||||
if(OrderItems != null)
|
||||
foreach(var item in OrderItems)
|
||||
if(item.Product != null)
|
||||
weight += item.Product.Weight * item.ProductUnits;
|
||||
return weight;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class OrderItem : DatabaseObject {
|
||||
public virtual Order Order { get; set; }
|
||||
public long? OrderId { get; set; }
|
||||
public virtual Product Product { get; set; }
|
||||
public long? ProductId { get; set; }
|
||||
public int ProductUnits { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal ProductPrice { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Discount { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Total { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Drawing;
|
||||
using DevExpress.Utils;
|
||||
using DevExpress.XtraEditors.Controls;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class Picture : DatabaseObject {
|
||||
public byte[] Data { get; set; }
|
||||
public virtual ICollection<Employee> Employees { get; set; }
|
||||
public virtual ICollection<CustomerEmployee> CustomerEmployees { get; set; }
|
||||
public virtual ICollection<Product> Products { get; set; }
|
||||
public virtual ICollection<ProductImage> ProductImages { get; set; }
|
||||
}
|
||||
static class PictureExtension {
|
||||
public const string DefaultPic = DefaultUserPic;
|
||||
public const string DefaultUserPic = "DevExpress.DevAV.Resources.Unknown-user.png";
|
||||
internal static Image CreateImage(this Picture picture, string defaultImage = null) {
|
||||
if(picture == null) {
|
||||
if(string.IsNullOrEmpty(defaultImage))
|
||||
defaultImage = DefaultPic;
|
||||
return ResourceImageHelper.CreateImageFromResourcesEx(defaultImage, typeof(Picture).Assembly);
|
||||
}
|
||||
else return ByteImageConverter.FromByteArray(picture.Data);
|
||||
}
|
||||
internal static Picture FromImage(Image image) {
|
||||
return (image == null) ? null : new Picture()
|
||||
{
|
||||
Data = ByteImageConverter.ToByteArray(image, image.RawFormat)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class Probation : DatabaseObject {
|
||||
public string Reason { get; set; }
|
||||
public virtual ICollection<Employee> Employees { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using DevExpress.Utils;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public enum ProductCategory {
|
||||
[Display(Name = "Automation")]
|
||||
Automation,
|
||||
[Display(Name = "Monitors")]
|
||||
Monitors,
|
||||
[Display(Name = "Projectors")]
|
||||
Projectors,
|
||||
[Display(Name = "Televisions")]
|
||||
Televisions,
|
||||
[Display(Name = "Video Players")]
|
||||
VideoPlayers,
|
||||
}
|
||||
public class Product : DatabaseObject {
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public DateTime ProductionStart { get; set; }
|
||||
public bool Available { get; set; }
|
||||
public byte[] Image { get; set; }
|
||||
public virtual Employee Support { get; set; }
|
||||
public long? SupportId { get; set; }
|
||||
public virtual Employee Engineer { get; set; }
|
||||
public long? EngineerId { get; set; }
|
||||
public int? CurrentInventory { get; set; }
|
||||
public int Backorder { get; set; }
|
||||
public int Manufacturing { get; set; }
|
||||
public byte[] Barcode { get; set; }
|
||||
public virtual Picture PrimaryImage { get; set; }
|
||||
public long? PrimaryImageId { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Cost { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal SalePrice { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal RetailPrice { get; set; }
|
||||
public double Weight { get; set; }
|
||||
public double ConsumerRating { get; set; }
|
||||
public ProductCategory Category { get; set; }
|
||||
[InverseProperty("Product")]
|
||||
public virtual List<ProductCatalog> Catalog { get; set; }
|
||||
[InverseProperty("Product")]
|
||||
public virtual List<OrderItem> OrderItems { get; set; }
|
||||
public virtual List<ProductImage> Images { get; set; }
|
||||
public virtual ICollection<QuoteItem> QuoteItems { get; set; }
|
||||
public Stream Brochure {
|
||||
get {
|
||||
if(Catalog != null && Catalog.Count > 0)
|
||||
return Catalog[0].PdfStream;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Image img;
|
||||
public Image ProductImage {
|
||||
get {
|
||||
if(img == null && PrimaryImage != null)
|
||||
img = CreateImage(PrimaryImage.Data);
|
||||
return img;
|
||||
}
|
||||
}
|
||||
Image CreateImage(byte[] data) {
|
||||
if(data == null)
|
||||
return ResourceImageHelper.CreateImageFromResourcesEx("DevExpress.DevAV.Resources.Unknown-user.png", typeof(Employee).Assembly);
|
||||
else
|
||||
return DevExpress.XtraEditors.Controls.ByteImageConverter.FromByteArray(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class ProductCatalog : DatabaseObject {
|
||||
public virtual Product Product { get; set; }
|
||||
public long? ProductId { get; set; }
|
||||
public byte[] PDF { get; set; }
|
||||
Stream _pdfStream;
|
||||
public Stream PdfStream {
|
||||
get {
|
||||
if (_pdfStream == null)
|
||||
_pdfStream = new MemoryStream(PDF);
|
||||
return _pdfStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class ProductImage : DatabaseObject {
|
||||
public virtual Picture Picture { get; set; }
|
||||
public long? PictureId { get; set; }
|
||||
public virtual Product Product { get; set; }
|
||||
public long? ProductId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
[assembly: AssemblyTitle("DevExpress.DevAV.Data")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany(AssemblyInfo.AssemblyCompany)]
|
||||
[assembly: AssemblyProduct("DevExpress.DevAV.Data")]
|
||||
[assembly: AssemblyCopyright(AssemblyInfo.AssemblyCopyright)]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: CLSCompliant(true)]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: NeutralResourcesLanguage("en-US")]
|
||||
[assembly: SatelliteContractVersion(AssemblyInfo.SatelliteContractVersion)]
|
||||
[assembly: AssemblyVersion(AssemblyInfo.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfo.FileVersion)]
|
||||
73
OutlookInspiredApp/DevExpress.DevAV/DevExpress.DevAV.Data/Properties/Resources.Designer.cs
generated
Normal file
73
OutlookInspiredApp/DevExpress.DevAV/DevExpress.DevAV.Data/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34011
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DevExpress.DevAV.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DevExpress.DevAV.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Unknown_user {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Unknown_user", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="Unknown_user" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Unknown-user.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,583 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class SaleSummaryInfo {
|
||||
public DateTime OrderDate { get; set; }
|
||||
public string InvoiceNumber { get; set; }
|
||||
public int ProductUnits { get; set; }
|
||||
public decimal ProductPrice { get; set; }
|
||||
public decimal Discount { get; set; }
|
||||
public decimal Total { get; set; }
|
||||
public ProductCategory ProductCategory { get; set; }
|
||||
public long StoreId { get; set; }
|
||||
public string StoreCity { get; set; }
|
||||
public string StoreCustomerName { get; set; }
|
||||
}
|
||||
|
||||
public class SaleAnalisysInfo {
|
||||
public DateTime OrderDate { get; set; }
|
||||
public decimal ProductCost { get; set; }
|
||||
public int ProductUnits { get; set; }
|
||||
public decimal Total { get; set; }
|
||||
}
|
||||
|
||||
public class CustomerSaleDetailOrderItemInfo {
|
||||
public long OrderId { get; set; }
|
||||
public DateTime OrderDate { get; set; }
|
||||
public string InvoiceNumber { get; set; }
|
||||
public ProductCategory ProductCategory { get; set; }
|
||||
public string PONumber { get; set; }
|
||||
public long StoreId { get; set; }
|
||||
public string StoreCity { get; set; }
|
||||
public string EmployeeFullName { get; set; }
|
||||
public decimal ShippingAmount { get; set; }
|
||||
public decimal TotalAmount { get; set; }
|
||||
public string CustomerName { get; set; }
|
||||
public string CustomerPhone { get; set; }
|
||||
public string CustomerFax { get; set; }
|
||||
public byte[] CustomerLogo { get; set; }
|
||||
Image img = null;
|
||||
public Image CustomerImage { get { return img ?? (img = Customer.CreateImage(CustomerLogo)); } }
|
||||
|
||||
public decimal Discount { get; set; }
|
||||
public int ProductUnits { get; set; }
|
||||
public decimal ProductPrice { get; set; }
|
||||
public decimal Total { get; set; }
|
||||
|
||||
public string CustomerHomeOfficeLine { get; set; }
|
||||
public string CustomerHomeOfficeCity { get; set; }
|
||||
public StateEnum CustomerHomeOfficeState { get; set; }
|
||||
public string CustomerHomeOfficeZipCode { get; set; }
|
||||
public string CustomerHomeOfficeCityLine { get { return Address.GetCityLine(CustomerHomeOfficeCity, CustomerHomeOfficeState, CustomerHomeOfficeZipCode); } }
|
||||
|
||||
public string CustomerBillingAddressLine { get; set; }
|
||||
public string CustomerBillingAddressCity { get; set; }
|
||||
public StateEnum CustomerBillingAddressState { get; set; }
|
||||
public string CustomerBillingAddressZipCode { get; set; }
|
||||
public string CustomerBillingAddressCityLine { get { return Address.GetCityLine(CustomerBillingAddressCity, CustomerBillingAddressState, CustomerBillingAddressZipCode); } }
|
||||
}
|
||||
public class CustomerSaleDetailOrderInfo {
|
||||
public CustomerSaleDetailOrderItemInfo[] OrderItems { get; set; }
|
||||
|
||||
public long OrderId { get; set; }
|
||||
public ProductCategory ProductCategory { get; set; }
|
||||
public DateTime OrderDate { get; set; }
|
||||
public string InvoiceNumber { get; set; }
|
||||
public string PONumber { get; set; }
|
||||
public long StoreId { get; set; }
|
||||
public string StoreCity { get; set; }
|
||||
public string EmployeeFullName { get; set; }
|
||||
public string CustomerName { get; set; }
|
||||
public string CustomerPhone { get; set; }
|
||||
public string CustomerFax { get; set; }
|
||||
public Image CustomerImage { get; set; }
|
||||
public decimal ShippingAmount { get; set; }
|
||||
public decimal TotalAmount { get; set; }
|
||||
public string CustomerHomeOfficeLine { get; set; }
|
||||
public string CustomerHomeOfficeCityLine { get; set; }
|
||||
public string CustomerBillingAddressLine { get; set; }
|
||||
public string CustomerBillingAddressCityLine { get; set; }
|
||||
}
|
||||
public class QuoteInfo {
|
||||
public long Id { get; set; }
|
||||
public StateEnum State { get; set; }
|
||||
public string City { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public decimal Total { get; set; }
|
||||
public double Opportunity { get; set; }
|
||||
public decimal MoneyOpportunity { get { return Total * (decimal)Opportunity; } }
|
||||
public decimal Percentage { get { return 100M * (decimal)Opportunity; } }
|
||||
}
|
||||
public class OrderInfo {
|
||||
public string InvoiceNumber { get; set; }
|
||||
public DateTime OrderDate { get; set; }
|
||||
public string Company { get; set; }
|
||||
public string Store { get; set; }
|
||||
public decimal TotalAmount { get; set; }
|
||||
}
|
||||
public class SalesProductInfo {
|
||||
public string Name { get; set; }
|
||||
public decimal Value { get; set; }
|
||||
}
|
||||
|
||||
public class SalesInfo {
|
||||
public string Caption { get; set; }
|
||||
public List<SalesProductInfo> ListProductInfo { get; set; }
|
||||
public DateTime time { get; set; }
|
||||
public SalesInfo() {
|
||||
ListProductInfo = new List<SalesProductInfo>();
|
||||
}
|
||||
}
|
||||
public class ProductInfoWithSales {
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal Cost { get; set; }
|
||||
public decimal SalePrice { get; set; }
|
||||
public decimal RetailPrice { get; set; }
|
||||
public int? CurrentInventory { get; set; }
|
||||
public int Backorder { get; set; }
|
||||
public IEnumerable<double> MonthlySales { get; set; }
|
||||
public decimal? TotalSales { get; set; }
|
||||
}
|
||||
public class CustomerInfoWithSales {
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string HomeOfficeLine { get; set; }
|
||||
public string HomeOfficeCity { get; set; }
|
||||
public StateEnum HomeOfficeState { get; set; }
|
||||
public string HomeOfficeZipCode { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Fax { get; set; }
|
||||
public decimal? TotalSales { get; set; }
|
||||
|
||||
Lazy<IEnumerable<CustomerStore>> customerStores;
|
||||
public IEnumerable<CustomerStore> CustomerStores { get { return customerStores.Value; } }
|
||||
Lazy<IEnumerable<CustomerEmployee>> customerEmployees;
|
||||
public IEnumerable<CustomerEmployee> Employees { get { return customerEmployees.Value; } }
|
||||
public IEnumerable<decimal> MonthlySales { get; private set; }
|
||||
public void Init(Func<IEnumerable<CustomerStore>> getStores, Func<IEnumerable<CustomerEmployee>> getEmployees, IEnumerable<decimal> monthlySales) {
|
||||
this.customerStores = new Lazy<IEnumerable<CustomerStore>>(getStores);
|
||||
this.customerEmployees = new Lazy<IEnumerable<CustomerEmployee>>(getEmployees);
|
||||
this.MonthlySales = monthlySales;
|
||||
}
|
||||
}
|
||||
public class MapItem {
|
||||
public Address Address { get; set; }
|
||||
public Customer Customer { get; set; }
|
||||
public Product Product { get; set; }
|
||||
public decimal Total { get; set; }
|
||||
public string City { get { return Address.City; } }
|
||||
public double Latitude { get { return Address.Latitude; } }
|
||||
public double Longitude { get { return Address.Longitude; } }
|
||||
public string CustomerName { get { return Customer.Name; } }
|
||||
public string ProductName { get { return Product.Name; } }
|
||||
public ProductCategory ProductCategory { get { return Product.Category; } }
|
||||
}
|
||||
public class QuoteMapItem {
|
||||
public Address Address { get; set; }
|
||||
public Stage Stage { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public string City { get { return Address.City; } }
|
||||
public double Latitude { get { return Address.Latitude; } }
|
||||
public double Longitude { get { return Address.Longitude; } }
|
||||
public string Name { get { return Enum.GetName(typeof(Stage), Stage); } }
|
||||
public int Index { get { return (int)Stage; } }
|
||||
public decimal Value { get; set; }
|
||||
}
|
||||
public enum Stage {
|
||||
High,
|
||||
Medium,
|
||||
Low,
|
||||
Unlikely,
|
||||
Summary
|
||||
}
|
||||
public class SalesSummaryItem {
|
||||
public ProductCategory Category { get; set; }
|
||||
public decimal Sales { get; set; }
|
||||
}
|
||||
public class QuoteSummaryItem {
|
||||
public string StageName { get; set; }
|
||||
public decimal Summary { get; set; }
|
||||
}
|
||||
public class CostAverageItem {
|
||||
public ProductCategory Category { get; set; }
|
||||
public decimal Cost { get; set; }
|
||||
}
|
||||
public static class QueriesHelper {
|
||||
public static IQueryable<Order> ActualOrders(this IQueryable<Order> orders) {
|
||||
var actualDateTime = DateTime.Now.AddHours(0.5);
|
||||
return orders.Where(x => x.OrderDate <= actualDateTime);
|
||||
}
|
||||
public static IQueryable<Quote> ActualQuotes(this IQueryable<Quote> quotes) {
|
||||
var actualDateTime = DateTime.Now.AddHours(0.5);
|
||||
return quotes.Where(x => x.Date <= actualDateTime);
|
||||
}
|
||||
public static IQueryable<QuoteInfo> GetQuoteInfo(IQueryable<Quote> quotes) {
|
||||
return quotes.ActualQuotes().Select(x => new QuoteInfo {
|
||||
Id = x.Id,
|
||||
State = x.CustomerStore.Address.State,
|
||||
City = x.CustomerStore.Address.City,
|
||||
Date = x.Date,
|
||||
Total = x.Total,
|
||||
Opportunity = x.Opportunity,
|
||||
});
|
||||
}
|
||||
public static decimal CustomSum<T>(this IEnumerable<T> query, Expression<Func<T, decimal>> selector) {
|
||||
return query.AsQueryable<T>().Select(selector).DefaultIfEmpty(0).Sum();
|
||||
}
|
||||
public static IEnumerable<CustomerSaleDetailOrderInfo> GetCustomerSaleDetails(long customerId, IQueryable<OrderItem> orderItems) {
|
||||
List<CustomerSaleDetailOrderItemInfo> detailInfo = GetCustomerSaleOrderItemDetails(customerId, orderItems);
|
||||
return detailInfo
|
||||
.GroupBy(x => x.OrderId)
|
||||
.Select(x => new CustomerSaleDetailOrderInfo() {
|
||||
OrderId = x.Key,
|
||||
OrderItems = x.ToArray(),
|
||||
ProductCategory = x.First().ProductCategory,
|
||||
OrderDate = x.First().OrderDate,
|
||||
InvoiceNumber = x.First().InvoiceNumber,
|
||||
PONumber = x.First().PONumber,
|
||||
StoreCity = x.First().StoreCity,
|
||||
StoreId = x.First().StoreId,
|
||||
EmployeeFullName = x.First().EmployeeFullName,
|
||||
CustomerName = x.First().CustomerName,
|
||||
CustomerPhone = x.First().CustomerPhone,
|
||||
CustomerFax = x.First().CustomerFax,
|
||||
CustomerImage = x.First().CustomerImage,
|
||||
ShippingAmount = x.First().ShippingAmount,
|
||||
TotalAmount = x.First().TotalAmount,
|
||||
CustomerHomeOfficeLine = x.First().CustomerHomeOfficeLine,
|
||||
CustomerHomeOfficeCityLine = x.First().CustomerHomeOfficeCityLine,
|
||||
CustomerBillingAddressLine = x.First().CustomerBillingAddressLine,
|
||||
CustomerBillingAddressCityLine = x.First().CustomerBillingAddressCityLine
|
||||
}).ToArray();
|
||||
}
|
||||
public static List<CustomerSaleDetailOrderItemInfo> GetCustomerSaleOrderItemDetails(long customerId, IQueryable<OrderItem> orderItems) {
|
||||
return orderItems
|
||||
.Where(x => x.Order.CustomerId == customerId)
|
||||
.Select(x => new CustomerSaleDetailOrderItemInfo() {
|
||||
ProductCategory = x.Product.Category,
|
||||
OrderDate = x.Order.OrderDate,
|
||||
OrderId = x.OrderId.Value,
|
||||
InvoiceNumber = x.Order.InvoiceNumber,
|
||||
PONumber = x.Order.PONumber,
|
||||
StoreId = x.Order.Store.Id,
|
||||
StoreCity = x.Order.Store.Address.City,
|
||||
EmployeeFullName = x.Order.Employee.FullName,
|
||||
CustomerName = x.Order.Customer.Name,
|
||||
CustomerPhone = x.Order.Customer.Phone,
|
||||
CustomerFax = x.Order.Customer.Fax,
|
||||
CustomerLogo = x.Order.Customer.Logo,
|
||||
|
||||
CustomerHomeOfficeLine = x.Order.Customer.HomeOffice.Line,
|
||||
CustomerHomeOfficeCity = x.Order.Customer.HomeOffice.City,
|
||||
CustomerHomeOfficeZipCode = x.Order.Customer.HomeOffice.ZipCode,
|
||||
CustomerHomeOfficeState = x.Order.Customer.HomeOffice.State,
|
||||
CustomerBillingAddressLine = x.Order.Customer.BillingAddress.Line,
|
||||
CustomerBillingAddressCity = x.Order.Customer.BillingAddress.City,
|
||||
CustomerBillingAddressZipCode = x.Order.Customer.BillingAddress.ZipCode,
|
||||
CustomerBillingAddressState = x.Order.Customer.BillingAddress.State,
|
||||
|
||||
Total = x.Total,
|
||||
TotalAmount = x.Order.TotalAmount,
|
||||
Discount = x.Discount,
|
||||
ProductUnits = x.ProductUnits,
|
||||
ProductPrice = x.ProductPrice,
|
||||
ShippingAmount = x.Order.ShippingAmount,
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public static IEnumerable<SaleSummaryInfo> GetSaleSummaries(IQueryable<OrderItem> orderItems) {
|
||||
return orderItems.Select(x => new SaleSummaryInfo() {
|
||||
OrderDate = x.Order.OrderDate,
|
||||
InvoiceNumber = x.Order.InvoiceNumber,
|
||||
ProductUnits = x.ProductUnits,
|
||||
ProductPrice = x.ProductPrice,
|
||||
Discount = x.Discount,
|
||||
Total = x.Total,
|
||||
ProductCategory = x.Product.Category,
|
||||
StoreId = x.Order.Store.Id,
|
||||
StoreCity = x.Order.Store.Address.City,
|
||||
StoreCustomerName = x.Order.Store.Customer.Name,
|
||||
}).ToList();
|
||||
}
|
||||
public static IEnumerable<SaleAnalisysInfo> GetSaleAnalysis(IQueryable<OrderItem> orderItems) {
|
||||
return orderItems.Select(x => new SaleAnalisysInfo() {
|
||||
OrderDate = x.Order.OrderDate,
|
||||
ProductCost = x.Product.Cost,
|
||||
ProductUnits = x.ProductUnits,
|
||||
Total = x.Total,
|
||||
}).ToList();
|
||||
}
|
||||
public static IEnumerable<string> GetStateNames(IQueryable<State> queryableStates, IEnumerable<StateEnum> states) {
|
||||
return
|
||||
from ss in queryableStates
|
||||
join s in states on ss.ShortName equals s
|
||||
select ss.LongName;
|
||||
}
|
||||
public static IList<OrderInfo> GetOrderInfo(IQueryable<Order> orders) {
|
||||
return orders.ActualOrders().Select(x => new OrderInfo {
|
||||
InvoiceNumber = x.InvoiceNumber,
|
||||
OrderDate = x.OrderDate,
|
||||
Company = x.Customer.Name,
|
||||
Store = x.Customer.HomeOffice.City,
|
||||
TotalAmount = x.TotalAmount,
|
||||
}).ToList();
|
||||
}
|
||||
public static List<Order> GetAverageOrders(IQueryable<Order> orders, int NumberOfPoints) {
|
||||
DateTime startDate = orders.Min(q => q.OrderDate);
|
||||
DateTime endDate = orders.Max(q => q.OrderDate);
|
||||
int daysPerGroup = Math.Max(1, (endDate - startDate).Days / NumberOfPoints);
|
||||
var constDate = new DateTime(1990, 1, 1);
|
||||
List<decimal> groups = orders
|
||||
.Select(x => new { OrderDate = x.OrderDate, TotalAmount = x.TotalAmount })
|
||||
.ToList()
|
||||
.GroupBy(q => (q.OrderDate - constDate).Days / daysPerGroup)
|
||||
.Select(g => g.Average(q => q.TotalAmount))
|
||||
.ToList();
|
||||
DateTime currentDate = startDate;
|
||||
List<Order> averageOrders = new List<Order>();
|
||||
foreach(decimal total in groups) {
|
||||
averageOrders.Add(new Order { OrderDate = currentDate, TotalAmount = total });
|
||||
currentDate = currentDate.AddDays(daysPerGroup);
|
||||
}
|
||||
return averageOrders;
|
||||
}
|
||||
|
||||
public static List<Quote> GetAverageQuotes(IQueryable<Quote> quotes, int NumberOfPoints) {
|
||||
var startDate = quotes.Min(q => q.Date);
|
||||
var endDate = quotes.Max(q => q.Date);
|
||||
int daysPerGroup = Math.Max(1, (endDate - startDate).Days / NumberOfPoints);
|
||||
var constDate = new DateTime(1990, 1, 1);
|
||||
List<decimal> groups = quotes
|
||||
.Select(x => new { Date = x.Date, Total = x.Total })
|
||||
.ToList()
|
||||
.GroupBy(q => (q.Date - constDate).Days / daysPerGroup)
|
||||
.Select(g => g.Average(q => q.Total))
|
||||
.ToList();
|
||||
DateTime currentDate = startDate;
|
||||
List<Quote> averageQuotes = new List<Quote>();
|
||||
foreach(decimal total in groups) {
|
||||
averageQuotes.Add(new Quote { Date = currentDate, Total = total });
|
||||
currentDate = currentDate.AddDays(daysPerGroup);
|
||||
}
|
||||
return averageQuotes;
|
||||
}
|
||||
|
||||
public static List<SalesInfo> GetSales(IQueryable<OrderItem> orderItems) {
|
||||
var result = orderItems
|
||||
.Select(x => new { OrderDate = x.Order.OrderDate, ProductCategory = x.Product.Category, Total = x.Total })
|
||||
.OrderBy(x => x.OrderDate)
|
||||
.ToList()
|
||||
.GroupBy(x => x.OrderDate.Year)
|
||||
.Select(x => new SalesInfo() {
|
||||
time = new DateTime(x.Key, 1, 1),
|
||||
Caption = "Sales (FY" + x.Key + ")",
|
||||
ListProductInfo = x
|
||||
.GroupBy(y => y.ProductCategory)
|
||||
.Select(y => new SalesProductInfo() {
|
||||
Name = y.Key.ToString(),
|
||||
Value = y.Sum(z => z.Total)
|
||||
})
|
||||
.ToList()
|
||||
}).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
public static IQueryable<ProductInfoWithSales> GetProductInfoWithSales(IQueryable<Product> products) {
|
||||
return products.Select(x => new ProductInfoWithSales {
|
||||
Id = x.Id,
|
||||
Name = x.Name,
|
||||
Cost = x.Cost,
|
||||
RetailPrice = x.RetailPrice,
|
||||
SalePrice = x.SalePrice,
|
||||
CurrentInventory = x.CurrentInventory,
|
||||
Backorder = x.Backorder,
|
||||
TotalSales = x.OrderItems.Sum(orderItem => orderItem.Total)
|
||||
});
|
||||
}
|
||||
public static void UpdateMonthlySales(IQueryable<OrderItem> orderItems, IEnumerable<ProductInfoWithSales> products) {
|
||||
foreach(var productInfo in products) {
|
||||
var sales = orderItems
|
||||
.Where(x => x.Product.Id == productInfo.Id)
|
||||
.GroupBy(x => x.Order.OrderDate.Month)
|
||||
.Select(x => new { Month = x.Key, Sum = (double)x.Sum(i => i.Total) }).ToArray();
|
||||
double[] monthlySales = new double[12];
|
||||
for(int i = 0; i < sales.Length; i++)
|
||||
monthlySales[sales[i].Month - 1] = sales[i].Sum;
|
||||
productInfo.MonthlySales = monthlySales;
|
||||
}
|
||||
}
|
||||
|
||||
public static IQueryable<CustomerInfoWithSales> GetCustomerInfoWithSales(IQueryable<Customer> customers) {
|
||||
return customers.Select(x => new CustomerInfoWithSales {
|
||||
Id = x.Id,
|
||||
Name = x.Name,
|
||||
HomeOfficeLine = x.HomeOffice.Line,
|
||||
HomeOfficeCity = x.HomeOffice.City,
|
||||
HomeOfficeState = x.HomeOffice.State,
|
||||
HomeOfficeZipCode = x.HomeOffice.ZipCode,
|
||||
Phone = x.Phone,
|
||||
Fax = x.Fax,
|
||||
TotalSales = x.Orders.Sum(orderItem => orderItem.TotalAmount)
|
||||
});
|
||||
}
|
||||
public static void UpdateCustomerInfoWithSales(IEnumerable<CustomerInfoWithSales> entities, IQueryable<CustomerStore> stores, IQueryable<CustomerEmployee> employees, IQueryable<Order> orders) {
|
||||
foreach(var item in entities) {
|
||||
item.Init(
|
||||
() => stores.Where(x => x.CustomerId == item.Id).ToArray(),
|
||||
() => employees.Where(x => x.CustomerId == item.Id).ToArray(),
|
||||
orders.Where(x => x.CustomerId == item.Id).GroupBy(o => o.OrderDate.Month).Select(g => g.Sum(i => i.TotalAmount)).ToArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static IQueryable<Order> GetOrdersForPeriod(IQueryable<Order> orders, Period period, DateTime dateTime = new DateTime()) {
|
||||
switch(period) {
|
||||
case Period.ThisYear:
|
||||
return orders.Where(o => o.OrderDate.Year == DateTime.Now.Year);
|
||||
case Period.ThisMonth:
|
||||
return orders.Where(o => o.OrderDate.Month == DateTime.Now.Month && o.OrderDate.Year == DateTime.Now.Year);
|
||||
case Period.FixedDate:
|
||||
return orders.Where(o => o.OrderDate.Month == dateTime.Month && o.OrderDate.Year == dateTime.Year
|
||||
&& o.OrderDate.Day == dateTime.Day);
|
||||
}
|
||||
return orders;
|
||||
}
|
||||
public static IQueryable<Order> GetCustomerOrdersForPeriod(IQueryable<Order> orders, Period period, long customerId) {
|
||||
return GetOrdersForPeriod(orders.Where(o => o.CustomerId == customerId), period);
|
||||
}
|
||||
|
||||
public static IQueryable<OrderItem> GetOrderItemsForPeriod(IQueryable<OrderItem> orderItems, Period period, DateTime dateTime = new DateTime()) {
|
||||
return orderItems.Where(GetOrderItemsForPeriodFilter(period, dateTime));
|
||||
}
|
||||
public static Expression<Func<OrderItem, bool>> GetOrderItemsForPeriodFilter(Period period, DateTime dateTime = new DateTime()) {
|
||||
switch(period) {
|
||||
case Period.ThisYear:
|
||||
return x => x.Order.OrderDate.Year == DateTime.Now.Year;
|
||||
case Period.ThisMonth:
|
||||
return x => x.Order.OrderDate.Month == DateTime.Now.Month && x.Order.OrderDate.Year == DateTime.Now.Year;
|
||||
case Period.FixedDate:
|
||||
return x => x.Order.OrderDate.Month == dateTime.Month && x.Order.OrderDate.Year == dateTime.Year
|
||||
&& x.Order.OrderDate.Day == dateTime.Day;
|
||||
}
|
||||
return x => true;
|
||||
}
|
||||
|
||||
public static IEnumerable<CustomerStore> GetSalesStoresForPeriod(IQueryable<Order> orders, Period period = Period.Lifetime) {
|
||||
return QueriesHelper.GetOrdersForPeriod(orders, period).GroupBy(o => o.Store).Select(g => g.Key).Distinct();
|
||||
}
|
||||
|
||||
public static IEnumerable<MapItem> GetSaleMapItemsByCity(IQueryable<OrderItem> orderItems, long productId, string city, Period period = Period.Lifetime) {
|
||||
return GetSaleMapItems(orderItems.Where(x => x.Order.Store.Address.City == city), productId, period);
|
||||
}
|
||||
public static IEnumerable<MapItem> GetSaleMapItems(IQueryable<OrderItem> orderItems, long productId, Period period = Period.Lifetime) {
|
||||
return GetSaleMapItemsCore(orderItems.Where(QueriesHelper.GetOrderItemsForPeriodFilter(period)).Where(x => x.ProductId == productId));
|
||||
}
|
||||
public static IEnumerable<MapItem> GetSaleMapItemsByCustomer(IQueryable<OrderItem> orderItems, long customerId, Period period = Period.Lifetime) {
|
||||
return GetSaleMapItemsCore(orderItems.Where(x => x.Order.CustomerId == customerId).Where(QueriesHelper.GetOrderItemsForPeriodFilter(period)));
|
||||
}
|
||||
public static IEnumerable<MapItem> GetSaleMapItemsByCustomerAndCity(IQueryable<OrderItem> orderItems, long customerId, string city, Period period = Period.Lifetime) {
|
||||
return GetSaleMapItemsByCustomer(orderItems.Where(x => x.Order.Store.Address.City == city), customerId, period);
|
||||
}
|
||||
static IEnumerable<MapItem> GetSaleMapItemsCore(IQueryable<OrderItem> orderItems) {
|
||||
return orderItems
|
||||
.Select(x => new MapItem {
|
||||
Customer = x.Order.Customer,
|
||||
Product = x.Product,
|
||||
Total = x.Total,
|
||||
Address = x.Order.Store.Address
|
||||
});
|
||||
}
|
||||
|
||||
public static IEnumerable<SalesSummaryItem> GetSalesSummaryItems(IQueryable<OrderItem> orderItems, Period period, DateTime dateTime = new DateTime()) {
|
||||
return GetOrderItemsForPeriod(orderItems, period, dateTime)
|
||||
.GroupBy(oi => oi.Product.Category)
|
||||
.Select(g => new SalesSummaryItem { Category = g.Key, Sales = g.Sum(oi => oi.Total) })
|
||||
.ToList();
|
||||
}
|
||||
public static IEnumerable<CostAverageItem> GetCostAverageItems(IQueryable<OrderItem> orderItems, Period period, DateTime dateTime = new DateTime()) {
|
||||
return GetOrderItemsForPeriod(orderItems, period, dateTime)
|
||||
.GroupBy(oi => oi.Product.Category)
|
||||
.Select(g => new CostAverageItem { Category = g.Key, Cost = g.Average(oi => oi.ProductPrice) })
|
||||
.ToList();
|
||||
}
|
||||
public static IEnumerable<CustomerStore> GetDistinctStoresForPeriod(IQueryable<Order> orders, long customerId, Period period = Period.Lifetime) {
|
||||
return QueriesHelper.GetCustomerOrdersForPeriod(orders, period, customerId).GroupBy(o => o.Store).Select(g => g.Key).Distinct();
|
||||
}
|
||||
|
||||
public static decimal GetQuotesTotal(IQueryable<Quote> quotes, CustomerStore store, DateTime begin, DateTime end) {
|
||||
return quotes.Where(x => x.CustomerStoreId == store.Id && x.Date >= begin && x.Date <= end).CustomSum(x => x.Total);
|
||||
}
|
||||
public static IEnumerable<QuoteSummaryItem> GetSummaryOpportunities(IQueryable<Quote> quotes) {
|
||||
yield return GetSummaryItem(quotes, Stage.High);
|
||||
yield return GetSummaryItem(quotes, Stage.Medium);
|
||||
yield return GetSummaryItem(quotes, Stage.Low);
|
||||
yield return GetSummaryItem(quotes, Stage.Unlikely);
|
||||
}
|
||||
public static IEnumerable<QuoteMapItem> GetOpportunities(IQueryable<Quote> quotes, IQueryable<Customer> customers, Stage stage) {
|
||||
string name = Enum.GetName(typeof(Stage), stage);
|
||||
return from q in GetQuotes(quotes, stage)
|
||||
join c in customers on q.CustomerId equals c.Id
|
||||
select new QuoteMapItem { Stage = stage, Address = q.CustomerStore.Address, Value = q.Total, Date = q.Date };
|
||||
}
|
||||
public static IEnumerable<QuoteMapItem> GetOpportunities(IQueryable<Quote> quotes) {
|
||||
yield return GetOpportunity(quotes, Stage.High);
|
||||
yield return GetOpportunity(quotes, Stage.Medium);
|
||||
yield return GetOpportunity(quotes, Stage.Low);
|
||||
yield return GetOpportunity(quotes, Stage.Unlikely);
|
||||
}
|
||||
static QuoteMapItem GetOpportunity(IQueryable<Quote> quotes, Stage stage) {
|
||||
return new QuoteMapItem {
|
||||
Stage = stage,
|
||||
Value = GetQuotes(quotes, stage).CustomSum(q => q.Total)
|
||||
};
|
||||
}
|
||||
public static decimal GetOpportunity(IQueryable<Quote> quotes, Stage stage, string city) {
|
||||
return GetQuotes(quotes, stage).Where(q => q.CustomerStore.Address.City == city).CustomSum(q => q.Total);
|
||||
}
|
||||
public static IEnumerable<CustomerStore> GetCustomerStore(IQueryable<CustomerStore> stores, IQueryable<Quote> quotes, Stage stage) {
|
||||
return from q in GetQuotes(quotes, stage)
|
||||
join s in stores on q.CustomerStoreId equals s.Id
|
||||
select s;
|
||||
}
|
||||
public static IEnumerable<OrderItem> GetRevenueReportItems(IQueryable<OrderItem> orderItems) {
|
||||
bool hasItemsInCurrentMonth = orderItems.Where(x => x.Order.OrderDate.Month == DateTime.Now.Month && x.Order.OrderDate.Year == DateTime.Now.Year).Any();
|
||||
var dateOfLastOrder = orderItems.Max(x => x.Order.OrderDate);
|
||||
var revenueMonth = hasItemsInCurrentMonth ? DateTime.Now.Month : dateOfLastOrder.Month;
|
||||
var revenueYear = hasItemsInCurrentMonth ? DateTime.Now.Year : dateOfLastOrder.Year;
|
||||
return orderItems.Where(x => x.Order.OrderDate.Month == revenueMonth && x.Order.OrderDate.Year == revenueYear).ToList();
|
||||
}
|
||||
public static IEnumerable<OrderItem> GetRevenueAnalysisReportItems(IQueryable<OrderItem> orderItems, long storeId) {
|
||||
return orderItems.Where(x => x.Order.StoreId.Value == storeId).ToList();
|
||||
}
|
||||
static QuoteSummaryItem GetSummaryItem(IQueryable<Quote> quotes, Stage stage) {
|
||||
var query = GetQuotes(quotes, stage);
|
||||
return new QuoteSummaryItem {
|
||||
StageName = stage.ToString(),
|
||||
Summary = !query.Any() ? 0 : query.CustomSum(q => q.Total)
|
||||
};
|
||||
}
|
||||
static IQueryable<Quote> GetQuotes(IQueryable<Quote> quotes, Stage stage) {
|
||||
double min, max;
|
||||
switch(stage) {
|
||||
case Stage.High:
|
||||
max = 1.0;
|
||||
min = 0.6;
|
||||
break;
|
||||
case Stage.Medium:
|
||||
min = 0.3;
|
||||
max = 0.6;
|
||||
break;
|
||||
case Stage.Low:
|
||||
min = 0.12;
|
||||
max = 0.3;
|
||||
break;
|
||||
case Stage.Summary:
|
||||
min = 0.0;
|
||||
max = 1.0;
|
||||
break;
|
||||
default:
|
||||
min = 0.0;
|
||||
max = 0.12;
|
||||
break;
|
||||
}
|
||||
return quotes.Where(q => q.Opportunity > min && q.Opportunity < max);
|
||||
}
|
||||
}
|
||||
public enum Period {
|
||||
[Display(Name = "Lifetime")]
|
||||
Lifetime,
|
||||
[Display(Name = "This Year")]
|
||||
ThisYear,
|
||||
[Display(Name = "This Month")]
|
||||
ThisMonth,
|
||||
[Display(Name = "Fixed Date")]
|
||||
FixedDate
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class Quote : DatabaseObject {
|
||||
public string Number { get; set; }
|
||||
public virtual Customer Customer { get; set; }
|
||||
public long? CustomerId { get; set; }
|
||||
public virtual CustomerStore CustomerStore { get; set; }
|
||||
public long? CustomerStoreId { get; set; }
|
||||
public virtual Employee Employee { get; set; }
|
||||
public long? EmployeeId { get; set; }
|
||||
public virtual DateTime Date { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal SubTotal { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal ShippingAmount { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Total { get; set; }
|
||||
public double Opportunity { get; set; }
|
||||
public virtual List<QuoteItem> QuoteItems { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class QuoteItem : DatabaseObject {
|
||||
public virtual Quote Quote { get; set; }
|
||||
public long? QuoteId { get; set; }
|
||||
public virtual Product Product { get; set; }
|
||||
public long? ProductId { get; set; }
|
||||
public int ProductUnits { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal ProductPrice { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Discount { get; set; }
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Total { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public class State {
|
||||
[Key]
|
||||
public StateEnum ShortName { get; set; }
|
||||
public string LongName { get; set; }
|
||||
public byte[] Flag48px { get; set; }
|
||||
public byte[] Flag24px { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public enum StateEnum {
|
||||
CA,
|
||||
AR,
|
||||
AL,
|
||||
AK,
|
||||
AZ,
|
||||
CO,
|
||||
CT,
|
||||
DE,
|
||||
DC,
|
||||
FL,
|
||||
GA,
|
||||
HI,
|
||||
ID,
|
||||
IL,
|
||||
IN,
|
||||
IA,
|
||||
KS,
|
||||
KY,
|
||||
LA,
|
||||
ME,
|
||||
MD,
|
||||
MA,
|
||||
MI,
|
||||
MN,
|
||||
MS,
|
||||
MO,
|
||||
MT,
|
||||
NE,
|
||||
NV,
|
||||
NH,
|
||||
NJ,
|
||||
NM,
|
||||
NY,
|
||||
NC,
|
||||
OH,
|
||||
OK,
|
||||
OR,
|
||||
PA,
|
||||
RI,
|
||||
SC,
|
||||
SD,
|
||||
TN,
|
||||
TX,
|
||||
UT,
|
||||
VT,
|
||||
VA,
|
||||
WA,
|
||||
WV,
|
||||
WI,
|
||||
WY,
|
||||
ND
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Windows.Media;
|
||||
using System.Linq;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public enum EmployeeTaskStatus {
|
||||
[Display(Name = "Not Started")]
|
||||
NotStarted,
|
||||
[Display(Name = "Completed")]
|
||||
Completed,
|
||||
[Display(Name = "In Progress")]
|
||||
InProgress,
|
||||
[Display(Name = "Need Assistance")]
|
||||
NeedAssistance,
|
||||
[Display(Name = "Deferred")]
|
||||
Deferred
|
||||
}
|
||||
public enum EmployeeTaskPriority {
|
||||
Low,
|
||||
Normal,
|
||||
High,
|
||||
Urgent
|
||||
}
|
||||
public enum EmployeeTaskFollowUp {
|
||||
[Display(Name = "Today")]
|
||||
Today,
|
||||
[Display(Name = "Tomorrow")]
|
||||
Tomorrow,
|
||||
[Display(Name = "This Week")]
|
||||
ThisWeek,
|
||||
[Display(Name = "Next Week")]
|
||||
NextWeek,
|
||||
[Display(Name = "No Date")]
|
||||
NoDate,
|
||||
[Display(Name = "Custom")]
|
||||
Custom
|
||||
}
|
||||
|
||||
public class EmployeeTask : DatabaseObject {
|
||||
public EmployeeTask() {
|
||||
AssignedEmployees = new List<Employee>();
|
||||
}
|
||||
public virtual List<Employee> AssignedEmployees { get; set; }
|
||||
[Required]
|
||||
public string Subject { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string RtfTextDescription { get; set; }
|
||||
public DateTime? StartDate { get; set; }
|
||||
public DateTime? DueDate { get; set; }
|
||||
public EmployeeTaskStatus Status { get; set; }
|
||||
public EmployeeTaskPriority Priority { get; set; }
|
||||
public int Completion { get; set; }
|
||||
public bool Reminder { get; set; }
|
||||
public DateTime? ReminderDateTime { get; set; }
|
||||
public virtual Employee AssignedEmployee { get; set; }
|
||||
public long? AssignedEmployeeId { get; set; }
|
||||
public virtual Employee Owner { get; set; }
|
||||
public long? OwnerId { get; set; }
|
||||
public virtual CustomerEmployee CustomerEmployee { get; set; }
|
||||
public long? CustomerEmployeeId { get; set; }
|
||||
public EmployeeTaskFollowUp FollowUp { get; set; }
|
||||
public bool Private { get; set; }
|
||||
public string Category { get; set; }
|
||||
public virtual List<TaskAttachedFile> AttachedFiles { get; set; }
|
||||
public bool AttachedCollectionsChanged { get; set; }
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("{0} - {1}, due {2}, {3},\r\nOwner: {4}", Subject, Description, DueDate, Status, Owner);
|
||||
}
|
||||
public bool Overdue {
|
||||
get {
|
||||
if(Status == EmployeeTaskStatus.Completed || !DueDate.HasValue) return false;
|
||||
DateTime dDate = DueDate.Value.Date.AddDays(1);
|
||||
if(DateTime.Now >= dDate) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public int AttachedFilesCount {
|
||||
get {
|
||||
return (AttachedFiles == null) ? 0 : AttachedFiles.Count;
|
||||
}
|
||||
}
|
||||
public string AssignedEmployeesFullList {
|
||||
get {
|
||||
if(AssignedEmployees == null)
|
||||
return "";
|
||||
return string.Join(", ", AssignedEmployees.Select(x => x.FullName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevExpress.DevAV {
|
||||
public static partial class AddressHelper {
|
||||
public static Address DevAVHomeOffice { get { return devAVHomeOffice; } }
|
||||
|
||||
static Address devAVHomeOffice = new Address {
|
||||
City = "Glendale",
|
||||
Line = "505 N. Brand Blvd",
|
||||
State = StateEnum.CA,
|
||||
ZipCode = "91203",
|
||||
Latitude = 34.1532866,
|
||||
Longitude = -118.2555815
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user