code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(8)] public class Migration_008 : Migration { public override void Up() { Create.Column("PriceTag").OnTable("Departments").AsString(10).Nullable(); Create.Column("Tag").OnTable("MenuItems").AsString(128).Nullable(); Create.Column("PriceTag").OnTable("TicketItems").AsString(10).Nullable(); Create.Column("Tag").OnTable("TicketItems").AsString(128).Nullable(); Create.Table("ActionContainers") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("AppActionId").AsInt32().WithDefaultValue(0) .WithColumn("AppRuleId").AsInt32().WithDefaultValue(0) .WithColumn("ParameterValues").AsString(500).Nullable() .WithColumn("Order").AsInt32().WithDefaultValue(0); Create.Table("AppActions") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("ActionType").AsString(128).Nullable() .WithColumn("Parameter").AsString(500).Nullable(); Create.Table("AppRules") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("EventName").AsString(128).Nullable() .WithColumn("EventConstraints").AsString(500).Nullable(); Create.Table("MenuItemPriceDefinitions") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("PriceTag").AsString(10).Nullable(); Create.Table("MenuItemPrices") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("MenuItemPortionId").AsInt32().WithDefaultValue(0) .WithColumn("PriceTag").AsString(10).Nullable() .WithColumn("Price").AsDecimal(16, 2).WithDefaultValue(0); Create.Table("Triggers") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("Expression").AsString(128).Nullable() .WithColumn("LastTrigger").AsDateTime().WithDefaultValue(new DateTime(2000, 1, 1)); Create.Table("AccountTransactions") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("Date").AsDateTime().WithDefaultValue(new DateTime(2000, 1, 1)) .WithColumn("TransactionType").AsInt32().WithDefaultValue(0) .WithColumn("Amount").AsDecimal(16, 2).WithDefaultValue(0) .WithColumn("UserId").AsInt32().WithDefaultValue(0) .WithColumn("CustomerId").AsInt32().WithDefaultValue(0); Create.ForeignKey("AppRule_Actions") .FromTable("ActionContainers").ForeignColumn("AppRuleId") .ToTable("AppRules").PrimaryColumn("Id"); Create.ForeignKey("MenuItemPortion_Prices") .FromTable("MenuItemPrices").ForeignColumn("MenuItemPortionId") .ToTable("MenuItemPortions").PrimaryColumn("Id").OnDelete(Rule.Cascade); Create.Index("IX_Tickets_LastPaymentDate").OnTable("Tickets").OnColumn("LastPaymentDate").Ascending() .WithOptions().NonClustered(); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_008.cs
C#
gpl3
3,928
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(13)] public class Migration_013 : Migration { public override void Up() { Create.Column("GroupTemplate").OnTable("PrinterTemplates").AsString(500).Nullable(); Create.Column("CloseTicket").OnTable("PrintJobs").AsBoolean().WithDefaultValue(true); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_013.cs
C#
gpl3
605
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(9)] public class Migration_009 : Migration { public override void Up() { Delete.Column("SourceId").FromTable("Discounts"); Create.Column("SaveFreeTags").OnTable("TicketTagGroups").AsBoolean().WithDefaultValue(true); Create.Column("ExcludeVat").OnTable("PrintJobs").AsBoolean().WithDefaultValue(false); Create.Column("Tag").OnTable("ScreenMenuItems").AsString(128).Nullable(); Create.Column("UsageCount").OnTable("ScreenMenuItems").AsInt32().WithDefaultValue(0); Create.Column("ItemPortion").OnTable("ScreenMenuItems").AsString(128).Nullable(); Create.Column("SubButtonHeight").OnTable("ScreenMenuCategories").AsInt32().WithDefaultValue(65); Create.Column("MaxItems").OnTable("ScreenMenuCategories").AsInt32().WithDefaultValue(0); Create.Column("SortType").OnTable("ScreenMenuCategories").AsInt32().WithDefaultValue(0); Create.Column("VatAmount").OnTable("TicketItemProperties").AsDecimal(16, 2).WithDefaultValue(0); Create.Column("VatRate").OnTable("TicketItems").AsDecimal(16, 2).WithDefaultValue(0); Create.Column("VatAmount").OnTable("TicketItems").AsDecimal(16, 2).WithDefaultValue(0); Create.Column("VatTemplateId").OnTable("TicketItems").AsInt32().WithDefaultValue(0); Create.Column("VatIncluded").OnTable("TicketItems").AsBoolean().WithDefaultValue(false); Create.Column("VatTemplate_Id").OnTable("MenuItems").AsInt32().Nullable(); Create.Table("VatTemplates") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("Rate").AsDecimal(16, 2) .WithColumn("VatIncluded").AsBoolean().WithDefaultValue(false); Create.ForeignKey("MenuItem_VatTemplate") .FromTable("MenuItems").ForeignColumn("VatTemplate_Id") .ToTable("VatTemplates").PrimaryColumn("Id"); Create.Table("TaxServiceTemplates") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("Order").AsInt32().WithDefaultValue(0) .WithColumn("CalculationMethod").AsInt32().WithDefaultValue(0) .WithColumn("Amount").AsDecimal(16, 2).WithDefaultValue(0); Create.Table("DepartmentTaxServiceTemplates") .WithColumn("Department_Id").AsInt32().WithDefaultValue(0) .WithColumn("TaxServiceTemplate_Id").AsInt32().WithDefaultValue(0); Create.ForeignKey("Department_TaxServiceTemplates_Target") .FromTable("DepartmentTaxServiceTemplates").ForeignColumn("TaxServiceTemplate_Id") .ToTable("TaxServiceTemplates").PrimaryColumn("Id") .OnDelete(Rule.Cascade); Create.ForeignKey("Department_TaxServiceTemplates_Source") .FromTable("DepartmentTaxServiceTemplates").ForeignColumn("Department_Id") .ToTable("Departments").PrimaryColumn("Id") .OnDelete(Rule.Cascade); Create.Table("TaxServices") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("TicketId").AsInt32().WithDefaultValue(0) .WithColumn("TaxServiceId").AsInt32().WithDefaultValue(0) .WithColumn("TaxServiceType").AsInt32().WithDefaultValue(0) .WithColumn("CalculationType").AsInt32().WithDefaultValue(0) .WithColumn("Amount").AsDecimal(16, 2).WithDefaultValue(0) .WithColumn("CalculationAmount").AsDecimal(16, 2).WithDefaultValue(0); Create.ForeignKey("Ticket_TaxServices") .FromTable("TaxServices").ForeignColumn("TicketId") .ToTable("Tickets").PrimaryColumn("Id") .OnDelete(Rule.Cascade); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_009.cs
C#
gpl3
4,364
using FluentMigrator; using Samba.Infrastructure.Settings; namespace Samba.Persistance.DBMigration { [Migration(16)] public class Migration_016 : Migration { public override void Up() { Create.Column("ExcludeInReports").OnTable("TicketTagGroups").AsBoolean().WithDefaultValue(false); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_016.cs
C#
gpl3
445
using System; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(1)] public class Migration_001 : Migration { public override void Up() { Create.Column("ModifiedDateTime").OnTable("TicketItems").AsDate().WithDefaultValue(new DateTime(2010, 1, 1)); Create.Column("CreatedDateTime").OnTable("TicketItems").AsDate().WithDefaultValue(new DateTime(2010, 1, 1)); Create.Column("ModifiedUserId").OnTable("TicketItems").AsInt32().WithDefaultValue(1); Delete.Column("GiftedUserId").FromTable("TicketItems"); Delete.Column("VoidedUserId").FromTable("TicketItems"); } public override void Down() { Delete.Column("ModifiedDateTime").FromTable("TicketItems"); Delete.Column("CreatedDateTime").FromTable("TicketItems"); Delete.Column("ModifiedUserId").FromTable("TicketItems"); Create.Column("GiftedUserId").OnTable("TicketItems").AsInt32(); Create.Column("VoidedUserId").OnTable("TicketItems").AsInt32(); } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_001.cs
C#
gpl3
1,133
using System; using System.Collections.Generic; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(5)] public class Migration_005 : Migration { public override void Up() { Execute.Sql("delete from TicketItemProperties where TicketItem_Id in (select Id from TicketItems where Ticket_Id is null)"); Execute.Sql("delete from TicketItems where Ticket_Id is null"); Create.Column("NumeratorHeight").OnTable("TableScreens").AsInt32().WithDefaultValue(0); Create.Column("AlphaButtonValues").OnTable("TableScreens").AsString(128).Nullable(); Create.Column("Tag").OnTable("Tickets").AsString(128).Nullable(); Create.Column("TicketTag").OnTable("PrinterMaps").AsString(128).Nullable(); Create.Column("InternalAccount").OnTable("Customers").AsBoolean().WithDefaultValue(false); Create.Column("OpenTicketViewColumnCount").OnTable("Departments").AsInt32().WithDefaultValue(5); Delete.ForeignKey("Ticket_TicketItems").OnTable("TicketItems"); Create.Column("TicketId").OnTable("TicketItems").AsInt32().WithDefaultValue(0).NotNullable(); Execute.Sql("Update TicketItems set TicketId=Ticket_Id"); Delete.Column("Ticket_Id").FromTable("TicketItems"); Create.ForeignKey("Ticket_TicketItems") .FromTable("TicketItems").ForeignColumn("TicketId") .ToTable("Tickets").PrimaryColumn("Id"); Delete.ForeignKey("UserRole_Permissions").OnTable("Permissions"); Create.Column("UserRoleId").OnTable("Permissions").AsInt32().WithDefaultValue(0).NotNullable(); Execute.Sql("Update Permissions set UserRoleId=UserRole_Id"); Delete.Column("UserRole_Id").FromTable("Permissions"); Create.ForeignKey("UserRole_Permissions") .FromTable("Permissions").ForeignColumn("UserRoleId") .ToTable("UserRoles").PrimaryColumn("Id"); Create.Table("TicketTags") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("Numerator_Id").AsInt32().Nullable() .WithColumn("Account_Id").AsInt32().Nullable(); Create.Table("CostItems") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("PeriodicConsumptionId").AsInt32().NotNullable().WithDefaultValue(0) .WithColumn("Quantity").AsDecimal().WithDefaultValue(0) .WithColumn("CostPrediction").AsDecimal().WithDefaultValue(0) .WithColumn("Cost").AsDecimal().WithDefaultValue(0) .WithColumn("Portion_Id").AsInt32().Nullable(); Create.Table("InventoryItems") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("GroupCode").AsString(128).Nullable() .WithColumn("BaseUnit").AsString(10).Nullable() .WithColumn("TransactionUnit").AsString(10).Nullable() .WithColumn("TransactionUnitMultiplier").AsInt32().WithDefaultValue(0); Create.Table("PeriodicConsumptionItems") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("PeriodicConsumptionId").AsInt32().WithDefaultValue(0) .WithColumn("UnitMultiplier").AsDecimal().WithDefaultValue(0) .WithColumn("InStock").AsDecimal().WithDefaultValue(0) .WithColumn("Purchase").AsDecimal().WithDefaultValue(0) .WithColumn("Consumption").AsDecimal().WithDefaultValue(0) .WithColumn("PhysicalInventory").AsDecimal().Nullable() .WithColumn("Cost").AsDecimal().WithDefaultValue(0) .WithColumn("InventoryItem_Id").AsInt32().Nullable(); Create.Table("PeriodicConsumptions") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("WorkPeriodId").AsInt32().NotNullable().WithDefaultValue(0) .WithColumn("StartDate").AsDateTime().WithDefaultValue(new DateTime(2000, 1, 1)) .WithColumn("EndDate").AsDateTime().WithDefaultValue(new DateTime(2000, 1, 1)); Create.Table("RecipeItems") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("RecipeId").AsInt32().WithDefaultValue(0) .WithColumn("Quantity").AsDecimal().WithDefaultValue(0) .WithColumn("InventoryItem_Id").AsInt32().Nullable(); Create.Table("Recipes") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("Portion_Id").AsInt32().Nullable(); Create.Table("TransactionItems") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("TransactionId").AsInt32().WithDefaultValue(0) .WithColumn("Unit").AsString(128).Nullable() .WithColumn("Multiplier").AsInt32().NotNullable().WithDefaultValue(0) .WithColumn("Quantity").AsDecimal().WithDefaultValue(0) .WithColumn("Price").AsDecimal().WithDefaultValue(0) .WithColumn("InventoryItem_Id").AsInt32().Nullable(); Create.Table("Transactions") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("Date").AsDateTime().WithDefaultValue(new DateTime(2000, 1, 1)); Create.ForeignKey("TicketTag_Numerator") .FromTable("TicketTags").ForeignColumn("Numerator_Id") .ToTable("Numerators").PrimaryColumn("Id"); Create.ForeignKey("CostItem_Portion") .FromTable("CostItems").ForeignColumn("Portion_Id") .ToTable("MenuItemPortions").PrimaryColumn("Id"); Create.ForeignKey("PeriodicConsumption_CostItems") .FromTable("CostItems").ForeignColumn("PeriodicConsumptionId") .ToTable("PeriodicConsumptions").PrimaryColumn("Id"); Create.ForeignKey("PeriodicConsumptionItem_InventoryItem") .FromTable("PeriodicConsumptionItems").ForeignColumn("InventoryItem_Id") .ToTable("InventoryItems").PrimaryColumn("Id"); Create.ForeignKey("RecipeItem_InventoryItem") .FromTable("RecipeItems").ForeignColumn("InventoryItem_Id") .ToTable("InventoryItems").PrimaryColumn("Id"); Create.ForeignKey("TransactionItem_InventoryItem") .FromTable("TransactionItems").ForeignColumn("InventoryItem_Id") .ToTable("InventoryItems").PrimaryColumn("Id"); Create.ForeignKey("PeriodicConsumption_PeriodicConsumptionItems") .FromTable("PeriodicConsumptionItems").ForeignColumn("PeriodicConsumptionId") .ToTable("PeriodicConsumptions").PrimaryColumn("Id"); Create.ForeignKey("Recipe_RecipeItems") .FromTable("RecipeItems").ForeignColumn("RecipeId") .ToTable("Recipes").PrimaryColumn("Id"); Create.ForeignKey("Recipe_Portion") .FromTable("Recipes").ForeignColumn("Portion_Id") .ToTable("MenuItemPortions").PrimaryColumn("Id"); Create.ForeignKey("Transaction_TransactionItems") .FromTable("TransactionItems").ForeignColumn("TransactionId") .ToTable("Transactions").PrimaryColumn("Id"); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_005.cs
C#
gpl3
8,172
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(11)] public class Migration_011 : Migration { public override void Up() { Create.Column("GroupCode").OnTable("Customers").AsString(128).Nullable(); Create.Column("CustomerGroupCode").OnTable("Tickets").AsString(128).Nullable(); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_011.cs
C#
gpl3
588
using FluentMigrator; using Samba.Infrastructure.Settings; namespace Samba.Persistance.DBMigration { [Migration(19)] public class Migration_019 : Migration { public override void Up() { Create.Column("ReplacementPattern").OnTable("Printers").AsString(128).Nullable(); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_019.cs
C#
gpl3
429
using FluentMigrator; using Samba.Infrastructure.Settings; namespace Samba.Persistance.DBMigration { [Migration(18)] public class Migration_018 : Migration { public override void Up() { if (!LocalSettings.ConnectionString.ToLower().Contains(".sdf")) { Execute.Sql("CREATE NONCLUSTERED INDEX IDX_TicketItems_All ON TicketItems (TicketId) INCLUDE (Id,MenuItemId,MenuItemName,PortionName,Price,CurrencyCode,Quantity,PortionCount,Locked,Voided,ReasonId,Gifted,OrderNumber,CreatingUserId,CreatedDateTime,ModifiedUserId,ModifiedDateTime,PriceTag,Tag,DepartmentId,VatRate,VatAmount,VatTemplateId,VatIncluded)"); } } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_018.cs
C#
gpl3
811
using System; using System.Collections.Generic; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(4)] public class Migration_004 : Migration { public override void Up() { Delete.ForeignKey("Terminal_AlaCartePrinter").OnTable("Terminals"); Delete.ForeignKey("Terminal_FastFoodPrinter").OnTable("Terminals"); Delete.ForeignKey("Terminal_KitchenPrinter").OnTable("Terminals"); Delete.ForeignKey("Terminal_TakeAwayPrinter").OnTable("Terminals"); Delete.ForeignKey("Terminal_TicketPrinter").OnTable("Terminals"); Delete.ForeignKey("Terminal_AlaCartePrinterTemplate").OnTable("Terminals"); Delete.ForeignKey("Terminal_FastFoodPrinterTemplate").OnTable("Terminals"); Delete.ForeignKey("Terminal_KitchenPrinterTemplate").OnTable("Terminals"); Delete.ForeignKey("Terminal_TakeAwayPrinterTemplate").OnTable("Terminals"); Delete.ForeignKey("Terminal_TicketPrinterTemplate").OnTable("Terminals"); Delete.Column("DepartmentType").FromTable("PrinterMaps"); Delete.Column("TicketPrinter_Id").FromTable("Terminals"); Delete.Column("KitchenPrinter_Id").FromTable("Terminals"); Delete.Column("AlaCartePrinter_Id").FromTable("Terminals"); Delete.Column("TakeAwayPrinter_Id").FromTable("Terminals"); Delete.Column("FastFoodPrinter_Id").FromTable("Terminals"); Delete.Column("TicketPrinterTemplate_Id").FromTable("Terminals"); Delete.Column("KitchenPrinterTemplate_Id").FromTable("Terminals"); Delete.Column("AlaCartePrinterTemplate_Id").FromTable("Terminals"); Delete.Column("TakeAwayPrinterTemplate_Id").FromTable("Terminals"); Delete.Column("FastFoodPrinterTemplate_Id").FromTable("Terminals"); Create.Column("PrintJob_Id").OnTable("PrinterMaps").AsInt32().Nullable(); Create.Column("PageHeight").OnTable("Printers").AsInt32().WithDefaultValue(0).NotNullable(); Alter.Column("HeaderTemplate").OnTable("PrinterTemplates").AsString(500).Nullable(); Alter.Column("LineTemplate").OnTable("PrinterTemplates").AsString(500).Nullable(); Alter.Column("VoidedLineTemplate").OnTable("PrinterTemplates").AsString(500).Nullable(); Alter.Column("GiftLineTemplate").OnTable("PrinterTemplates").AsString(500).Nullable(); Alter.Column("FooterTemplate").OnTable("PrinterTemplates").AsString(500).Nullable(); Create.Column("PrintJobData").OnTable("Tickets").AsString(128).Nullable(); Delete.Column("LastUpdateTime").FromTable("Tickets"); Create.Column("LastUpdateTime").OnTable("Tickets").AsDateTime().WithDefaultValue(new DateTime(2000, 1, 1)); Create.Table("PrintJobs") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("ButtonText").AsString(128).Nullable() .WithColumn("Order").AsInt32().WithDefaultValue(0) .WithColumn("AutoPrintIfCash").AsBoolean().WithDefaultValue(false) .WithColumn("AutoPrintIfCreditCard").AsBoolean().WithDefaultValue(false) .WithColumn("AutoPrintIfTicket").AsBoolean().WithDefaultValue(false) .WithColumn("WhenToPrint").AsInt32().WithDefaultValue(0) .WithColumn("WhatToPrint").AsInt32().WithDefaultValue(0) .WithColumn("LocksTicket").AsBoolean().WithDefaultValue(false) .WithColumn("UseFromPaymentScreen").AsBoolean().WithDefaultValue(false) .WithColumn("UseFromTerminal").AsBoolean().WithDefaultValue(false); Create.ForeignKey("PrintJob_PrinterMaps") .FromTable("PrinterMaps").ForeignColumn("PrintJob_Id") .ToTable("PrintJobs").PrimaryColumn("Id"); Create.Table("TerminalPrintJobs") .WithColumn("Terminal_Id").AsInt32().WithDefaultValue(0) .WithColumn("PrintJob_Id").AsInt32().WithDefaultValue(0); Create.ForeignKey("Terminal_PrintJobs_Source") .FromTable("TerminalPrintJobs").ForeignColumn("Terminal_Id") .ToTable("Terminals").PrimaryColumn("Id"); Create.ForeignKey("Terminal_PrintJobs_Target") .FromTable("TerminalPrintJobs").ForeignColumn("PrintJob_Id") .ToTable("PrintJobs").PrimaryColumn("Id"); } public override void Down() { } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_004.cs
C#
gpl3
4,768
using FluentMigrator; using Samba.Infrastructure.Settings; namespace Samba.Persistance.DBMigration { [Migration(15)] public class Migration_015 : Migration { public override void Up() { Create.Column("HtmlContent").OnTable("Tables").AsString(128).Nullable(); Create.Column("ForceValue").OnTable("MenuItemPropertyGroups").AsBoolean().WithDefaultValue(false); Create.Column("GroupTag").OnTable("MenuItemPropertyGroups").AsString(128).Nullable(); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_015.cs
C#
gpl3
631
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Samba.Persistance.DBMigration")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Samba.Persistance.DBMigration")] [assembly: AssemblyCopyright("Copyright © 2010")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("2fbcbab7-7fc5-4698-9b40-437e8714da1e")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Properties/AssemblyInfo.cs
C#
gpl3
1,470
using FluentMigrator; using Samba.Infrastructure.Settings; namespace Samba.Persistance.DBMigration { [Migration(20)] public class Migration_020 : Migration { public override void Up() { if (!LocalSettings.ConnectionString.ToLower().Contains(".sdf")) { Execute.Sql("CREATE NONCLUSTERED INDEX IDX_TicketItemProperties_All ON TicketItemProperties (TicketItemId) INCLUDE (Id,Name,PropertyPrice_CurrencyCode,PropertyPrice_Amount,PropertyGroupId,Quantity,MenuItemId,PortionName,CalculateWithParentPrice,VatAmount)"); Execute.Sql("CREATE NONCLUSTERED INDEX IDX_Payments_All ON Payments (Ticket_Id) INCLUDE (Id,Amount,Date,PaymentType,UserId,DepartmentId)"); } Create.Column("HideExitButton").OnTable("Terminals").AsBoolean().WithDefaultValue(false); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_020.cs
C#
gpl3
977
using FluentMigrator; using Samba.Infrastructure.Settings; namespace Samba.Persistance.DBMigration { [Migration(17)] public class Migration_017 : Migration { public override void Up() { Create.Column("AutoRefresh").OnTable("Tables").AsBoolean().WithDefaultValue(true); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_017.cs
C#
gpl3
430
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(7)] public class Migration_007 : Migration { public override void Up() { Create.Column("MergeLines").OnTable("PrinterTemplates").AsBoolean().WithDefaultValue(false); Execute.Sql("Update PrinterTemplates set MergeLines=1"); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_007.cs
C#
gpl3
585
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(10)] public class Migration_010 : Migration { public override void Up() { Create.Column("PriceTags").OnTable("TicketTagGroups").AsBoolean().WithDefaultValue(false); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_010.cs
C#
gpl3
512
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using FluentMigrator; using Samba.Infrastructure.Settings; namespace Samba.Persistance.DBMigration { [Migration(6)] public class Migration_006 : Migration { public override void Up() { Execute.Sql("delete from ScreenMenuItems where ScreenMenuCategory_Id in(select Id from ScreenMenuCategories where ScreenMenu_Id is null)"); Execute.Sql("delete from ScreenMenuItems where ScreenMenuCategory_Id is null"); Execute.Sql("delete from ScreenMenuCategories where ScreenMenu_Id is null"); Execute.Sql("delete from PrinterMaps where PrintJob_Id is null"); Delete.ForeignKey("ScreenMenu_Categories").OnTable("ScreenMenuCategories"); Create.Column("ScreenMenuId").OnTable("ScreenMenuCategories").AsInt32().WithDefaultValue(0).NotNullable(); Execute.Sql("Update ScreenMenuCategories set ScreenMenuId=ScreenMenu_Id"); Delete.Column("ScreenMenu_Id").FromTable("ScreenMenuCategories"); Create.ForeignKey("ScreenMenu_Categories") .FromTable("ScreenMenuCategories").ForeignColumn("ScreenMenuId") .ToTable("ScreenMenus").PrimaryColumn("Id"); Delete.ForeignKey("ScreenMenuCategory_ScreenMenuItems").OnTable("ScreenMenuItems"); Create.Column("ScreenMenuCategoryId").OnTable("ScreenMenuItems").AsInt32().WithDefaultValue(0).NotNullable(); Execute.Sql("Update ScreenMenuItems set ScreenMenuCategoryId=ScreenMenuCategory_Id"); Delete.Column("ScreenMenuCategory_Id").FromTable("ScreenMenuItems"); Create.ForeignKey("ScreenMenuCategory_ScreenMenuItems") .FromTable("ScreenMenuItems").ForeignColumn("ScreenMenuCategoryId") .ToTable("ScreenMenuCategories").PrimaryColumn("Id"); if (LocalSettings.ConnectionString.EndsWith(".sdf")) Delete.ForeignKey("PrintJob_PrinterMaps").OnTable("PrinterMaps"); else { Execute.Sql( @"DECLARE @default sysname, @sql nvarchar(max); SELECT @default = CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE COLUMN_NAME= 'PrintJob_Id' AND TABLE_NAME='PrinterMaps'; SET @sql = N'ALTER TABLE [PrinterMaps] DROP CONSTRAINT ' + @default; EXEC sp_executesql @sql;"); } Create.Column("PrintJobId").OnTable("PrinterMaps").AsInt32().WithDefaultValue(0).NotNullable(); Execute.Sql("Update PrinterMaps set PrintJobId=PrintJob_Id"); Delete.Column("PrintJob_Id").FromTable("PrinterMaps"); Create.ForeignKey("PrintJob_PrinterMaps") .FromTable("PrinterMaps").ForeignColumn("PrintJobId") .ToTable("PrintJobs").PrimaryColumn("Id"); Execute.Sql("update Tickets set Tag = Tag+':'+Tag where Tag is not null and Tag != '' and CHARINDEX('#',Tag) = 0 and CHARINDEX(':',Tag) = 0 "); Delete.Table("TicketTags"); Execute.Sql("Delete from TicketItemProperties where TicketItem_Id is null"); Delete.ForeignKey("TicketItem_Properties").OnTable("TicketItemProperties"); Create.Column("TicketItemId").OnTable("TicketItemProperties").AsInt32().WithDefaultValue(0).NotNullable(); Execute.Sql("Update TicketItemProperties set TicketItemId=TicketItem_Id"); Delete.Column("TicketItem_Id").FromTable("TicketItemProperties"); Create.ForeignKey("TicketItem_Properties") .FromTable("TicketItemProperties").ForeignColumn("TicketItemId") .ToTable("TicketItems").PrimaryColumn("Id") .OnDelete(Rule.Cascade); Create.Table("DepartmentTicketTagGroups") .WithColumn("Department_Id").AsInt32().PrimaryKey() .WithColumn("TicketTagGroup_Id").AsInt32().PrimaryKey(); Create.Table("TicketTags") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("AccountId").AsInt32().WithDefaultValue(0) .WithColumn("AccountName").AsString(128).Nullable() .WithColumn("TicketTagGroupId").AsInt32().WithDefaultValue(0).NotNullable(); Create.Table("TicketTagGroups") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString(128).Nullable() .WithColumn("Order").AsInt32().WithDefaultValue(0) .WithColumn("Action").AsInt32().WithDefaultValue(0) .WithColumn("FreeTagging").AsBoolean().WithDefaultValue(false) .WithColumn("ButtonColorWhenTagSelected").AsString(128).Nullable() .WithColumn("ButtonColorWhenNoTagSelected").AsString(128).Nullable() .WithColumn("ActiveOnPosClient").AsBoolean().WithDefaultValue(false) .WithColumn("ActiveOnTerminalClient").AsBoolean().WithDefaultValue(false) .WithColumn("ForceValue").AsBoolean().WithDefaultValue(false) .WithColumn("NumericTags").AsBoolean().WithDefaultValue(false) .WithColumn("Numerator_Id").AsInt32().Nullable(); Create.ForeignKey("Department_TicketTagGroups_Target") .FromTable("DepartmentTicketTagGroups").ForeignColumn("TicketTagGroup_Id") .ToTable("TicketTagGroups").PrimaryColumn("Id"); Create.ForeignKey("TicketTagGroup_Numerator") .FromTable("TicketTagGroups").ForeignColumn("Numerator_Id") .ToTable("Numerators").PrimaryColumn("Id"); Create.ForeignKey("TicketTagGroup_TicketTags") .FromTable("TicketTags").ForeignColumn("TicketTagGroupId") .ToTable("TicketTagGroups").PrimaryColumn("Id"); Create.Column("DefaultTag").OnTable("Departments").AsString(128).Nullable(); Create.Column("TerminalDefaultTag").OnTable("Departments").AsString(128).Nullable(); Create.Column("MenuItemId").OnTable("MenuItemProperties").AsInt32().WithDefaultValue(0); Create.Column("MultipleSelection").OnTable("MenuItemPropertyGroups").AsBoolean().WithDefaultValue(false); Create.Column("ColumnCount").OnTable("MenuItemPropertyGroups").AsInt32().WithDefaultValue(0); Create.Column("ButtonHeight").OnTable("MenuItemPropertyGroups").AsInt32().WithDefaultValue(0); Create.Column("TerminalColumnCount").OnTable("MenuItemPropertyGroups").AsInt32().WithDefaultValue(0); Create.Column("TerminalButtonHeight").OnTable("MenuItemPropertyGroups").AsInt32().WithDefaultValue(0); Create.Column("CalculateWithParentPrice").OnTable("MenuItemPropertyGroups").AsBoolean().WithDefaultValue(false); Execute.Sql("Update MenuItemPropertyGroups set ColumnCount=5, ButtonHeight=65, TerminalColumnCount=4, TerminalButtonHeight=35"); Create.Column("FixedCost").OnTable("Recipes").AsDecimal(16, 2).WithDefaultValue(0); Create.Column("DefaultProperties").OnTable("ScreenMenuItems").AsString(128).Nullable(); Create.Column("Quantity").OnTable("TicketItemProperties").AsDecimal(16, 2).WithDefaultValue(0); Create.Column("MenuItemId").OnTable("TicketItemProperties").AsInt32().WithDefaultValue(0); Create.Column("PortionName").OnTable("TicketItemProperties").AsString(128).Nullable(); Create.Column("CalculateWithParentPrice").OnTable("TicketItemProperties").AsBoolean().WithDefaultValue(false); Create.Column("UseForPaidTickets").OnTable("PrintJobs").AsBoolean().WithDefaultValue(false); Create.Column("UseFromPos").OnTable("PrintJobs").AsBoolean().WithDefaultValue(false); Execute.Sql("Update PrintJobs set UseFromPos=1"); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_006.cs
C#
gpl3
8,191
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(12)] public class Migration_012 : Migration { public override void Up() { Create.Column("IsImageOnly").OnTable("ScreenMenuItems").AsBoolean().WithDefaultValue(false); } public override void Down() { //do nothing } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_012.cs
C#
gpl3
514
using System; using System.Collections.Generic; using System.Linq; using System.Text; using FluentMigrator; namespace Samba.Persistance.DBMigration { [Migration(3)] public class Migration_003 : Migration { public override void Up() { Create.Table("Permissions") .WithColumn("Id").AsInt32().Identity().PrimaryKey() .WithColumn("Name").AsString().WithDefaultValue("").Nullable() .WithColumn("UserRole_Id").AsInt32().Nullable() .WithColumn("Value").AsInt32().WithDefaultValue(0); Create.ForeignKey("UserRole_Permissions") .FromTable("Permissions").ForeignColumn("UserRole_Id") .ToTable("UserRoles").PrimaryColumn("Id"); Delete.Column("CanExecuteDashboard").FromTable("UserRoles"); } public override void Down() { Delete.Table("Permissions"); } } }
zzgaminginc-pointofssale
Samba.Persistance.DBMigration/Migration_003.cs
C#
gpl3
993
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Samba.Modules.CidMonitor { public partial class FrmMain : Form { public FrmMain() { InitializeComponent(); } private void FrmMain_Load(object sender, EventArgs e) { } } }
zzgaminginc-pointofssale
Samba.Modules.CidMonitor/FrmMain.cs
C#
gpl3
467
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Samba.Modules.CidMonitor")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Samba.Modules.CidMonitor")] [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("a65f872f-d50a-4f8e-93ef-0e7ef641866b")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
zzgaminginc-pointofssale
Samba.Modules.CidMonitor/Properties/AssemblyInfo.cs
C#
gpl3
1,478
using System; using System.Linq; using Axcidv5callerid; using Microsoft.Practices.Prism.MefExtensions.Modularity; using Samba.Domain.Models.Customers; using Samba.Localization.Properties; using Samba.Persistance.Data; using Samba.Presentation.Common; using Samba.Presentation.Common.Services; namespace Samba.Modules.CidMonitor { [ModuleExport(typeof(CidMonitor))] public class CidMonitor : ModuleBase { public CidMonitor() { try { var frmMain = new FrmMain(); frmMain.axCIDv51.OnCallerID += axCIDv51_OnCallerID; frmMain.axCIDv51.Start(); } catch (Exception) { #if DEBUG var i = 0; #else InteractionService.UserIntraction.DisplayPopup(Resources.Information, Resources.CallerIdDriverError, "", ""); #endif } } static void axCIDv51_OnCallerID(object sender, ICIDv5Events_OnCallerIDEvent e) { var pn = e.phoneNumber; pn = pn.TrimStart('+'); pn = pn.TrimStart('0'); pn = pn.TrimStart('9'); pn = pn.TrimStart('0'); var c = Dao.Query<Customer>(x => x.PhoneNumber == pn); if (c.Count() == 0) c = Dao.Query<Customer>(x => x.PhoneNumber.Contains(pn)); if (c.Count() == 1) { var customer = c.First(); InteractionService.UserIntraction.DisplayPopup(customer.Name, customer.Name + " " + Resources.Calling + ".\r" + customer.PhoneNumber + "\r" + customer.Address + "\r" + customer.Note, customer.PhoneNumber, "SelectCustomer"); } else InteractionService.UserIntraction.DisplayPopup(e.phoneNumber, e.phoneNumber + " " + Resources.Calling + "...", e.phoneNumber, "SelectCustomer"); } } }
zzgaminginc-pointofssale
Samba.Modules.CidMonitor/CidMonitor.cs
C#
gpl3
2,070
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Samba.Domain.Tests")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Samba.Domain.Tests")] [assembly: AssemblyCopyright("Copyright © 2010")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("64171b30-c017-43af-a8e0-4e0f7d38546d")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
zzgaminginc-pointofssale
Samba.Domain.Tests/Properties/AssemblyInfo.cs
C#
gpl3
1,407
using System; using Samba.Domain.Models.Settings; namespace Samba.Domain { public class SettingGetter { private readonly ProgramSetting _programSetting; public SettingGetter(ProgramSetting programSetting) { _programSetting = programSetting; } public string SettingName { get { return _programSetting.Name; } } public string StringValue { get { return _programSetting.Value; } set { _programSetting.Value = value; } } public DateTime DateTimeValue { get { DateTime result; DateTime.TryParse(_programSetting.Value, out result); return result; } set { _programSetting.Value = value.ToString(); } } public int IntegerValue { get { int result; int.TryParse(_programSetting.Value, out result); return result; } set { _programSetting.Value = value.ToString(); } } public decimal DecimalValue { get { decimal result; decimal.TryParse(_programSetting.Value, out result); return result; } set { _programSetting.Value = value.ToString(); } } public bool BoolValue { get { bool result; bool.TryParse(_programSetting.Value, out result); return result; } set { _programSetting.Value = value.ToString(); } } private static SettingGetter _nullSetting; public static SettingGetter NullSetting { get { return _nullSetting ?? (_nullSetting = new SettingGetter(new ProgramSetting())); } } } }
zzgaminginc-pointofssale
Samba.Domain/SettingGetter.cs
C#
gpl3
1,950
namespace Samba.Domain { public enum TransactionType { Income, Expense, Liability, Receivable } }
zzgaminginc-pointofssale
Samba.Domain/TransactionType.cs
C#
gpl3
153
using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Users { public class User : IEntity { public User() { } public User(string name, string pinCode) { Name = name; PinCode = pinCode; _userRole = UserRole.Empty; } public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public string PinCode { get; set; } private UserRole _userRole; public virtual UserRole UserRole { get { return _userRole; } set { _userRole = value; } } private static readonly User _nobody = new User("*", ""); public static User Nobody { get { return _nobody; } } public string UserString { get { return Name; } } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Users/User.cs
C#
gpl3
933
 namespace Samba.Domain.Models.Users { public enum LoginStatus { CanLogin, PinNotFound, Suspended } }
zzgaminginc-pointofssale
Samba.Domain/Models/Users/LoginStatus.cs
C#
gpl3
151
using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Users { public enum PermissionValue { Enabled, Disabled, Invisible } public class Permission : IEntity { public int Id { get; set; } public string Name { get; set; } public int Value { get; set; } public int UserRoleId { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Users/Permission.cs
C#
gpl3
404
using System.Collections.Generic; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Users { public class UserRole : IEntity { public UserRole() { Permissions = new List<Permission>(); } public UserRole(string name) : this() { Name = name; } public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public bool IsAdmin { get; set; } public int DepartmentId { get; set; } public virtual IList<Permission> Permissions { get; set; } public string UserString { get { return Name; } } private static readonly UserRole EmptyUserRole = new UserRole { Id = 0, Name = "Default UserRole" }; public static UserRole Empty { get { return EmptyUserRole; } } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Users/UserRole.cs
C#
gpl3
945
using System.ComponentModel.DataAnnotations; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Inventory { public class InventoryItem : IEntity { public int Id { get; set; } public string Name { get; set; } public string GroupCode { get; set; } [StringLength(10)] public string BaseUnit { get; set; } [StringLength(10)] public string TransactionUnit { get; set; } public int TransactionUnitMultiplier { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Inventory/InventoryItem.cs
C#
gpl3
531
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Samba.Domain.Models.Menus; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Inventory { public class CostItem : IEntity { public int Id { get; set; } public string Name { get; set; } public int PeriodicConsumptionId { get; set; } public virtual MenuItemPortion Portion { get; set; } public decimal Quantity { get; set; } public decimal CostPrediction { get; set; } public decimal Cost { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Inventory/CostItem.cs
C#
gpl3
601
using System.Collections.Generic; using Samba.Domain.Models.Menus; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Inventory { public class Recipe : IEntity { public int Id { get; set; } public string Name { get; set; } public virtual MenuItemPortion Portion { get; set; } public virtual IList<RecipeItem> RecipeItems { get; set; } public decimal FixedCost { get; set; } public Recipe() { RecipeItems = new List<RecipeItem>(); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Inventory/Recipe.cs
C#
gpl3
561
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Inventory { public class Transaction : IEntity { public int Id { get; set; } public string Name { get; set; } public DateTime Date { get; set; } public virtual IList<TransactionItem> TransactionItems { get; set; } public Transaction() { TransactionItems = new List<TransactionItem>(); Date = DateTime.Now; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Inventory/Transaction.cs
C#
gpl3
580
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Samba.Domain.Models.Inventory { public class TransactionItem { public int Id { get; set; } public int TransactionId { get; set; } public virtual InventoryItem InventoryItem { get; set; } public string Unit { get; set; } public int Multiplier { get; set; } public decimal Quantity { get; set; } public decimal Price { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Inventory/TransactionItem.cs
C#
gpl3
519
namespace Samba.Domain.Models.Inventory { public class RecipeItem { public int Id { get; set; } public int RecipeId { get; set; } public virtual InventoryItem InventoryItem { get; set; } public decimal Quantity { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Inventory/RecipeItem.cs
C#
gpl3
286
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Samba.Domain.Models.Inventory { public class PeriodicConsumptionItem { public int Id { get; set; } public int PeriodicConsumptionId { get; set; } public virtual InventoryItem InventoryItem { get; set; } public decimal UnitMultiplier { get; set; } public decimal InStock { get; set; } public decimal Purchase { get; set; } public decimal Consumption { get; set; } public decimal? PhysicalInventory { get; set; } public decimal Cost { get; set; } public decimal GetInventoryPrediction() { return (InStock + Purchase) - GetPredictedConsumption(); } public decimal GetPhysicalInventory() { return (InStock + Purchase) - GetConsumption(); } public decimal GetPredictedConsumption() { return Consumption; } public decimal GetConsumption() { if (PhysicalInventory == null) return GetPredictedConsumption(); return (InStock + Purchase) - PhysicalInventory.GetValueOrDefault(0); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Inventory/PeriodicConsumptionItem.cs
C#
gpl3
1,261
using System; using System.Collections.Generic; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Inventory { public class PeriodicConsumption : IEntity { public int Id { get; set; } public string Name { get; set; } public int WorkPeriodId { get; set; } public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } public virtual IList<PeriodicConsumptionItem> PeriodicConsumptionItems { get; set; } public virtual IList<CostItem> CostItems { get; set; } public PeriodicConsumption() { PeriodicConsumptionItems = new List<PeriodicConsumptionItem>(); CostItems = new List<CostItem>(); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Inventory/PeriodicConsumption.cs
C#
gpl3
764
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Samba.Domain.Models.Tickets { public class TaxService { public int Id { get; set; } public int TicketId { get; set; } public int TaxServiceId { get; set; } public int TaxServiceType { get; set; } public int CalculationType { get; set; } public decimal Amount { get; set; } public decimal CalculationAmount { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/TaxService.cs
C#
gpl3
510
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Diagnostics; using System.Linq; using Samba.Domain.Models.Customers; using Samba.Domain.Models.Menus; using Samba.Infrastructure.Data; using Samba.Infrastructure.Data.Serializer; using Samba.Infrastructure.Settings; namespace Samba.Domain.Models.Tickets { public class Ticket : IEntity { public Ticket() : this(0, "") { } public Ticket(int ticketId) : this(ticketId, "") { } public Ticket(int ticketId, string locationName) { Id = ticketId; Date = DateTime.Now; LastPaymentDate = DateTime.Now; LastOrderDate = DateTime.Now; LocationName = locationName; PrintJobData = ""; _removedTicketItems = new List<TicketItem>(); _removedTaxServices = new List<TaxService>(); _ticketItems = new List<TicketItem>(); _payments = new List<Payment>(); _discounts = new List<Discount>(); _paidItems = new List<PaidItem>(); _taxServices = new List<TaxService>(); } private bool _shouldLock; private Dictionary<int, int> _printCounts; private Dictionary<string, string> _tagValues; private readonly List<TicketItem> _removedTicketItems; private readonly List<TaxService> _removedTaxServices; private Dictionary<int, decimal> _paidItemsCache = new Dictionary<int, decimal>(); public int Id { get; set; } public string Name { get; set; } public int DepartmentId { get; set; } public DateTime LastUpdateTime { get; set; } public string TicketNumber { get; set; } public string PrintJobData { get; set; } public DateTime Date { get; set; } public DateTime LastOrderDate { get; set; } public DateTime LastPaymentDate { get; set; } public string LocationName { get; set; } public int CustomerId { get; set; } public string CustomerName { get; set; } public string CustomerGroupCode { get; set; } public bool IsPaid { get; set; } public decimal RemainingAmount { get; set; } public decimal TotalAmount { get; set; } public string Note { get; set; } public bool Locked { get; set; } [StringLength(500)] public string Tag { get; set; } private IList<TicketItem> _ticketItems; public virtual IList<TicketItem> TicketItems { get { return _ticketItems; } set { _ticketItems = value; } } private IList<Payment> _payments; public virtual IList<Payment> Payments { get { return _payments; } set { _payments = value; } } private IList<Discount> _discounts; public virtual IList<Discount> Discounts { get { return _discounts; } set { _discounts = value; } } private IList<TaxService> _taxServices; public virtual IList<TaxService> TaxServices { get { return _taxServices; } set { _taxServices = value; } } private IList<PaidItem> _paidItems; public virtual IList<PaidItem> PaidItems { get { return _paidItems; } set { _paidItems = value; } } public TicketItem AddTicketItem(int userId, MenuItem menuItem, string portionName) { // Only for tests return AddTicketItem(userId, 0, menuItem, portionName, "", ""); } public TicketItem AddTicketItem(int userId, int departmentId, MenuItem menuItem, string portionName, string priceTag, string defaultProperties) { Locked = false; var tif = new TicketItem { DepartmentId = departmentId }; tif.UpdateMenuItem(userId, menuItem, portionName, priceTag, 1, defaultProperties); TicketItems.Add(tif); return tif; } public Payment AddPayment(DateTime date, decimal amount, PaymentType paymentType, int userId, int departmentId) { var result = new Payment { Amount = amount, Date = date, PaymentType = (int)paymentType, UserId = userId, DepartmentId = departmentId }; DepartmentId = departmentId; Payments.Add(result); LastPaymentDate = DateTime.Now; RemainingAmount = GetRemainingAmount(); if (RemainingAmount == 0) { PaidItems.Clear(); } return result; } public void RemoveTicketItem(TicketItem ti) { TicketItems.Remove(ti); if (ti.Id > 0) _removedTicketItems.Add(ti); } public IEnumerable<TicketItem> PopRemovedTicketItems() { var result = _removedTicketItems.ToArray(); _removedTicketItems.Clear(); return result; } public IEnumerable<TaxService> PopRemovedTaxServices() { var result = _removedTaxServices.ToArray(); _removedTaxServices.Clear(); return result; } public int GetItemCount() { return TicketItems.Count(); } public decimal GetSumWithoutTax() { var sum = GetPlainSum(); sum -= GetDiscountAndRoundingTotal(); return sum; } public decimal GetSum() { var plainSum = GetPlainSum(); var discount = CalculateDiscounts(Discounts.Where(x => x.DiscountType == (int)DiscountType.Percent), plainSum); var tax = CalculateTax(plainSum, discount); var services = CalculateServices(TaxServices, plainSum - discount, tax); return (plainSum - discount + services + tax) - Discounts.Where(x => x.DiscountType != (int)DiscountType.Percent).Sum(x => x.Amount); } public decimal CalculateTax() { return CalculateTax(GetPlainSum(), GetDiscountTotal()); } private decimal CalculateTax(decimal plainSum, decimal discount) { var result = TicketItems.Where(x => !x.VatIncluded && !x.Gifted && !x.Voided).Sum(x => (x.VatAmount + x.Properties.Sum(y => y.VatAmount)) * x.Quantity); if (discount > 0) result -= (result * discount) / plainSum; return result; } public decimal GetDiscountAndRoundingTotal() { decimal sum = GetPlainSum(); return CalculateDiscounts(Discounts, sum); } public decimal GetDiscountTotal() { decimal sum = GetPlainSum(); return CalculateDiscounts(Discounts.Where(x => x.DiscountType == (int)DiscountType.Percent), sum); } public decimal GetRoundingTotal() { return CalculateDiscounts(Discounts.Where(x => x.DiscountType != (int)DiscountType.Percent), 0); } public decimal GetTaxServicesTotal() { var plainSum = GetPlainSum(); var discount = GetDiscountTotal(); var tax = CalculateTax(plainSum, discount); return CalculateServices(TaxServices, plainSum - discount, tax); } private static decimal CalculateServices(IEnumerable<TaxService> taxServices, decimal sum, decimal tax) { decimal totalAmount = 0; var currentSum = sum; foreach (var taxService in taxServices) { if (taxService.CalculationType == 0) { taxService.CalculationAmount = taxService.Amount > 0 ? (sum * taxService.Amount) / 100 : 0; } else if (taxService.CalculationType == 1) { taxService.CalculationAmount = taxService.Amount > 0 ? ((sum + tax) * taxService.Amount) / 100 : 0; } else if (taxService.CalculationType == 2) { taxService.CalculationAmount = taxService.Amount > 0 ? (currentSum * taxService.Amount) / 100 : 0; } else taxService.CalculationAmount = taxService.Amount; taxService.CalculationAmount = Decimal.Round(taxService.CalculationAmount, LocalSettings.Decimals); totalAmount += taxService.CalculationAmount; currentSum += taxService.CalculationAmount; } return decimal.Round(totalAmount, LocalSettings.Decimals); } private decimal CalculateDiscounts(IEnumerable<Discount> discounts, decimal sum) { decimal totalDiscount = 0; foreach (var discount in discounts) { if (discount.DiscountType == (int)DiscountType.Percent) { if (discount.TicketItemId == 0) discount.DiscountAmount = discount.Amount > 0 ? (sum * discount.Amount) / 100 : 0; else { var d = discount; discount.DiscountAmount = discount.Amount > 0 ? (TicketItems.Single(x => x.Id == d.TicketItemId).GetTotal() * discount.Amount) / 100 : 0; } } else discount.DiscountAmount = discount.Amount; discount.DiscountAmount = Decimal.Round(discount.DiscountAmount, LocalSettings.Decimals); totalDiscount += discount.DiscountAmount; } return decimal.Round(totalDiscount, LocalSettings.Decimals); } public void AddTicketDiscount(DiscountType type, decimal amount, int userId) { var c = Discounts.SingleOrDefault(x => x.DiscountType == (int)type); if (c == null) { c = new Discount { DiscountType = (int)type, Amount = amount }; Discounts.Add(c); } if (amount == 0) Discounts.Remove(c); c.UserId = userId; c.Amount = amount; } public void AddTaxService(int taxServiceId, int calculationMethod, decimal amount) { var t = TaxServices.SingleOrDefault(x => x.TaxServiceId == taxServiceId); if (t == null) { t = new TaxService { Amount = amount, CalculationType = calculationMethod, TaxServiceId = taxServiceId }; TaxServices.Add(t); } if (amount == 0) { if (t.Id > 0) _removedTaxServices.Add(t); TaxServices.Remove(t); } t.Amount = amount; } public decimal GetPlainSum() { return TicketItems.Sum(item => item.GetTotal()); } public decimal GetTotalGiftAmount() { return TicketItems.Where(x => x.Gifted && !x.Voided).Sum(item => item.GetItemValue()); } public decimal GetPaymentAmount() { return Payments.Sum(item => item.Amount); } public decimal GetRemainingAmount() { var sum = GetSum(); var payment = GetPaymentAmount(); return decimal.Round(sum - payment, LocalSettings.Decimals); } public decimal GetAccountPaymentAmount() { return Payments.Where(x => x.PaymentType != (int)PaymentType.Account).Sum(x => x.Amount); } public decimal GetAccountRemainingAmount() { return Payments.Where(x => x.PaymentType == (int)PaymentType.Account).Sum(x => x.Amount); } public string UserString { get { return Name; } } public bool CanSubmit { get { return !IsPaid; } } public void VoidItem(TicketItem item, int reasonId, int userId) { Locked = false; if (item.Locked && !item.Voided && !item.Gifted) { item.Voided = true; item.ModifiedUserId = userId; item.ModifiedDateTime = DateTime.Now; item.ReasonId = reasonId; item.Locked = false; } else if (item.Voided && !item.Locked) { item.ReasonId = 0; item.Voided = false; item.Locked = true; } else if (item.Gifted) { item.ReasonId = 0; item.Gifted = false; if (!item.Locked) RemoveTicketItem(item); } else if (!item.Locked) RemoveTicketItem(item); } public void CancelItem(TicketItem item) { Locked = false; if (item.Voided && !item.Locked) { item.ReasonId = 0; item.Voided = false; item.Locked = true; } else if (item.Gifted && !item.Locked) { item.ReasonId = 0; item.Gifted = false; item.Locked = true; } else if (!item.Locked) RemoveTicketItem(item); } public void GiftItem(TicketItem item, int reasonId, int userId) { Locked = false; item.Gifted = true; item.ModifiedUserId = userId; item.ModifiedDateTime = DateTime.Now; item.ReasonId = reasonId; } public bool CanRemoveSelectedItems(IEnumerable<TicketItem> items) { return (items.Sum(x => x.GetSelectedValue()) <= GetRemainingAmount()); } public bool CanVoidSelectedItems(IEnumerable<TicketItem> items) { if (!CanRemoveSelectedItems(items)) return false; foreach (var item in items) { if (!TicketItems.Contains(item)) return false; if (item.Voided) return false; if (item.Gifted) return false; if (!item.Locked) return false; } return true; } public bool CanGiftSelectedItems(IEnumerable<TicketItem> items) { if (!CanRemoveSelectedItems(items)) return false; foreach (var item in items) { if (!TicketItems.Contains(item)) return false; if (item.Voided) return false; if (item.Gifted) return false; } return true; } public bool CanCancelSelectedItems(IEnumerable<TicketItem> items) { if (items.Count() == 0) return false; foreach (var item in items) { if (!TicketItems.Contains(item)) return false; if (item.Locked && !item.Gifted) return false; } return true; } public IEnumerable<TicketItem> GetUnlockedLines() { return TicketItems.Where(x => !x.Locked).OrderBy(x => x.CreatedDateTime).ToList(); } public void MergeLinesAndUpdateOrderNumbers(int orderNumber) { LastOrderDate = DateTime.Now; IList<TicketItem> newLines = TicketItems.Where(x => !x.Locked && x.Id == 0).ToList(); //sadece quantity = 1 olan satırlar birleştirilecek. var mergedLines = newLines.Where(x => x.Quantity != 1).ToList(); var ids = mergedLines.Select(x => x.MenuItemId).Distinct().ToArray(); mergedLines.AddRange(newLines.Where(x => ids.Contains(x.MenuItemId) && x.Quantity == 1)); foreach (var ticketItem in newLines.Where(x => x.Quantity == 1 && !ids.Contains(x.MenuItemId))) { var ti = ticketItem; if (ticketItem.Properties.Count > 0) { mergedLines.Add(ticketItem); continue; } var item = mergedLines.SingleOrDefault( x => x.Properties.Count == 0 && x.MenuItemId == ti.MenuItemId && x.PortionName == ti.PortionName && x.Gifted == ti.Gifted && x.Price == ti.Price && x.Tag == ti.Tag); if (item == null) mergedLines.Add(ticketItem); else item.Quantity += ticketItem.Quantity; } foreach (var ticketItem in newLines.Where(ticketItem => !mergedLines.Contains(ticketItem))) { RemoveTicketItem(ticketItem); } foreach (var item in TicketItems.Where(x => !x.Locked).Where(item => item.OrderNumber == 0)) { item.OrderNumber = orderNumber; } } public void RequestLock() { _shouldLock = true; } public void LockTicket() { foreach (var item in TicketItems.Where(x => !x.Locked)) { item.Locked = true; } if (_shouldLock) Locked = true; _shouldLock = false; } public static Ticket Create(Department department) { var ticket = new Ticket { DepartmentId = department.Id }; foreach (var taxServiceTemplate in department.TaxServiceTemplates) { ticket.AddTaxService(taxServiceTemplate.Id, taxServiceTemplate.CalculationMethod, taxServiceTemplate.Amount); } return ticket; } public TicketItem CloneItem(TicketItem item) { Debug.Assert(_ticketItems.Contains(item)); var result = ObjectCloner.Clone(item); result.Quantity = 0; _ticketItems.Add(result); return result; } public bool DidPrintJobExecuted(int printerId) { return GetPrintCount(printerId) > 0; } public void AddPrintJob(int printerId) { if (_printCounts == null) _printCounts = CreatePrintCounts(PrintJobData); if (!_printCounts.ContainsKey(printerId)) _printCounts.Add(printerId, 0); _printCounts[printerId]++; PrintJobData = string.Join("#", _printCounts.Select(x => string.Format("{0}:{1}", x.Key, x.Value))); } public int GetPrintCount(int id) { if (_printCounts == null) _printCounts = CreatePrintCounts(PrintJobData); return _printCounts.ContainsKey(id) ? _printCounts[id] : 0; } private static Dictionary<int, int> CreatePrintCounts(string pJobData) { try { return pJobData .Split('#') .Where(x => !string.IsNullOrEmpty(x)) .Select(item => item.Split(':').Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x)).ToArray()) .ToDictionary(d => d[0], d => d[1]); } catch (Exception) { return new Dictionary<int, int>(); } } private static Dictionary<string, string> CreateTagValues(string tagData) { try { return tagData .Split('\r') .Where(x => !string.IsNullOrEmpty(x)) .Select(item => item.Split(':').Where(x => !string.IsNullOrEmpty(x)).ToArray()) .ToDictionary(d => d[0], d => d[1]); } catch (Exception) { return new Dictionary<string, string>(); } } public string GetTagValue(string tagName) { if (string.IsNullOrEmpty(Tag)) return ""; if (_tagValues == null) _tagValues = CreateTagValues(Tag); return _tagValues.ContainsKey(tagName) ? _tagValues[tagName] : ""; } public void SetTagValue(string tagName, string tagValue) { if (_tagValues == null) _tagValues = CreateTagValues(Tag); if (!_tagValues.ContainsKey(tagName)) _tagValues.Add(tagName, tagValue); else _tagValues[tagName] = tagValue; if (string.IsNullOrEmpty(tagValue)) _tagValues.Remove(tagName); Tag = string.Join("\r", _tagValues.Select(x => string.Format("{0}:{1}", x.Key, x.Value))); if (!string.IsNullOrEmpty(Tag)) Tag += "\r"; } public string GetTagData() { if (string.IsNullOrEmpty(Tag)) return ""; if (_tagValues == null) _tagValues = CreateTagValues(Tag); return string.Join("\r", _tagValues.Where(x => !string.IsNullOrEmpty(x.Value)).Select(x => string.Format("{0}: {1}", x.Key, x.Value))); } public void UpdateCustomer(Customer customer) { if (customer == Customer.Null) { CustomerId = 0; CustomerName = ""; CustomerGroupCode = ""; } else { CustomerId = customer.Id; CustomerName = customer.Name.Trim(); CustomerGroupCode = (customer.GroupCode ?? "").Trim(); } } public void Recalculate(decimal autoRoundValue, int userId) { if (autoRoundValue != 0) { AddTicketDiscount(DiscountType.Auto, 0, userId); var ramount = GetRemainingAmount(); if (ramount > 0) { decimal damount; if (autoRoundValue > 0) damount = decimal.Round(ramount / autoRoundValue, MidpointRounding.AwayFromZero) * autoRoundValue; else // eğer yuvarlama eksi olarak verildiyse hep aşağı yuvarlar damount = Math.Truncate(ramount / autoRoundValue) * autoRoundValue; AddTicketDiscount(DiscountType.Auto, ramount - damount, userId); } else if (ramount < 0) { AddTicketDiscount(DiscountType.Auto, ramount, userId); } } RemainingAmount = GetRemainingAmount(); TotalAmount = GetSum(); } public IEnumerable<TicketItem> ExtractSelectedTicketItems(IEnumerable<TicketItem> selectedItems) { var newItems = new List<TicketItem>(); foreach (var selectedTicketItem in selectedItems) { Debug.Assert(selectedTicketItem.SelectedQuantity > 0); Debug.Assert(TicketItems.Contains(selectedTicketItem)); if (selectedTicketItem.SelectedQuantity >= selectedTicketItem.Quantity) continue; var newItem = CloneItem(selectedTicketItem); newItem.Quantity = selectedTicketItem.SelectedQuantity; selectedTicketItem.Quantity -= selectedTicketItem.SelectedQuantity; newItems.Add(newItem); } return newItems; } public void UpdateVat(VatTemplate vatTemplate) { foreach (var ticketItem in TicketItems) { ticketItem.VatRate = vatTemplate.Rate; ticketItem.VatTemplateId = vatTemplate.Id; ticketItem.VatIncluded = vatTemplate.VatIncluded; ticketItem.UpdatePrice(ticketItem.Price, ticketItem.PriceTag); } } public void CancelPaidItems() { _paidItemsCache.Clear(); } public void UpdatePaidItems(int menuItemId) { if (!_paidItemsCache.ContainsKey(menuItemId)) _paidItemsCache.Add(menuItemId, 0); _paidItemsCache[menuItemId]++; } public decimal GetPaidItemQuantity(int menuItemId) { return _paidItemsCache.ContainsKey(menuItemId) ? _paidItemsCache[menuItemId] : 0; } public int[] GetPaidItems() { return _paidItemsCache.Keys.ToArray(); } public void CopyPaidItemsCache(Ticket ticket) { _paidItemsCache = new Dictionary<int, decimal>(ticket._paidItemsCache); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/Ticket.cs
C#
gpl3
25,489
using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Tickets { public class Reason : IEntity { public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public int ReasonType { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/Reason.cs
C#
gpl3
309
using Samba.Domain.Foundation; namespace Samba.Domain.Models.Tickets { public class TicketItemProperty { public int Id { get; set; } public string Name { get; set; } public int TicketItemId { get; set; } public Price PropertyPrice { get; set; } public decimal VatAmount { get; set; } public decimal Quantity { get; set; } public int PropertyGroupId { get; set; } public int MenuItemId { get; set; } public bool CalculateWithParentPrice { get; set; } public string PortionName { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/TicketItemProperty.cs
C#
gpl3
608
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Samba.Domain.Models.Settings; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Tickets { public class TicketTagGroup : IEntity, IOrderable { public int Id { get; set; } public string Name { get; set; } public int Order { get; set; } public virtual Numerator Numerator { get; set; } private IList<TicketTag> _ticketTags; public int Action { get; set; } public bool FreeTagging { get; set; } public bool SaveFreeTags { get; set; } public bool ExcludeInReports { get; set; } public string ButtonColorWhenTagSelected { get; set; } public string ButtonColorWhenNoTagSelected { get; set; } public bool ActiveOnPosClient { get; set; } public bool ActiveOnTerminalClient { get; set; } public bool ForceValue { get; set; } public bool NumericTags { get; set; } public bool PriceTags { get; set; } public string UserString { get { return Name; } } public virtual IList<TicketTag> TicketTags { get { return _ticketTags; } set { _ticketTags = value; } } public TicketTagGroup() { _ticketTags = new List<TicketTag>(); ButtonColorWhenNoTagSelected = "Gainsboro"; ButtonColorWhenTagSelected = "Gainsboro"; ActiveOnPosClient = true; SaveFreeTags = true; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/TicketTagGroup.cs
C#
gpl3
1,618
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Diagnostics; using Samba.Domain.Foundation; using Samba.Domain.Models.Menus; using Samba.Infrastructure.Settings; namespace Samba.Domain.Models.Tickets { public class TicketItem { public TicketItem() { _properties = new List<TicketItemProperty>(); CreatedDateTime = DateTime.Now; ModifiedDateTime = DateTime.Now; _selectedQuantity = 0; } public int Id { get; set; } public int TicketId { get; set; } public int MenuItemId { get; set; } public string MenuItemName { get; set; } public string PortionName { get; set; } public decimal Price { get; set; } public string CurrencyCode { get; set; } public decimal Quantity { get; set; } public int PortionCount { get; set; } public bool Locked { get; set; } public bool Voided { get; set; } public int ReasonId { get; set; } public bool Gifted { get; set; } public int OrderNumber { get; set; } public int CreatingUserId { get; set; } public DateTime CreatedDateTime { get; set; } public int ModifiedUserId { get; set; } public DateTime ModifiedDateTime { get; set; } [StringLength(10)] public string PriceTag { get; set; } public string Tag { get; set; } public int DepartmentId { get; set; } public decimal VatRate { get; set; } public decimal VatAmount { get; set; } public int VatTemplateId { get; set; } public bool VatIncluded { get; set; } private IList<TicketItemProperty> _properties; public virtual IList<TicketItemProperty> Properties { get { return _properties; } set { _properties = value; } } decimal _selectedQuantity; public decimal SelectedQuantity { get { return _selectedQuantity; } } private TicketItemProperty _lastSelectedProperty; public TicketItemProperty LastSelectedProperty { get { return _lastSelectedProperty; } } public void UpdateMenuItem(int userId, MenuItem menuItem, string portionName, string priceTag, int quantity, string defaultProperties) { MenuItemId = menuItem.Id; MenuItemName = menuItem.Name; var portion = menuItem.GetPortion(portionName); Debug.Assert(portion != null); UpdatePortion(portion, priceTag, menuItem.VatTemplate); Quantity = quantity; _selectedQuantity = quantity; PortionCount = menuItem.Portions.Count; CreatingUserId = userId; CreatedDateTime = DateTime.Now; if (!string.IsNullOrEmpty(defaultProperties)) { foreach (var menuItemPropertyGroup in menuItem.PropertyGroups) { var properties = defaultProperties.Split(','); foreach (var defaultProperty in properties) { var property = defaultProperty.Trim(); var pQuantity = 1; if (defaultProperty.Contains("*")) { var parts = defaultProperty.Split(new[] { '*' }, 1); if (!string.IsNullOrEmpty(parts[0].Trim())) { property = parts[0]; int.TryParse(parts[1], out pQuantity); } else continue; } var defaultValue = menuItemPropertyGroup.Properties.FirstOrDefault(x => x.Name == property); if (defaultValue != null) { for (int i = 0; i < pQuantity; i++) { ToggleProperty(menuItemPropertyGroup, defaultValue); } } } } } } public void UpdatePortion(MenuItemPortion portion, string priceTag, VatTemplate vatTemplate) { PortionName = portion.Name; if (vatTemplate != null) { VatRate = vatTemplate.Rate; VatIncluded = vatTemplate.VatIncluded; VatTemplateId = vatTemplate.Id; } if (!string.IsNullOrEmpty(priceTag)) { string tag = priceTag; var price = portion.Prices.SingleOrDefault(x => x.PriceTag == tag); if (price != null && price.Price > 0) { UpdatePrice(price.Price, price.PriceTag); } else priceTag = ""; } if (string.IsNullOrEmpty(priceTag)) { UpdatePrice(portion.Price.Amount, ""); } CurrencyCode = LocalSettings.CurrencySymbol; foreach (var ticketItemProperty in Properties) { ticketItemProperty.PortionName = portion.Name; } } public TicketItemProperty ToggleProperty(MenuItemPropertyGroup group, MenuItemProperty property) { if (property.Name.ToLower() == "x") { var groupItems = Properties.Where(x => x.PropertyGroupId == group.Id).ToList(); foreach (var tip in groupItems) Properties.Remove(tip); if (group.MultipleSelection) Quantity = 1; return null; } var ti = FindProperty(property); if (ti == null) { ti = new TicketItemProperty { Name = property.Name, PropertyPrice = new Price { Amount = property.Price.Amount, CurrencyCode = property.Price.CurrencyCode }, PropertyGroupId = group.Id, MenuItemId = property.MenuItemId, CalculateWithParentPrice = group.CalculateWithParentPrice, PortionName = PortionName, Quantity = group.MultipleSelection ? 0 : 1 }; if (VatIncluded && VatRate > 0) { ti.PropertyPrice.Amount = ti.PropertyPrice.Amount / ((100 + VatRate) / 100); ti.PropertyPrice.Amount = decimal.Round(ti.PropertyPrice.Amount, 2); ti.VatAmount = property.Price.Amount - ti.PropertyPrice.Amount; } else if (VatRate > 0) ti.VatAmount = (property.Price.Amount * VatRate) / 100; else ti.VatAmount = 0; } if (group.SingleSelection || !string.IsNullOrEmpty(group.GroupTag)) { var tip = Properties.FirstOrDefault(x => x.PropertyGroupId == group.Id); if (tip != null) { Properties.Insert(Properties.IndexOf(tip), ti); Properties.Remove(tip); } } else if (group.MultipleSelection) { ti.Quantity++; } else if (!group.MultipleSelection && Properties.Contains(ti)) { Properties.Remove(ti); _lastSelectedProperty = ti; return ti; } if (!Properties.Contains(ti)) Properties.Add(ti); _lastSelectedProperty = ti; return ti; } public TicketItemProperty GetCustomProperty() { return Properties.FirstOrDefault(x => x.PropertyGroupId == 0); } public TicketItemProperty GetOrCreateCustomProperty() { var tip = GetCustomProperty(); if (tip == null) { tip = new TicketItemProperty { Name = "", PropertyPrice = new Price(0, LocalSettings.CurrencySymbol), PropertyGroupId = 0, MenuItemId = 0, Quantity = 0 }; Properties.Add(tip); } return tip; } public void UpdateCustomProperty(string text, decimal price, decimal quantity) { var tip = GetOrCreateCustomProperty(); if (string.IsNullOrEmpty(text)) { Properties.Remove(tip); } else { tip.Name = text; tip.PropertyPrice = new Price(price, LocalSettings.CurrencySymbol); if (VatIncluded && VatRate > 0) { tip.PropertyPrice.Amount = tip.PropertyPrice.Amount / ((100 + VatRate) / 100); tip.PropertyPrice.Amount = decimal.Round(tip.PropertyPrice.Amount, 2); tip.VatAmount = price - tip.PropertyPrice.Amount; } else if (VatRate > 0) tip.VatAmount = (price * VatRate) / 100; else VatAmount = 0; tip.Quantity = quantity; } } private TicketItemProperty FindProperty(MenuItemProperty property) { return Properties.FirstOrDefault(x => x.Name == property.Name && (x.PropertyPrice.Amount + x.VatAmount) == property.Price.Amount); } public decimal GetTotal() { return Voided || Gifted ? 0 : GetItemValue(); } public decimal GetItemValue() { return Quantity * GetItemPrice(); } public decimal GetSelectedValue() { return SelectedQuantity > 0 ? SelectedQuantity * GetItemPrice() : GetItemValue(); } public decimal GetItemPrice() { var result = Price + GetTotalPropertyPrice(); if (VatIncluded) result += VatAmount; return result; } public decimal GetMenuItemPrice() { var result = Price + GetMenuItemPropertyPrice(); if (VatIncluded) result += VatAmount; return result; } public decimal GetTotalPropertyPrice() { return GetPropertySum(Properties, VatIncluded); } public decimal GetPropertyPrice() { return GetPropertySum(Properties.Where(x => !x.CalculateWithParentPrice), VatIncluded); } public decimal GetMenuItemPropertyPrice() { return GetPropertySum(Properties.Where(x => x.CalculateWithParentPrice), VatIncluded); } private static decimal GetPropertySum(IEnumerable<TicketItemProperty> properties, bool vatIncluded) { return properties.Sum(property => (property.PropertyPrice.Amount + (vatIncluded ? property.VatAmount : 0)) * property.Quantity); } public void IncSelectedQuantity() { _selectedQuantity++; if (_selectedQuantity > Quantity) _selectedQuantity = 1; } public void DecSelectedQuantity() { _selectedQuantity--; if (_selectedQuantity < 1) _selectedQuantity = 1; } public void ResetSelectedQuantity() { _selectedQuantity = Quantity; } public void UpdateSelectedQuantity(decimal value) { _selectedQuantity = value; if (_selectedQuantity > Quantity) _selectedQuantity = 1; if (_selectedQuantity < 1) _selectedQuantity = 1; } public string GetPortionDesc() { if (PortionCount > 1 && !string.IsNullOrEmpty(PortionName) && !string.IsNullOrEmpty(PortionName.Trim('\b', ' ', '\t')) && PortionName.ToLower() != "normal") return "." + PortionName; return ""; } public void UpdatePrice(decimal value, string priceTag) { Price = value; PriceTag = priceTag; if (VatIncluded && VatRate > 0) { Price = Price / ((100 + VatRate) / 100); Price = decimal.Round(Price, 2); VatAmount = value - Price; } else if (VatRate > 0) VatAmount = (Price * VatRate) / 100; else VatAmount = 0; } public decimal GetTotalVatAmount() { return !Voided && !Gifted ? (VatAmount + Properties.Sum(x => x.VatAmount)) * Quantity : 0; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/TicketItem.cs
C#
gpl3
13,300
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Samba.Domain.Models.Menus; using Samba.Domain.Models.Settings; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Tickets { public class Department : IEntity { public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public string UserString { get { return Name; } } public int ScreenMenuId { get; set; } public int TerminalScreenMenuId { get; set; } public virtual Numerator TicketNumerator { get; set; } public virtual Numerator OrderNumerator { get; set; } public bool IsFastFood { get; set; } public bool IsAlaCarte { get; set; } public bool IsTakeAway { get; set; } public int TableScreenId { get; set; } public int TerminalTableScreenId { get; set; } public int OpenTicketViewColumnCount { get; set; } public string DefaultTag { get; set; } public string TerminalDefaultTag { get; set; } [StringLength(10)] public string PriceTag { get; set; } private IList<TicketTagGroup> _ticketTagGroups; public virtual IList<TicketTagGroup> TicketTagGroups { get { return _ticketTagGroups; } set { _ticketTagGroups = value; } } private IList<TaxServiceTemplate> _taxServiceTemplates; public virtual IList<TaxServiceTemplate> TaxServiceTemplates { get { return _taxServiceTemplates; } set { _taxServiceTemplates = value; } } private static readonly Department _all = new Department { Name = "*" }; public static Department All { get { return _all; } } public Department() { OpenTicketViewColumnCount = 5; _ticketTagGroups = new List<TicketTagGroup>(); _taxServiceTemplates = new List<TaxServiceTemplate>(); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/Department.cs
C#
gpl3
2,071
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Samba.Domain.Models.Customers; using Samba.Domain.Models.Settings; using Samba.Infrastructure; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Tickets { public class TicketTag : IEntity, IStringCompareable { public int Id { get; set; } public string Name { get; set; } public int TicketTagGroupId { get; set; } public int AccountId { get; set; } public string AccountName { get; set; } public string Display { get { return !string.IsNullOrEmpty(Name) ? Name : "X"; } } private static TicketTag _emptyTicketTag; public static TicketTag Empty { get { return _emptyTicketTag ?? (_emptyTicketTag = new TicketTag()); } } public string GetStringValue() { return Name; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/TicketTag.cs
C#
gpl3
953
using System; namespace Samba.Domain.Models.Tickets { public class Payment { public Payment() { Date = DateTime.Now; PaymentType = 0; } public int Id { get; set; } public decimal Amount { get; set; } public DateTime Date { get; set; } public int PaymentType { get; set; } public int UserId { get; set; } public int DepartmentId { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/Payment.cs
C#
gpl3
479
namespace Samba.Domain.Models.Tickets { public class PaidItem { public int Id { get; set; } public int MenuItemId { get; set; } public decimal Quantity { get; set; } public decimal Price { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/PaidItem.cs
C#
gpl3
262
namespace Samba.Domain.Models.Tickets { public enum DiscountType { Percent, Amount, Auto } public class Discount { public int Id { get; set; } public int UserId { get; set; } public int TicketItemId { get; set; } public int DiscountType { get; set; } public decimal Amount { get; set; } public decimal DiscountAmount { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tickets/Discount.cs
C#
gpl3
454
using System; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Customers { public class Customer : IEntity { public int Id { get; set; } public string Name { get; set; } public string GroupCode { get; set; } public string PhoneNumber { get; set; } public string Address { get; set; } public string Note { get; set; } public DateTime AccountOpeningDate { get; set; } public bool InternalAccount { get; set; } private static readonly Customer _null = new Customer { Name = "*" }; public static Customer Null { get { return _null; } } public Customer() { AccountOpeningDate = DateTime.Now; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Customers/Customer.cs
C#
gpl3
766
using Samba.Domain.Foundation; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class MenuItemProperty : IOrderable { public int Id { get; set; } public string Name { get; set; } public int Order { get; set; } public string UserString { get { return Name; } } public Price Price { get; set; } public int MenuItemId { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/MenuItemProperty.cs
C#
gpl3
441
using System; using System.Collections.Generic; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class ScreenMenuCategory : IOrderable { public ScreenMenuCategory() { _screenMenuItems = new List<ScreenMenuItem>(); MButtonHeight = 65; ButtonHeight = 65; SubButtonHeight = 65; ColumnCount = 0; WrapText = false; ButtonColor = "Green"; MButtonColor = "Orange"; NumeratorType = 2; PageCount = 1; } public ScreenMenuCategory(string name) : this() { Name = name; } public int Id { get; set; } public string Name { get; set; } public int Order { get; set; } public string UserString { get { return Name; } } public int ScreenMenuId { get; set; } public bool MostUsedItemsCategory { get; set; } private IList<ScreenMenuItem> _screenMenuItems; public virtual IList<ScreenMenuItem> ScreenMenuItems { get { return _screenMenuItems; } set { _screenMenuItems = value; } } public int MenuItemCount { get { return ScreenMenuItems.Count; } } public int ColumnCount { get; set; } public int ButtonHeight { get; set; } public bool WrapText { get; set; } public string ButtonColor { get; set; } public int PageCount { get; set; } public int MButtonHeight { get; set; } public string MButtonColor { get; set; } public int SubButtonHeight { get; set; } public int NumeratorType { get; set; } public string NumeratorValues { get; set; } public string AlphaButtonValues { get; set; } public string ImagePath { get; set; } public bool IsQuickNumeratorVisible { get { return NumeratorType == 1; } } public bool IsNumeratorVisible { get { return NumeratorType == 2; } } public int MaxItems { get; set; } public int SortType { get; set; } public void AddMenuItem(MenuItem menuItem) { var smi = new ScreenMenuItem { MenuItemId = menuItem.Id, Name = menuItem.Name }; ScreenMenuItems.Add(smi); } public int ItemCountPerPage { get { var itemCount = ScreenMenuItems.Count / PageCount; if (ScreenMenuItems.Count % PageCount > 0) itemCount++; return itemCount; } } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/ScreenMenuCategory.cs
C#
gpl3
2,671
using System; using System.Collections.Generic; using Samba.Domain.Foundation; using Samba.Infrastructure.Data; using Samba.Infrastructure.Settings; namespace Samba.Domain.Models.Menus { public class MenuItem : IEntity { public MenuItem() : this(string.Empty) { } public MenuItem(string name) { Name = name; _portions = new List<MenuItemPortion>(); _propertyGroups = new List<MenuItemPropertyGroup>(); } public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public string GroupCode { get; set; } public string Barcode { get; set; } public string Tag { get; set; } public virtual VatTemplate VatTemplate { get; set; } private IList<MenuItemPortion> _portions; public virtual IList<MenuItemPortion> Portions { get { return _portions; } set { _portions = value; } } private IList<MenuItemPropertyGroup> _propertyGroups; public virtual IList<MenuItemPropertyGroup> PropertyGroups { get { return _propertyGroups; } set { _propertyGroups = value; } } private static MenuItem _all; public static MenuItem All { get { return _all ?? (_all = new MenuItem { Name = "*" }); } } public MenuItemPortion AddPortion(string portionName, decimal price, string currencyCode) { var mip = new MenuItemPortion { Name = portionName, Price = new Price(price, currencyCode), MenuItemId = Id }; Portions.Add(mip); return mip; } internal MenuItemPortion GetPortion(string portionName) { foreach (var portion in Portions) { if (portion.Name == portionName) return portion; } if (string.IsNullOrEmpty(portionName) && Portions.Count > 0) return Portions[0]; throw new Exception("Porsiyon Tanımlı Değil."); } public string UserString { get { return string.Format("{0} [{1}]", Name, GroupCode); } } public static MenuItemPortion AddDefaultMenuPortion(MenuItem item) { return item.AddPortion("Normal", 0, LocalSettings.CurrencySymbol); } public static MenuItemProperty AddDefaultMenuItemProperty(MenuItemPropertyGroup item) { return item.AddProperty("", 0, LocalSettings.CurrencySymbol); } public static MenuItem Create() { var result = new MenuItem(); AddDefaultMenuPortion(result); return result; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/MenuItem.cs
C#
gpl3
2,950
using System.Collections.Generic; using Samba.Domain.Foundation; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class MenuItemPropertyGroup : IEntity, IOrderable { public int Order { get; set; } public string UserString { get { return Name; } } public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public bool SingleSelection { get; set; } public bool MultipleSelection { get; set; } public bool ForceValue{ get; set; } public string GroupTag { get; set; } public int ColumnCount { get; set; } public int ButtonHeight { get; set; } public int TerminalColumnCount { get; set; } public int TerminalButtonHeight { get; set; } public bool CalculateWithParentPrice { get; set; } private IList<MenuItemProperty> _properties; public virtual IList<MenuItemProperty> Properties { get { return _properties; } set { _properties = value; } } public MenuItemPropertyGroup() { _properties = new List<MenuItemProperty>(); ColumnCount = 5; ButtonHeight = 65; TerminalColumnCount = 4; TerminalButtonHeight = 35; } public MenuItemProperty AddProperty(string name, decimal price, string defaultCurrency) { var prp = new MenuItemProperty { Name = name, Price = new Price(price, defaultCurrency) }; Properties.Add(prp); return prp; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/MenuItemPropertyGroup.cs
C#
gpl3
1,724
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using Samba.Domain.Models.Tickets; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class MenuItemPriceDefinition : IEntity { public int Id { get; set; } public string Name { get; set; } [StringLength(10)] public string PriceTag { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/MenuItemPriceDefinitions.cs
C#
gpl3
473
using System.Collections.Generic; using Samba.Domain.Foundation; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class MenuItemPortion : IEntity { public int Id { get; set; } public int MenuItemId { get; set; } public string Name { get; set; } public Price Price { get; set; } public int Multiplier { get; set; } private IList<MenuItemPrice> _prices; public virtual IList<MenuItemPrice> Prices { get { return _prices; } set { _prices = value; } } public MenuItemPortion() { Multiplier = 1; _prices = new List<MenuItemPrice>(); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/MenuItemPortion.cs
C#
gpl3
753
using System; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class ScreenMenuItem : IOrderable { public ScreenMenuItem() { Quantity = 1; Tag = ""; } public int Id { get; set; } public string Name { get; set; } public string UserString { get { return MenuItem != null ? MenuItem.Name + " [" + MenuItem.GroupCode + "]" : Name; } } public int ScreenMenuCategoryId { get; set; } public int MenuItemId { get; set; } public int Order { get; set; } public bool AutoSelect { get; set; } public string ButtonColor { get; set; } public int Quantity { get; set; } public bool Gift { get; set; } public string ImagePath { get; set; } public string DefaultProperties { get; set; } public string Tag { get; set; } public string ItemPortion { get; set; } public int UsageCount { get; set; } public bool IsImageOnly { get; set; } public MenuItem MenuItem; } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/ScreenMenuItem.cs
C#
gpl3
1,145
using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class TaxServiceTemplate : IEntity, IOrderable { public int Id { get; set; } public string Name { get; set; } public int Order { get; set; } public string UserString { get { return Name; } } public int CalculationMethod { get; set; } public decimal Amount { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/TaxServiceTemplate.cs
C#
gpl3
430
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class MenuItemPrice { public int Id { get; set; } public int MenuItemPortionId { get; set; } [StringLength(10)] public string PriceTag { get; set; } public decimal Price { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/MenuItemPrice.cs
C#
gpl3
471
using System.Collections.Generic; using System.Diagnostics; using System.Linq; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class ScreenMenu : IEntity { public ScreenMenu() : this("Menu") { } public ScreenMenu(string name) { Name = name; _categories = new List<ScreenMenuCategory>(); } public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } private IList<ScreenMenuCategory> _categories; public virtual IList<ScreenMenuCategory> Categories { get { return _categories; } set { _categories = value; } } public ScreenMenuCategory AddCategory(string categoryName) { var result = new ScreenMenuCategory(categoryName); Categories.Add(result); return result; } public string UserString { get { return Name; } } public void AddItemsToCategory(string category, List<MenuItem> menuItems) { ScreenMenuCategory menuCategory = Categories.Single(x => x.Name == category); Debug.Assert(menuCategory != null); foreach (var menuItem in menuItems) { menuCategory.AddMenuItem(menuItem); } } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/ScreenMenu.cs
C#
gpl3
1,500
using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Menus { public class VatTemplate : IEntity { public int Id { get; set; } public string Name { get; set; } public decimal Rate { get; set; } public bool VatIncluded { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Menus/TaxTemplate.cs
C#
gpl3
305
using System; using System.Collections.Generic; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Tables { public class TableScreen : IEntity { public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public int DisplayMode { get; set; } public string BackgroundColor { get; set; } public string BackgroundImage { get; set; } public string TableEmptyColor { get; set; } public string TableFullColor { get; set; } public string TableLockedColor { get; set; } public int PageCount { get; set; } public int ColumnCount { get; set; } public int ButtonHeight { get; set; } public int NumeratorHeight { get; set; } public string AlphaButtonValues { get; set; } private IList<Table> _tables; public virtual IList<Table> Tables { get { return _tables; } set { _tables = value; } } public TableScreen() { _tables = new List<Table>(); TableEmptyColor = "WhiteSmoke"; TableFullColor = "Orange"; TableLockedColor = "Brown"; BackgroundColor = "Transparent"; PageCount = 1; ButtonHeight = 0; } public int ItemCountPerPage { get { var itemCount = Tables.Count / PageCount; if (Tables.Count % PageCount > 0) itemCount++; return itemCount; } } public void AddScreenItem(Table choosenValue) { if (!Tables.Contains(choosenValue)) Tables.Add(choosenValue); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tables/TableScreen.cs
C#
gpl3
1,823
using System; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Tables { public class Table : IEntity, IOrderable { public int Id { get; set; } public string Name { get; set; } public int Order { get; set; } public byte[] LastUpdateTime { get; set; } public string Category { get; set; } public int TicketId { get; set; } public bool IsTicketLocked { get; set; } public int XLocation { get; set; } public int YLocation { get; set; } public int Height { get; set; } public int Width { get; set; } public int CornerRadius { get; set; } public double Angle { get; set; } public string HtmlContent { get; set; } public bool AutoRefresh { get; set; } public string UserString { get { return Name + " [" + Category + "]"; } } public Table() { Height = 70; Width = 70; AutoRefresh = true; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Tables/Table.cs
C#
gpl3
1,071
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Transactions { public class AccountTransaction : IEntity { public int Id { get; set; } public string Name { get; set; } public DateTime Date { get; set; } public int TransactionType { get; set; } public decimal Amount { get; set; } public int UserId { get; set; } public int CustomerId { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Transactions/AccountTransaction.cs
C#
gpl3
544
using System; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Transactions { public class CashTransaction : IEntity { public int Id { get; set; } public string Name { get; set; } public DateTime Date { get; set; } public int PaymentType { get; set; } public int TransactionType { get; set; } public decimal Amount { get; set; } public int UserId { get; set; } public int CustomerId { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Transactions/CashTransaction.cs
C#
gpl3
512
using System.ComponentModel.DataAnnotations; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Actions { public class ActionContainer : IOrderable { public ActionContainer() { } public ActionContainer(AppAction ruleAction) { AppActionId = ruleAction.Id; Name = ruleAction.Name; } public int Id { get; set; } public int AppActionId { get; set; } public int AppRuleId { get; set; } public string Name { get; set; } [StringLength(500)] public string ParameterValues { get; set; } public int Order { get; set; } public string UserString { get { return Name; } } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Actions/ActionContainer.cs
C#
gpl3
815
using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Actions { public class AppRule : IEntity { public int Id { get; set; } public string Name { get; set; } public string EventName { get; set; } [StringLength(500)] public string EventConstraints { get; set; } private IList<ActionContainer> _actions; public virtual IList<ActionContainer> Actions { get { return _actions; } set { _actions = value; } } public AppRule() { _actions = new List<ActionContainer>(); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Actions/AppRule.cs
C#
gpl3
741
using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text.RegularExpressions; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Actions { public class AppAction : IEntity { public int Id { get; set; } public string Name { get; set; } public string ActionType { get; set; } [StringLength(500)] public string Parameter { get; set; } public string GetParameter(string parameterName) { var param = Parameter.Split('#').Where(x => x.StartsWith(parameterName + "=")).FirstOrDefault(); if (!string.IsNullOrEmpty(param) && param.Contains("=")) return param.Split('=')[1]; return ""; } public string GetFormattedParameter(string parameterName, object dataObject, string parameterValues) { var format = GetParameter(parameterName); return !string.IsNullOrEmpty(format) && format.Contains("[") ? Format(format, dataObject, parameterValues) : format; } public string Format(string s, object dataObject, string parameterValues) { if (!string.IsNullOrEmpty(parameterValues) && Regex.IsMatch(parameterValues, "\\[([^\\]]+)\\]")) { foreach (var propertyName in Regex.Matches(parameterValues, "\\[([^\\]]+)\\]").Cast<Match>().Select(match => match.Groups[1].Value).ToList()) { var value = dataObject.GetType().GetProperty(propertyName).GetValue(dataObject, null) ?? ""; parameterValues = parameterValues.Replace(string.Format("[{0}]", propertyName), value.ToString()); } } var parameters = (parameterValues ?? "") .Split('#') .Select(y => y.Split('=')) .Where(x => x.Length > 1) .ToDictionary(x => x[0], x => x[1]); var matches = Regex.Matches(s, "\\[([^\\]]+)\\]").Cast<Match>() .Select(match => match.Groups[1].Value) .Where(value => parameters.Keys.Contains(value)); return matches.Aggregate(s, (current, value) => current.Replace(string.Format("[{0}]", value), parameters[value].ToString())); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Actions/AppAction.cs
C#
gpl3
2,372
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Settings { public class Trigger : IEntity { public int Id { get; set; } public string Name { get; set; } public string Expression { get; set; } public DateTime LastTrigger { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Settings/Trigger.cs
C#
gpl3
403
using Samba.Domain.Models.Menus; using Samba.Domain.Models.Tickets; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Settings { public class PrinterMap : IEntity { public int Id { get; set; } public string Name { get; set; } public int PrintJobId { get; set; } public byte[] LastUpdateTime { get; set; } public virtual Department Department { get; set; } public string MenuItemGroupCode { get; set; } public string TicketTag { get; set; } public virtual MenuItem MenuItem { get; set; } public virtual Printer Printer { get; set; } public virtual PrinterTemplate PrinterTemplate { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Settings/PrinterMap.cs
C#
gpl3
726
using System.Collections.Generic; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Settings { public enum WhenToPrintTypes { Manual, NewLinesAdded, Paid } public enum WhatToPrintTypes { Everything, NewLines, GroupedByBarcode, GroupedByGroupCode, GroupedByTag, LastLinesByPrinterLineCount, LastPaidItems } public class PrintJob : IEntity, IOrderable { public int Id { get; set; } public string Name { get; set; } public string ButtonText { get; set; } public int Order { get; set; } public string UserString { get { return Name; } } public bool AutoPrintIfCash { get; set; } public bool AutoPrintIfCreditCard { get; set; } public bool AutoPrintIfTicket { get; set; } public int WhenToPrint { get; set; } public int WhatToPrint { get; set; } public bool LocksTicket { get; set; } public bool CloseTicket { get; set; } public bool UseFromPaymentScreen { get; set; } public bool UseFromTerminal { get; set; } public bool UseFromPos { get; set; } public bool UseForPaidTickets { get; set; } public bool ExcludeVat { get; set; } private IList<PrinterMap> _printerMaps; public virtual IList<PrinterMap> PrinterMaps { get { return _printerMaps; } set { _printerMaps = value; } } public PrintJob() { _printerMaps = new List<PrinterMap>(); UseFromPos = true; UseFromPaymentScreen = true; CloseTicket = true; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Settings/PrintJob.cs
C#
gpl3
1,767
using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Settings { public class Numerator : IEntity { public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public int Number { get; set; } public string NumberFormat { get; set; } public string GetNumber() { return Number.ToString(NumberFormat); } public Numerator() { NumberFormat = "#"; Name = "Varsayılan Numeratör"; Number = 0; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Settings/Numerator.cs
C#
gpl3
625
using System.ComponentModel.DataAnnotations; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Settings { public class PrinterTemplate : IEntity { public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } [StringLength(500)] public string HeaderTemplate { get; set; } [StringLength(500)] public string LineTemplate { get; set; } [StringLength(500)] public string VoidedLineTemplate { get; set; } [StringLength(500)] public string GiftLineTemplate { get; set; } [StringLength(500)] public string FooterTemplate { get; set; } [StringLength(500)] public string GroupTemplate { get; set; } public bool MergeLines { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Settings/PrinterTemplate.cs
C#
gpl3
855
using System.ComponentModel.DataAnnotations; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Settings { public class ProgramSetting : IEntity { public int Id { get; set; } [StringLength(100)] public string Name { get; set; } [StringLength(250)] public string Value { get; set; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Settings/ProgramSetting.cs
C#
gpl3
368
using System.Collections.Generic; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Settings { public class Terminal : IEntity { public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public bool IsDefault { get; set; } public bool AutoLogout { get; set; } public bool HideExitButton { get; set; } public virtual Printer SlipReportPrinter { get; set; } public virtual Printer ReportPrinter { get; set; } public int DepartmentId { get; set; } private IList<PrintJob> _printJobs; public virtual IList<PrintJob> PrintJobs { get { return _printJobs; } set { _printJobs = value; } } private static readonly Terminal _defaultTerminal = new Terminal { Name = "Varsayılan Terminal" }; public static Terminal DefaultTerminal { get { return _defaultTerminal; } } public Terminal() { _printJobs = new List<PrintJob>(); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Settings/Terminal.cs
C#
gpl3
1,109
using System; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Settings { public class WorkPeriod : IEntity { public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } public string StartDescription { get; set; } public string EndDescription { get; set; } public decimal CashAmount { get; set; } public decimal CreditCardAmount { get; set; } public decimal TicketAmount { get; set; } public string Description { get { var desc = (StartDescription + " - " + EndDescription).Trim(' ', '-'); return desc; } } public override string ToString() { if (!string.IsNullOrEmpty(Name)) return Name; var desc = !string.IsNullOrEmpty(Description) ? " # " + Description : ""; if (StartDate == EndDate) { return StartDate.ToString("dd MMMMM yyyy HH:mm") + desc; } return string.Format("{0} - {1}{2}", StartDate.ToString("dd MMMMM yyyy HH:mm"), EndDate.ToString("dd MMMMM yyyy HH:mm"), desc).Trim(); } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Settings/WorkPeriod.cs
C#
gpl3
1,390
using System; using Samba.Infrastructure.Data; namespace Samba.Domain.Models.Settings { public class Printer : IEntity { public int Id { get; set; } public string Name { get; set; } public byte[] LastUpdateTime { get; set; } public string ShareName { get; set; } public int PrinterType { get; set; } public int CodePage { get; set; } public int CharsPerLine { get; set; } public int PageHeight { get; set; } public string ReplacementPattern { get; set; } public Printer() { CharsPerLine = 42; CodePage = 857; } } }
zzgaminginc-pointofssale
Samba.Domain/Models/Settings/Printer.cs
C#
gpl3
676
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Samba.Domain")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Samba.Domain")] [assembly: AssemblyCopyright("Copyright © 2010")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("7286eabc-f893-49bc-994f-d69d5fd87b38")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: InternalsVisibleTo("Samba.Domain.Explorables")]
zzgaminginc-pointofssale
Samba.Domain/Properties/AssemblyInfo.cs
C#
gpl3
1,496
using System; namespace Samba.Domain.Foundation { public class DocumentDate { private DateTime _dateTime; public DocumentDate() : this(DateTime.Now) { } public DocumentDate(int day, int month, int year) : this(new DateTime(year, month, day)) { } public DocumentDate(DateTime dateTime) { _dateTime = dateTime; } public static DocumentDate Now { get { return new DocumentDate(); } } public override bool Equals(object obj) { var comparingDate = obj as DocumentDate; if (comparingDate != null) { return comparingDate._dateTime.Day == _dateTime.Day && comparingDate._dateTime.Month == _dateTime.Month && comparingDate._dateTime.Year == _dateTime.Year && comparingDate._dateTime.Hour == _dateTime.Hour && comparingDate._dateTime.Minute == _dateTime.Minute; } return base.Equals(obj); } public static bool operator ==(DocumentDate a, DocumentDate b) { // If both are null, or both are same instance, return true. if (ReferenceEquals(a, b)) { return true; } // If one is null, but not both, return false. if (((object)a == null) || ((object)b == null)) { return false; } // Return true if the fields match: return a._dateTime.Day == b._dateTime.Day && a._dateTime.Month == b._dateTime.Month && a._dateTime.Year == b._dateTime.Year && a._dateTime.Hour == b._dateTime.Hour && a._dateTime.Minute == b._dateTime.Minute; } public static bool operator !=(DocumentDate a, DocumentDate b) { return !(a == b); } public override int GetHashCode() { return _dateTime.Day + _dateTime.Month + _dateTime.Year + _dateTime.Hour + _dateTime.Minute; } public long Ticks { get { return _dateTime.Ticks; } } public int Day { get { return _dateTime.Day; } } public int Month { get { return _dateTime.Month; } } public int Year { get { return _dateTime.Year; } } public int Hour { get { return _dateTime.Hour; } } public int Minute { get { return _dateTime.Minute; } } public int Second { get { return _dateTime.Second; } } public string Date { get { return _dateTime.ToString(); } set { DateTime.TryParse(value, out _dateTime); } } public string ShortDateDisplay { get { return _dateTime.ToShortDateString(); } } public string ShortTimeDisplay { get { return _dateTime.ToShortTimeString(); } } public double DifferenceMinutesFromNow() { return new TimeSpan(DateTime.Now.Ticks - _dateTime.Ticks).TotalMinutes; } } }
zzgaminginc-pointofssale
Samba.Domain/Foundation/DocumentDate.cs
C#
gpl3
3,306
namespace Samba.Domain.Foundation { public class Price { public Price() { } public Price(decimal price, string currencyCode) { Amount = price; CurrencyCode = currencyCode; } public string CurrencyCode { get; set; } public decimal Amount { get; set; } public override string ToString() { return Amount.ToString("#,#0.00 " + CurrencyCode); } } }
zzgaminginc-pointofssale
Samba.Domain/Foundation/Price.cs
C#
gpl3
511
namespace Samba.Domain { public enum PaymentType { Cash, CreditCard, Ticket, Account } }
zzgaminginc-pointofssale
Samba.Domain/PaymentType.cs
C#
gpl3
144
using System; using System.Windows.Input; namespace PropertyTools.Wpf { public class DelegateCommand : ICommand { private readonly Action execute; private readonly Func<bool> canExecute; public DelegateCommand(Action execute) : this(execute, null) { } public DelegateCommand(Action execute, Func<bool> canExecute) { if (execute == null) { throw new ArgumentNullException("execute"); } this.execute = execute; this.canExecute = canExecute; } public event EventHandler CanExecuteChanged { add { if (canExecute != null) { CommandManager.RequerySuggested += value; } } remove { if (canExecute != null) { CommandManager.RequerySuggested -= value; } } } public void RaiseCanExecuteChanged() { CommandManager.InvalidateRequerySuggested(); } public bool CanExecute(object parameter) { return canExecute == null ? true : canExecute(); } public void Execute(object parameter) { execute(); } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Commands/DelegateCommand.cs
C#
gpl3
1,460
using System; using System.Windows.Markup; namespace PropertyTools.Wpf { [Obsolete] public abstract class SelfProvider : MarkupExtension { public override object ProvideValue(IServiceProvider serviceProvider) { return this; } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/SelfProvider.cs
C#
gpl3
295
using System; using System.Windows.Data; namespace PropertyTools.Wpf { // todo: this was included for the slidable properties - does not work /// <summary> /// Convert any object to double (if possible) /// </summary> [ValueConversion(typeof(object), typeof(double))] public class ToDoubleConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return 0; // Explicit unboxing var t = value.GetType(); if (t == typeof(int)) return (int)value; if (t == typeof(long)) return (long)value; if (t == typeof(byte)) return (byte)value; if (t == typeof(double)) return (double)value; if (t == typeof(float)) return (float)value; return Binding.DoNothing; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { // if (targetType==typeof(double)) return value; // return Binding.DoNothing; } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/ToDoubleConverter.cs
C#
gpl3
1,365
using System; using System.Windows.Data; using System.Windows.Media; namespace PropertyTools.Wpf { /// <summary> /// Color to Hex string value converter /// </summary> [ValueConversion(typeof(Color), typeof(string))] public class ColorToHexConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return null; var color = (Color)value; return ColorHelper.ColorToHex(color); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return ColorHelper.HexToColor((string)value); } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/ColorToHexConverter.cs
C#
gpl3
825
using System; using System.Globalization; using System.Windows.Data; namespace PropertyTools.Wpf { /// <summary> /// Enum to Boolean converter /// Usage 'Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static value...}' /// </summary> [ValueConversion(typeof(Enum), typeof(bool))] public class EnumToBooleanConverter : IValueConverter { public Type EnumType { get; set; } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null || parameter == null) return Binding.DoNothing; string checkValue = value.ToString(); string targetValue = parameter.ToString(); return checkValue.Equals(targetValue, StringComparison.OrdinalIgnoreCase); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null || parameter == null) return Binding.DoNothing; try { bool boolValue = System.Convert.ToBoolean(value, culture); if (boolValue) return Enum.Parse(EnumType, parameter.ToString()); } catch (ArgumentException) { } // Ignore, just return DoNothing. catch (FormatException) { } // Ignore, just return DoNothing. return Binding.DoNothing; } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/EnumToBooleanConverter.cs
C#
gpl3
1,570
using System; using System.Windows.Data; using System.Windows.Media; namespace PropertyTools.Wpf { /// <summary> /// System.Windows.Media.Color to System.Drawing.Color value converter /// </summary> [ValueConversion( typeof( System.Windows.Media.Color), typeof( System.Drawing.Color ) )] public class DrawingColorToMediaColorConverter : IValueConverter { public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { // System.Windows.Media.Color --> System.Drawing.Color Color c = (Color)value; return System.Drawing.Color.FromArgb( c.A, c.R, c.G, c.B ); } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { // System.Drawing.Color --> System.Windows.Media.Color System.Drawing.Color c = (System.Drawing.Color)value; return Color.FromArgb( c.A, c.R, c.G, c.B ); } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/DrawingColorToMediaColorConverter.cs
C#
gpl3
1,003
using System; using System.Windows; using System.Windows.Data; namespace PropertyTools.Wpf { /// <summary> /// Null to Visibility converter /// </summary> [ValueConversion(typeof(Visibility), typeof(object))] public class NullToVisibilityConverter : IValueConverter { public Visibility NullVisibility { get; set; } public Visibility NotNullVisibility { get; set; } public NullToVisibilityConverter() { NullVisibility = Visibility.Collapsed; NotNullVisibility = Visibility.Visible; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return null; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return NullVisibility; return NotNullVisibility; } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/NullToVisibilityConverter.cs
C#
gpl3
1,039
using System; using System.Windows.Data; using System.Windows.Media; namespace PropertyTools.Wpf { /// <summary> /// Color to Brush value converter /// </summary> [ValueConversion(typeof(Color), typeof(SolidColorBrush))] public class ColorToBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return Binding.DoNothing; if (typeof(Brush).IsAssignableFrom(targetType)) { if (value is Color) return new SolidColorBrush((Color)value); } if (targetType == typeof(Color)) { if (value is SolidColorBrush) return ((SolidColorBrush)value).Color; } return Binding.DoNothing; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return Convert(value, targetType, parameter, culture); } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/ColorToBrushConverter.cs
C#
gpl3
1,176
using System; using System.Globalization; using System.Windows.Data; using System.Windows.Media; using PropertyEditorLibrary.Controls.ColorPicker; namespace PropertyEditorLibrary { /// <summary> /// Color to Brush value converter /// </summary> [ValueConversion(typeof(ColorWrapper), typeof(SolidColorBrush))] public class ColorWrapperToBrushConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value == null ? Binding.DoNothing : ((ColorWrapper)value).Color; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return new ColorWrapper((Color)value); } #endregion } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/ColorWrapperToBrushConverter.cs
C#
gpl3
876
using System; using System.Collections.Generic; using System.Linq; using System.ComponentModel; using System.Reflection; using System.Windows.Data; using System.Collections; namespace PropertyTools.Wpf { /// <summary> /// The EnumDescriptionConverter gets the Description attribute for Enum values. /// </summary> [ValueConversion(typeof(object), typeof(string))] public class EnumDescriptionConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { // Default, non-converted result. string result = value.ToString(); var field = value.GetType().GetFields(BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public).FirstOrDefault(f => f.GetValue(null).Equals(value)); if (field != null) { var descriptionAttribute = field.GetCustomAttributes<DescriptionAttribute>(true).FirstOrDefault(); if (descriptionAttribute != null) { // Found the attribute, assign description result = descriptionAttribute.Description; } } return result; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotSupportedException(); } #endregion } public static class ReflectionExtensions { public static IEnumerable<T> GetCustomAttributes<T>(this FieldInfo fieldInfo, bool inherit) { return fieldInfo.GetCustomAttributes(typeof(T), inherit).Cast<T>(); } /// <summary> /// Filters on the browsable attribute. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="arr">The arr.</param> /// <returns></returns> public static List<object> FilterOnBrowsableAttribute<T>( this T arr ) where T : IEnumerable { // Default empty list List<object> res = new List<object>(); // Loop each item in the enumerable foreach( var o in arr ) { // Get the field information for the current field FieldInfo field = o.GetType().GetField( o.ToString(), BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public ); if( field != null ) { // Get the Browsable attribute, if it is declared for this field var browsable = field.GetCustomAttributes<BrowsableAttribute>( true ).FirstOrDefault(); if( browsable != null ) { // It is declared, is it true or false? if( browsable.Browsable ) { // Is true - field is not hidden so add it to the result. res.Add( o ); } } else { // Not declared so add it to the result res.Add( o ); } } else { // Can't evaluate, include it. res.Add( o ); } } return res; } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/EnumDescriptionConverter.cs
C#
gpl3
2,813
using System; using System.Windows.Data; namespace PropertyTools.Wpf { /// <summary> /// Null to bool value converter /// </summary> [ValueConversion(typeof(bool), typeof(object))] public class NullToBoolConverter : IValueConverter { /// <summary> /// Gets or sets the value returned when the source value is null. /// </summary> public bool NullValue { get; set; } public NullToBoolConverter() { NullValue = true; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return null; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return NullValue; return !NullValue; } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/NullToBoolConverter.cs
C#
gpl3
965
using System; using System.Windows.Data; namespace PropertyTools.Wpf { /// <summary> /// Converts an Enum to a list of the enum type values /// </summary> [ValueConversion( typeof( Enum ), typeof( string[] ) )] public class EnumValuesConverter : IValueConverter { #region IValueConverter Members public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { if( value != null ) return Enum.GetValues( value.GetType() ).FilterOnBrowsableAttribute(); else if( targetType == typeof( Enum ) ) return Enum.GetValues( targetType ).FilterOnBrowsableAttribute(); else { return value; } } public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { throw new NotSupportedException(); } #endregion } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/EnumValuesConverter.cs
C#
gpl3
899
using System; using System.Windows; using System.Windows.Data; namespace PropertyTools.Wpf { /// <summary> /// Bool to Visibility value converter /// </summary> [ValueConversion(typeof(bool), typeof(Visibility))] public class BoolToVisibilityConverter :IValueConverter { public bool InvertVisibility { get; set; } public Visibility NotVisibleValue { get; set; } public BoolToVisibilityConverter() { InvertVisibility = false; NotVisibleValue = Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return ((value is Visibility) && (((Visibility)value) == Visibility.Visible)) ? !InvertVisibility : InvertVisibility; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return Visibility.Visible; bool visible=true; if (value is bool) { visible = (bool)value; } else if (value is bool?) { var nullable = (bool?)value; visible = nullable.HasValue ? nullable.Value : false; } if (InvertVisibility) visible = !visible; return visible ? Visibility.Visible : NotVisibleValue; } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/BoolToVisibilityConverter.cs
C#
gpl3
1,560
using System; using System.Windows; using System.Windows.Data; namespace PropertyTools.Wpf { /// <summary> /// GridLength to double value converter /// </summary> [ValueConversion(typeof(GridLength), typeof(double))] public class DoubleToGridLengthConverter : IValueConverter { public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (targetType == typeof(GridLength)) { if (value == null) return GridLength.Auto; if (value is double) return new GridLength((double)value); return GridLength.Auto; } if (targetType == typeof(double)) { if (value is GridLength) return ((GridLength)value).Value; return double.NaN; } return null; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return ConvertBack(value, targetType, parameter, culture); } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/DoubleToGridLengthConverter.cs
C#
gpl3
1,225
using System; using System.Windows.Data; using System.Windows.Media; namespace PropertyTools.Wpf { /// <summary> /// Brush to Color value converter /// </summary> [ValueConversion(typeof(Brush), typeof(Color))] public class BrushToColorConverter : IValueConverter { public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return Brushes.Red; var color = (Color)value; return new SolidColorBrush(color); } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var scb = value as SolidColorBrush; if (scb != null) return scb.Color; // todo: other brush types?? return Color.FromArgb(0, 0, 0, 0); } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Converters/BrushToColorConverter.cs
C#
gpl3
969
using System; namespace PropertyTools.Wpf { /// <summary> /// The OptionalAttribute is used for optional properties. /// Properties marked with [Optional] will have a checkbox as the label. /// The checkbox will enable/disable the property value editor. /// Example usage: /// [Optional] // requires a nullable property type /// [Optional("HasSomething")] // relates to other property HasSomething /// </summary> [AttributeUsage(AttributeTargets.Property)] public class OptionalAttribute : Attribute { public static readonly OptionalAttribute Default; public OptionalAttribute() { PropertyName = null; } public OptionalAttribute(string propertyName) { PropertyName = propertyName; } public string PropertyName { get; set; } public override bool Equals(object obj) { return PropertyName.Equals((string)obj); } public override int GetHashCode() { return PropertyName.GetHashCode(); } public override bool IsDefaultAttribute() { return Equals(Default); } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Attributes/OptionalAttribute.cs
C#
gpl3
1,281
using System; namespace PropertyTools.Wpf { /// <summary> /// The AutoUpdateTextAttribute forces the binding to update the value at every change. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class AutoUpdateTextAttribute : Attribute { } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Attributes/AutoUpdateTextAttribute.cs
C#
gpl3
299
using System; using System.ComponentModel; namespace PropertyTools.Wpf { /// <summary> /// EnumDisplayNameAttribute is used to decorate enum values with display names. /// </summary> [AttributeUsage(AttributeTargets.Enum | AttributeTargets.Field)] public class EnumDisplayNameAttribute : DisplayNameAttribute { public EnumDisplayNameAttribute(string displayName) : base(displayName) { } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Attributes/EnumDisplayNameAttribute.cs
C#
gpl3
465
using System; using System.Windows.Controls.Primitives; namespace PropertyTools.Wpf { /// <summary> /// The SlidableAttribute is used for numeric properties. /// Properties marked with [Slidable] will have a slider next to its editor. /// Example usage: /// [Slidable(0,100)] /// [Slidable(0,100,1,10)] /// </summary> [AttributeUsage(AttributeTargets.All)] public class SlidableAttribute : Attribute { public static readonly SlidableAttribute Default = new SlidableAttribute(); public SlidableAttribute() { Minimum = 0; Maximum = 100; SmallChange = 1; LargeChange = 10; SnapToTicks = false; TickFrequency = 1; TickPlacement = TickPlacement.None; } public SlidableAttribute(double minimum, double maximum) : this(minimum, maximum, 1, 10) { } public SlidableAttribute(double minimum, double maximum, double smallChange, double largeChange) { Minimum = minimum; Maximum = maximum; SmallChange = smallChange; LargeChange = largeChange; } public SlidableAttribute(double minimum, double maximum, double smallChange, double largeChange, bool snapToTicks, double tickFrequency) : this(minimum, maximum, smallChange, largeChange) { SnapToTicks = snapToTicks; TickFrequency = tickFrequency; } public SlidableAttribute(double minimum, double maximum, double smallChange, double largeChange, bool snapToTicks, double tickFrequency, TickPlacement tickPlacement) : this(minimum, maximum, smallChange, largeChange, snapToTicks, tickFrequency) { TickPlacement = tickPlacement; } public double Minimum { get; set; } public double Maximum { get; set; } public double LargeChange { get; set; } public double SmallChange { get; set; } public bool SnapToTicks { get; set; } public double TickFrequency { get; set; } public TickPlacement TickPlacement { get; set; } public override bool Equals(object obj) { var o = obj as SlidableAttribute; return o == null ? false : Minimum.Equals(o.Minimum) && Maximum.Equals(o.Maximum); } public override int GetHashCode() { return Minimum.GetHashCode() ^ Maximum.GetHashCode(); } public override bool IsDefaultAttribute() { return Equals(Default); } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Attributes/SlidableAttribute.cs
C#
gpl3
2,728
using System; namespace PropertyTools.Wpf { /// <summary> /// The HeightAttribute is used to control the height of TextBoxes. /// Example usage: /// [Height(100)] /// </summary> [AttributeUsage(AttributeTargets.Property)] public class HeightAttribute : Attribute { public HeightAttribute(double height) { Height = height; } public double Height { get; set; } } }
zzgaminginc-pointofssale
Lib/PropertyTools.Wpf/Attributes/HeightAttribute.cs
C#
gpl3
472