public static Scenario CreateScenario(string name, DateTime beginDate, DateTime endDate, CalculationType type)
        {
            Scenario scenario = new Scenario();

            scenario.Name = name;
            scenario.BeginDate = beginDate;
            scenario.EndDate = endDate;
            scenario.Type = type;
            scenario.FlowoffValues = GenerateFlowoffValues(beginDate, endDate, type);

            lock (scenarios)
            {
                long id = scenarios.Count;
                scenario.Id = id;
                scenarios.Add(id, scenario);
            }

            return scenario;
        }
        private static IDictionary<DateTime, IDictionary<int, float>> GenerateFlowoffValues(DateTime beginDate, DateTime endDate, CalculationType type)
        {
            IDictionary<DateTime, IDictionary<int, float>> flowoffValues = new Dictionary<DateTime, IDictionary<int, float>>();

            Random rand = new Random();

            Func<Random,IDictionary<int, float>> getDayValues = type == CalculationType.Diagnostic
                ? (Func<Random, IDictionary<int, float>>)((r) => { return new Dictionary<int, float> { { 0, 0 }, { beginDate.Year, r.Next(500) } }; })
                : type == CalculationType.Forecast
                ? (Func<Random, IDictionary<int, float>>)((r) => { return new Dictionary<int, float> { { beginDate.Year, r.Next(500) } }; })
                : (Func<Random, IDictionary<int, float>>)((r) => { return Enumerable.Range(1966, beginDate.Year - 1966).ToDictionary(y => y, y => (float)r.Next(500)); });

            for (DateTime date = beginDate; date <= endDate; date = date.AddDays(1))
            {
                flowoffValues.Add(date, getDayValues(rand));
            }

            return flowoffValues;
        }
示例#3
0
    public override void DrawWindow()
    {
        base.DrawWindow();

        //check for events
        Event e = Event.current;

        //make a popup for the user to select the calculation type
        calculationType = (CalculationType)EditorGUILayout.EnumPopup("Calculation Type", calculationType);


        string input1Title = "None";

        //if there is input get the result
        if (input1)
        {
            input1Title = input1.getResult();
        }

        //draw a label
        GUILayout.Label("Input 1: " + input1Title);

        if (e.type == EventType.Repaint)
        {
            input1Rect = GUILayoutUtility.GetLastRect();
        }

        string input2Title = "None";

        if (input2)
        {
            input2Title = input2.getResult();
        }

        GUILayout.Label("Input 2: " + input2Title);

        if (e.type == EventType.Repaint)
        {
            input2Rect = GUILayoutUtility.GetLastRect();
        }
    }
示例#4
0
        public static bool ParseFriendlyString(string calculationTypeString, out CalculationType calculationType)
        {
            switch (calculationTypeString)
            {
            case AverageOfTopNString:
                calculationType = CalculationType.AverageOfTopN;
                return(true);

            case AverageOfAllString:
                calculationType = CalculationType.AverageOfAll;
                return(true);

            case MaxString:
                calculationType = CalculationType.Max;
                return(true);

            default:
                calculationType = CalculationType.AverageOfTopN;
                return(false);
            }
        }
        public void AddTransactionFee(Guid transactionFeeId,
                                      CalculationType calculationType,
                                      FeeType feeType,
                                      String description,
                                      Decimal value)
        {
            TransactionFee transactionFee = new TransactionFee
            {
                TransactionFeeId = transactionFeeId,
                CalculationType  = calculationType,
                FeeType          = feeType,
                Description      = description,
                Value            = value
            };

            if (this.TransactionFees == null)
            {
                this.TransactionFees = new List <TransactionFee>();
            }
            this.TransactionFees.Add(transactionFee);
        }
        public void ChangeSelectedType()
        {
            CalculationType calcType = fView.TypeCombo.GetSelectedTag <CalculationType>();

            if (calcType >= CalculationType.Units_cm2inch && calcType <= CalculationType.Units_ConvGHppm2GHdeg)
            {
                fCalculation = new UnitsCalculation(calcType);
            }
            else
            {
                switch (calcType)
                {
                case CalculationType.NitriteSaltCalculator:
                    fCalculation = new SaltCalculation(calcType);
                    break;
                }
            }

            fView.ArgsGrid.SelectedObject = fCalculation;
            fView.DescriptionField.Text   = fCalculation.Description;
            fView.ArgsGrid.Refresh();
        }
示例#7
0
    public override void DrawWindow()
    {
        base.DrawWindow(); // tutorial did draw curves?
        Event e = Event.current;

        calculationType = (CalculationType)EditorGUILayout.EnumPopup("Calculation Type: ", calculationType);

        string input1Title = "None";

        if (input1)
        {
            input1Title = input1.getResult();
        }

        GUILayout.Label("Input 1: " + input1Title);

        if (e.type == EventType.Repaint)
        {
            input1Rect = GUILayoutUtility.GetLastRect();
        }


        //


        string input2Title = "None";

        if (input2)
        {
            input2Title = input2.getResult();
        }

        GUILayout.Label("Input 2: " + input2Title);

        if (e.type == EventType.Repaint)
        {
            input2Rect = GUILayoutUtility.GetLastRect();
        }
    }
示例#8
0
        public double Calculate(double numberA, double numberB, CalculationType calculationType)
        {
            double result = 0;

            switch (calculationType)
            {
            case CalculationType.addition:
                result = numberA + numberB;
                break;

            case CalculationType.multiplication:
                result = numberA * numberB;
                break;

            case CalculationType.subtraction:
                result = numberA - numberB;
                break;

            default:
                break;
            }
            return(result);
        }
示例#9
0
        private static FieldType GetFieldType(CalculationType calculationType)
        {
            switch (calculationType)
            {
            case CalculationType.Cash:
            case CalculationType.Rate:
            case CalculationType.PupilNumber:
            case CalculationType.Weighting:
            case CalculationType.PerPupilFunding:
            case CalculationType.LumpSum:
            case CalculationType.Number:
                return(FieldType.NullableOfDecimal);

            case CalculationType.Boolean:
                return(FieldType.Boolean);

            case CalculationType.Enum:
                return(FieldType.String);

            default:
                return(FieldType.String);
            }
        }
        [InlineData(5, 50, false, CalculationType.ByWeight, 100)] // cost would double coz discount is not supported
        public void ProperlyComputeCost(double size, double weight, bool isSpeedy, CalculationType calculationType, decimal expectedTotalCost)
        {
            // arrange
            var smallParcelType   = new MockSomethingSmallSizeParcel();
            var weightBasedParcel = new MockWeightBasedParcel();

            _mockParcelClassifier.Setup(p => p.ClassifyParcelBySize(It.IsAny <double>()))
            .Returns(smallParcelType);

            _mockParcelClassifier.Setup(p => p.ClassifyHeavyParcelByWeight(It.IsAny <double>()))
            .Returns(weightBasedParcel);

            var parcelBuilderWithDiscount = new ParcelOrderBuilder(_mockParcelClassifier.Object, new DiscountCalculator(new List <IDiscount>
            {
                new MockDiscountConfiguration()
            }));

            var parcelOrder = new ParcelOrder
            {
                Speedy          = isSpeedy,
                DiscountToApply = new List <DiscountTypes>
                {
                    DiscountTypes.Small
                },
                ParcelOrderItems = new List <ParcelOrderItem>
                {
                    new ParcelOrderItem(size, weight, calculationType),
                    new ParcelOrderItem(size, weight, calculationType)
                }
            };

            // act
            var order = parcelBuilderWithDiscount.BuildOrder(parcelOrder);

            // assert
            order.TotalCost.Should().Be(expectedTotalCost);
        }
示例#11
0
        /// <summary>
        /// Gets an image based on the given <paramref name="calculationType"/>.
        /// </summary>
        /// <param name="calculationType">The <see cref="CalculationType"/> to get the image for.</param>
        /// <returns>An image.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="calculationType"/>
        /// has an invalid value.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="calculationType"/>
        /// has a valid but not supported value.</exception>
        public static Bitmap GetCalculationTypeImage(CalculationType calculationType)
        {
            if (!Enum.IsDefined(typeof(CalculationType), calculationType))
            {
                throw new InvalidEnumArgumentException(nameof(calculationType),
                                                       (int)calculationType,
                                                       typeof(CalculationType));
            }

            switch (calculationType)
            {
            case CalculationType.SemiProbabilistic:
                return(Resources.SemiProbabilisticCalculationIcon);

            case CalculationType.Probabilistic:
                return(Resources.ProbabilisticCalculationIcon);

            case CalculationType.Hydraulic:
                return(Resources.HydraulicCalculationIcon);

            default:
                throw new NotSupportedException();
            }
        }
示例#12
0
        public form_ExpressionBuilder(string newFieldName, DataTable dataTable, CalculationType calculation, Database database, DataGridView datagridView)
        {
            selField     = newFieldName;
            selDataTable = dataTable;
            calType      = calculation;
            daoDB        = database;
            tableName    = dataTable.TableName;
            mainGridView = datagridView;

            if (tableName.Contains("Inst_"))
            {
                paramTable = "Rvt_Inst_Parameters";
            }
            if (tableName.Contains("Type_"))
            {
                paramTable = "Rvt_Type_Parameters";
            }
            if (tableName.Contains("Rvt_"))
            {
                paramTable = "Rvt_Type_Parameters";
            }                                                                       //Rooms and Spaces
            CollectFieldData();
            InitializeComponent();
        }
示例#13
0
        public void CreateData()
        {
            CreateDefaultCurrenciesIfNeeded();

            if (!ShouldCreateData())
            {
                return;
            }

            var saleAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Sales)
            };
            var receivableAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Receiveable)
            };
            var paymentAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Payment)
            };
            var discountAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Discount)
            };
            var customerAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Customer)
            };

            _workspace.Add(receivableAccountType);
            _workspace.Add(saleAccountType);
            _workspace.Add(paymentAccountType);
            _workspace.Add(discountAccountType);
            _workspace.Add(customerAccountType);
            _workspace.CommitChanges();

            var customerEntityType = new EntityType {
                Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name
            };

            customerEntityType.EntityCustomFields.Add(new EntityCustomField {
                EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone
            });
            customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]";
            var tableEntityType = new EntityType {
                Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name
            };

            _workspace.Add(customerEntityType);
            _workspace.Add(tableEntityType);

            _workspace.CommitChanges();

            var accountScreen = new AccountScreen {
                Name = Resources.General
            };

            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40
            });
            _workspace.Add(accountScreen);

            var defaultSaleAccount = new Account {
                AccountTypeId = saleAccountType.Id, Name = Resources.Sales
            };
            var defaultReceivableAccount = new Account {
                AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables
            };
            var cashAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Cash
            };
            var creditCardAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard
            };
            var voucherAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher
            };
            var defaultDiscountAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Discount
            };
            var defaultRoundingAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Rounding
            };

            _workspace.Add(defaultSaleAccount);
            _workspace.Add(defaultReceivableAccount);
            _workspace.Add(defaultDiscountAccount);
            _workspace.Add(defaultRoundingAccount);
            _workspace.Add(cashAccount);
            _workspace.Add(creditCardAccount);
            _workspace.Add(voucherAccount);

            _workspace.CommitChanges();

            var discountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Discount),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultDiscountAccount.Id
            };

            var roundingTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Rounding),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultRoundingAccount.Id
            };

            var saleTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Sale),
                SourceAccountTypeId    = saleAccountType.Id,
                TargetAccountTypeId    = receivableAccountType.Id,
                DefaultSourceAccountId = defaultSaleAccount.Id,
                DefaultTargetAccountId = defaultReceivableAccount.Id
            };

            var paymentTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Payment),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerAccountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.AccountTransaction),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = customerAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id
            };

            var customerCashPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CashPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerCreditCardPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = creditCardAccount.Id
            };

            _workspace.Add(saleTransactionType);
            _workspace.Add(paymentTransactionType);
            _workspace.Add(discountTransactionType);
            _workspace.Add(roundingTransactionType);
            _workspace.Add(customerAccountTransactionType);
            _workspace.Add(customerCashPaymentType);
            _workspace.Add(customerCreditCardPaymentType);

            var discountService = new CalculationType
            {
                AccountTransactionType = discountTransactionType,
                CalculationMethod      = 0,
                DecreaseAmount         = true,
                Name = Resources.Discount
            };

            var roundingService = new CalculationType
            {
                AccountTransactionType = roundingTransactionType,
                CalculationMethod      = 2,
                DecreaseAmount         = true,
                IncludeTax             = true,
                Name = Resources.Round
            };

            var discountSelector = new CalculationSelector {
                Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign
            };

            discountSelector.CalculationTypes.Add(discountService);
            discountSelector.AddCalculationSelectorMap();

            var roundingSelector = new CalculationSelector {
                Name = Resources.Round, ButtonHeader = Resources.Round
            };

            roundingSelector.CalculationTypes.Add(roundingService);
            roundingSelector.AddCalculationSelectorMap();


            _workspace.Add(discountService);
            _workspace.Add(roundingService);
            _workspace.Add(discountSelector);
            _workspace.Add(roundingSelector);

            var screen = new ScreenMenu();

            _workspace.Add(screen);

            var ticketNumerator = new Numerator {
                Name = Resources.TicketNumerator
            };

            _workspace.Add(ticketNumerator);

            var orderNumerator = new Numerator {
                Name = Resources.OrderNumerator
            };

            _workspace.Add(orderNumerator);



            _workspace.CommitChanges();

            var ticketType = new TicketType
            {
                Name                = Resources.Ticket,
                TicketNumerator     = ticketNumerator,
                OrderNumerator      = orderNumerator,
                SaleTransactionType = saleTransactionType,
                ScreenMenuId        = screen.Id,
            };

            ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment {
                EntityTypeId = tableEntityType.Id, EntityTypeName = tableEntityType.Name, SortOrder = 10
            });
            ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment {
                EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20
            });

            var cashPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = cashAccount,
                Name    = cashAccount.Name
            };

            cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var creditCardPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = creditCardAccount,
                Name    = creditCardAccount.Name
            };

            creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var voucherPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = voucherAccount,
                Name    = voucherAccount.Name
            };

            voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var accountPayment = new PaymentType
            {
                AccountTransactionType = customerAccountTransactionType,
                Name = Resources.CustomerAccount
            };

            accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            _workspace.Add(cashPayment);
            _workspace.Add(creditCardPayment);
            _workspace.Add(voucherPayment);
            _workspace.Add(accountPayment);
            _workspace.Add(ticketType);

            var warehouseType = new WarehouseType {
                Name = Resources.Warehouses
            };

            _workspace.Add(warehouseType);
            _workspace.CommitChanges();

            var localWarehouse = new Warehouse
            {
                Name            = Resources.LocalWarehouse,
                WarehouseTypeId = warehouseType.Id
            };

            _workspace.Add(localWarehouse);
            _workspace.CommitChanges();

            var department = new Department
            {
                Name         = Resources.Restaurant,
                TicketTypeId = ticketType.Id,
                WarehouseId  = localWarehouse.Id
            };

            _workspace.Add(department);

            var transactionType = new InventoryTransactionType
            {
                Name = Resources.PurchaseTransactionType,
                TargetWarehouseTypeId    = warehouseType.Id,
                DefaultTargetWarehouseId = localWarehouse.Id
            };

            _workspace.Add(transactionType);

            var transactionDocumentType = new InventoryTransactionDocumentType
            {
                Name = Resources.PurchaseTransaction,
                InventoryTransactionType = transactionType
            };

            _workspace.Add(transactionDocumentType);

            var role = new UserRole("Admin")
            {
                IsAdmin = true, DepartmentId = 1
            };

            _workspace.Add(role);

            var u = new User("Administrator", "1234")
            {
                UserRole = role
            };

            _workspace.Add(u);

            var ticketPrinterTemplate = new PrinterTemplate {
                Name = Resources.TicketTemplate, Template = GetDefaultTicketPrintTemplate()
            };
            var kitchenPrinterTemplate = new PrinterTemplate {
                Name = Resources.KitchenOrderTemplate, Template = GetDefaultKitchenPrintTemplate()
            };
            var customerReceiptTemplate = new PrinterTemplate {
                Name = Resources.CustomerReceiptTemplate, Template = GetDefaultCustomerReceiptTemplate()
            };

            _workspace.Add(ticketPrinterTemplate);
            _workspace.Add(kitchenPrinterTemplate);
            _workspace.Add(customerReceiptTemplate);

            var printer1 = new Printer {
                Name = Resources.TicketPrinter
            };
            var printer2 = new Printer {
                Name = Resources.KitchenPrinter
            };
            var printer3 = new Printer {
                Name = Resources.InvoicePrinter
            };

            _workspace.Add(printer1);
            _workspace.Add(printer2);
            _workspace.Add(printer3);

            _workspace.CommitChanges();

            var t = new Terminal
            {
                IsDefault            = true,
                Name                 = Resources.Server,
                ReportPrinterId      = printer1.Id,
                TransactionPrinterId = printer1.Id,
            };

            var pm1 = new PrinterMap {
                PrinterId = printer1.Id, PrinterTemplateId = ticketPrinterTemplate.Id
            };

            _workspace.Add(pm1);

            var pj1 = new PrintJob
            {
                Name        = Resources.PrintBill,
                WhatToPrint = (int)WhatToPrintTypes.Everything,
            };

            pj1.PrinterMaps.Add(pm1);


            _workspace.Add(pj1);

            var pm2 = new PrinterMap {
                PrinterId = printer2.Id, PrinterTemplateId = kitchenPrinterTemplate.Id
            };
            var pj2 = new PrintJob
            {
                Name        = Resources.PrintOrdersToKitchenPrinter,
                WhatToPrint = (int)WhatToPrintTypes.Everything,
            };

            pj2.PrinterMaps.Add(pm2);

            _workspace.Add(pj2);
            _workspace.Add(t);

            new RuleGenerator().GenerateSystemRules(_workspace);

            ImportMenus(screen);
            ImportTableResources(tableEntityType, ticketType);

            var customerScreen = new EntityScreen {
                Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id
            };

            customerScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerScreen);

            var customerTicketScreen = new EntityScreen {
                Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id
            };

            customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerTicketScreen);

            var customerCashDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.Cash),
                ButtonHeader        = Resources.Cash,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCashDocument.AddAccountTransactionDocumentTypeMap();
            customerCashDocument.TransactionTypes.Add(customerCashPaymentType);

            var customerCreditCardDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.CreditCard),
                ButtonHeader        = Resources.CreditCard,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCreditCardDocument.AddAccountTransactionDocumentTypeMap();
            customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType);

            _workspace.Add(customerCashDocument);
            _workspace.Add(customerCreditCardDocument);

            ImportItems(BatchCreateEntities);
            ImportItems(BatchCreateTransactionTypes);
            ImportItems(BatchCreateTransactionTypeDocuments);

            _workspace.CommitChanges();
            _workspace.Dispose();
        }
示例#14
0
        public void ClearCalculationModel(CalculationType calculationType)
        {
            var local = this;

            X.Instance.CurrentContext.Thread.Invoke(() => { local._client.ClearCalculationModel(calculationType); });
        }
 // constructor:
 public Numbers(int num1, int num2, CalculationType calcWanted)
 {
     this.number1 = num1;
     this.number2 = num2;
     this.calculationWanted = calcWanted;
 }
 public AmountDetailsIndexer(CalculationType ctype, AmountSource asource)
 {
     CalculationType = ctype;
     AmountSource    = asource;
 }
示例#17
0
 public bool CanProcess(CalculationType calculation)
 {
     return(calculation == CalculationType.AddWithEquation);
 }
 public bool CanProcess(CalculationType calculation)
 {
     return(calculation == CalculationType.Subtract);
 }
示例#19
0
 partial void BtnClear_Activated()
 {
     total       = 0.0d;
     calculation = CalculationType.None;
     ClearDisplay();
 }
示例#20
0
 public SaltCalculation(CalculationType type) : base(type)
 {
 }
示例#21
0
        public Dictionary <string, double> Calculate(Dictionary <string, double> values, CalculationType calculationType)
        {
            var matrices = CalculateMatrices(values);

            switch (calculationType)
            {
            case CalculationType.AvarageOfMaximum:
                return(AvarageOfMaximum(matrices));

            case CalculationType.Centroid:
                return(Centroid(matrices));

            case CalculationType.MeanOfMaximum:
                return(MeanOfMaximum(matrices));
            }
            throw new Exception("Invalid calculationType set in ruleset");
        }
示例#22
0
 public static bool CanBeExecuted(CalculationType type)
 {
     return (int)type == _currentIndex;
 }
示例#23
0
 public void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_characterType = (CharacterType)stream.ReadInt32();
     m_givePointsFor = (CalculationType)stream.ReadInt32();
     m_points        = stream.ReadInt32();
 }
示例#24
0
 public form_FieldName(DataTable table, CalculationType calculationType)
 {
     dataTable = table;
     calType   = calculationType;
     InitializeComponent();
 }
示例#25
0
 public double Execute(string path, CalculationType calcType)
 {
     return(Execute(path, calcType, InsertType));
 }
示例#26
0
 /// <summary>
 /// Kiểm tra ràng buộc loại tính toán trên cột
 /// </summary>
 /// <param name="column">Cột check</param>
 /// <param name="calculationType">Loại tính toán</param>
 /// <returns></returns>
 private static bool checkValidate(GridColumn column, CalculationType calculationType)
 {
     //Nếu cột là kiểu Text hay DateTime thì không chấp nhận phép tính SUM và AVERAGE
     if ((column.ColumnEdit == null || column.ColumnEdit is DevExpress.XtraEditors.Repository.RepositoryItemDateEdit)
         && (calculationType == CalculationType.SUM || calculationType == CalculationType.AVERAGE))
         return false;
     return true;
 }
        public async Task <IActionResult> Get([FromQuery] string numbers, char delimiter, CalculationType calcType)
        {
            //declare list of ints which we will use as input for the ICalculator's 'Calculate' method
            List <int> numbersList;

            //convert to list of int32 - throw BadRequest error if conversion fails
            try
            {
                numbersList = numbers.Split(delimiter).Select(Int32.Parse).ToList();
            }
            catch
            {   //unable to parse the numbers input - throw BadRequest 400 error
                return(BadRequest("Unable to proces the request, ensure you supply a list of delimited numbers, and the correct delimiter"));
            }

            //verify at least 2 numbers in the list
            if (numbersList.Count < 2)
            {
                return(BadRequest("at least 2 numbers are required"));
            }

            //perform the calculation based on the requested operation
            int result = 0;

            switch (calcType)
            {
            case CalculationType.Add:
                result = await _calculator.Calculate((x) => x.Sum(), numbersList);

                break;

            case CalculationType.Multiply:
                result = await _calculator.Calculate((x) => x.Aggregate((a, b) => a *b), numbersList);

                break;

            case CalculationType.Subtract:
                result = await _calculator.Calculate((x) => x.Aggregate((a, b) => a - b), numbersList);

                break;
            }

            return(Ok(result));
        }
示例#28
0
 /// <summary>
 /// Hiển thị thông tin tính toán (SUM, MIN, MAX, COUNT, AVERAGE) của 1 nhóm trên Grid
 /// + kiểm tra hợp lệ cột cần tính toán
 /// </summary>
 /// <param name="grid">GridView</param>
 /// <param name="column">GridColumn</param>
 public static void ShowGroupCalcInfo(GridView grid, GridColumn column, CalculationType calculationType)
 {
     if (calculationType == CalculationType.SUM)
     {
         if (checkValidate(column, CalculationType.SUM))
         {
             //column.Group();
             grid.GroupSummary.Add(new DevExpress.XtraGrid.GridGroupSummaryItem(
                                 DevExpress.Data.SummaryItemType.Sum, column.FieldName, column,
                                 "SUM={0}"));
         }
         else PLMessageBox.ShowErrorMessage(
             "Phép tính <Tổng cộng> không hợp lệ trên cột <" + column.Caption + ">.");
     }
     else if (calculationType == CalculationType.MIN)
     {
         if (checkValidate(column, CalculationType.MIN))
         {
             //column.Group();
             grid.GroupSummary.Add(new DevExpress.XtraGrid.GridGroupSummaryItem(
                                DevExpress.Data.SummaryItemType.Min, column.FieldName, column,
                                "MIN={0}"));
         }
         else PLMessageBox.ShowErrorMessage(
             "Phép tính <Giá trị nhỏ nhất> không hợp lệ trên cột <" + column.Caption + ">.");
     }
     else if (calculationType == CalculationType.MAX)
     {
         if (checkValidate(column, CalculationType.MAX))
         {
             //column.Group();
             grid.GroupSummary.Add(new DevExpress.XtraGrid.GridGroupSummaryItem(
                                DevExpress.Data.SummaryItemType.Max, column.FieldName, column,
                                "MAX={0}"));
         }
         else PLMessageBox.ShowErrorMessage(
             "Phép tính <Giá trị lớn nhất> không hợp lệ trên cột <" + column.Caption + ">.");
     }
     else if (calculationType == CalculationType.COUNT)
     {
         if (checkValidate(column, CalculationType.COUNT))
         {
             //column.Group();
             grid.GroupSummary.Add(new DevExpress.XtraGrid.GridGroupSummaryItem(
                                DevExpress.Data.SummaryItemType.Count, column.FieldName, column,
                                "NUM={0}"));
         }
         else PLMessageBox.ShowErrorMessage(
             "Phép tính <Số phần tử> không hợp lệ trên cột <" + column.Caption + ">.");
     }
     else if (calculationType == CalculationType.AVERAGE)
     {
         if (checkValidate(column, CalculationType.AVERAGE))
         {
             //column.Group();
             grid.GroupSummary.Add(new DevExpress.XtraGrid.GridGroupSummaryItem(
                                DevExpress.Data.SummaryItemType.Average, column.FieldName, column,
                                "AVG={0}"));
         }
         else PLMessageBox.ShowErrorMessage(
             "Phép tính <Trung bình> không hợp lệ trên cột <" + column.Caption + ">.");
     }
 }
示例#29
0
 partial void BtnDivide_Activated()
 {
     Calculate();
     calculation = CalculationType.Divide;
 }
示例#30
0
 public double Execute(CalculationType calcType, InsertionType insertType)
 {
     return(Execute(FilePath, calcType, insertType));
 }
示例#31
0
 partial void BtnMultiply_Activated()
 {
     Calculate();
     calculation = CalculationType.Multiply;
 }
示例#32
0
文件: Calculator.cs 项目: kblc/Test
        /// <summary>
        /// Calculate stored data
        /// </summary>
        /// <param name="data">Internal data storage</param>
        /// <param name="calcType">Calculate average data by each doctor or by each doctor's pacient</param>
        /// <param name="calcTimeType">Calculate results by any part of year (year/month/week/day)</param>
        /// <param name="excludeDoctorsWithoutPacients">Excludes from result doctors with no one pacient</param>
        /// <param name="excludePacientsWithoutMeasurements">Excludes from result pacients with one or no one measuremtns</param>
        /// <returns>Calculation result</returns>
        public IEnumerable<AnalysisModule.SimpleCalculationResult> Calculate(
            InternalData data,
            CalculationType calcType = CalculationType.ByDoctor,
            CalculationTimeType calcTimeType = CalculationTimeType.PerWeek,
            bool excludeDoctorsWithoutPacients = false,
            bool excludePacientsWithoutMeasurements = false)
        {
            if (data == null)
                throw new ArgumentNullException("data");
            if (data.Doctors == null)
                throw new ArgumentNullException("data.Doctors", "Feel 'Doctors' array before calling Calculation");
            if (data.Pacients == null)
                throw new ArgumentNullException("data.Pacients", "Feel 'Pacients' array before calling Calculation");
            if (data.Timestamps == null)
                throw new ArgumentNullException("data.Timestamps", "Feel 'Timestamps' array before calling Calculation");
            if (data.Measurements == null)
                throw new ArgumentNullException("data.Measurements", "Feel 'Measurements' array before calling Calculation");
            if (data.HeighComponent == null)
                throw new ArgumentNullException("data.HeighComponent", "Feel 'HeighComponent' array before calling Calculation");
            if (!data.Doctors.Any())
                throw new ArgumentException("You must feel doctors array before calling Calculation", "data.Doctors");

            var res = new List<AnalysisModule.SimpleCalculationResult>();

            var bigTableData =
                data.Doctors
                .LeftOuterJoin(data.Pacients, d => d.DoctorId, p => p.DoctorId, (d, p) => new { DoctorId = d.DoctorId, PacientId = p == null ? (long?)null : p.PacientId })
                .LeftOuterJoin(data.Measurements, i => i.PacientId, m => m.PacientId, (i, m) => new { i.DoctorId, i.PacientId, MeasurementId = m == null ? (long?)null : m.MeasurementId })
                .LeftOuterJoin(data.Timestamps, i => i.MeasurementId, t => t.MeasurementId, (i, t) => new { i.DoctorId, i.PacientId, i.MeasurementId, Timestamp = t == null ? (DateTime?)null : t.Timestamp })
                .LeftOuterJoin(data.HeighComponent
                    .Where(h => h.Height > 0
                        && !double.IsInfinity(h.Height)
                        && !double.IsNegativeInfinity(h.Height)
                        && !double.IsPositiveInfinity(h.Height)
                        && !double.IsNaN(h.Height)
                        ),
                    i => i.MeasurementId, hc => hc.MeasurementId, (i, hc) => new { i.DoctorId, i.PacientId, i.MeasurementId, i.Timestamp, Height = hc == null ? (double?)null : hc.Height })
                .ToArray();

            //Table generated. Group data by Doctor, Pacient and Measurement
            var doctors = bigTableData
                .GroupBy(i => i.DoctorId)
                .Select(g => new
                {
                    g.FirstOrDefault().DoctorId,
                    //Group data by pacient
                    Pacients = g.Where(p => p != null)
                        .GroupBy(g2 => g2.PacientId)
                        .Select(g2 => new
                        {
                            g2.FirstOrDefault().PacientId,
                            Measurements = g2
                                .Where(i => i.Height != null && i.Timestamp != null)
                                .OrderBy(m => m.Timestamp)
                                .ToArray()
                        })
                        .Select(g2 => new
                        {
                            g2.PacientId,
                            MeasurementsExists = g2.Measurements.Count() > 1,
                            Measurements = g2.Measurements.Count() > 1
                                ? Enumerable.Range(0, g2.Measurements.Count() - 1)
                                    .Select(i => new //Get measurement pairs for pacient
                                    {
                                        Start = g2.Measurements.ElementAt(i),
                                        End = g2.Measurements.ElementAt(i + 1)
                                    })
                                    .Select(i => new //Calc start and end measure data
                                    {
                                        HeightStart = i.Start.Height.Value,
                                        HeightEnd = i.End.Height.Value,
                                        TimestampStart = i.Start.Timestamp.Value,
                                        TimestampEnd = i.End.Timestamp.Value,
                                    })
                                    .Select(i => new //get height change by part of time
                                    {
                                        HeightChange = i.HeightEnd - i.HeightStart,
                                        TimeParts = GetTimePart((i.TimestampEnd - i.TimestampStart).TotalDays, calcTimeType),
                                    })
                                    .Select(i => i.HeightChange / i.TimeParts) //calc growth per week
                                    .ToArray()
                                : Enumerable.Empty<double>().ToArray() //return empty array if no one or one only measurement
                        })
                        .Select(g2 => new
                            {
                                g2.PacientId,
                                g2.MeasurementsExists,
                                //g2.Measurements //!!! enable to debug
                                MeanRateGrowhPerTimePart = g2.MeasurementsExists ? g2.Measurements.Average() : 0
                            })
                })
                //Exclude from data pacients with one or less measurements (is setted)
                .Select(i => new
                    {
                        i.DoctorId,
                        Pacients = i.Pacients
                            .Where(p => p.PacientId != null)
                            .Where(n => !excludePacientsWithoutMeasurements || n.MeasurementsExists)
                            .ToArray()
                    })
                //Exclude from data doctors without pacients (is setted)
                .Where(i => !excludeDoctorsWithoutPacients || i.Pacients.Any())
                .ToArray()
                ;

            //Get enum description attribute
            var perName = calcTimeType.ToString();
            var memInfo = calcTimeType.GetType().GetMember(perName).FirstOrDefault();
            if (memInfo != null)
            {
                var descrAttr = memInfo.GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault() as DescriptionAttribute;
                if (descrAttr != null)
                    perName = "per " + descrAttr.Description;
            }

            //generate result from data
            foreach (var doc in doctors)
            {
                switch (calcType)
                {
                    case CalculationType.ByPacient:
                        res.AddRange(
                            doc.Pacients.Select(i => new AnalysisModule.SimpleCalculationResult()
                            {
                                Result = i.MeanRateGrowhPerTimePart,
                                AnalysisName = string.Format("{0} {3} for pacient (id:{1}) of doctor (id:{2})", CalcTaskName, i.PacientId, doc.DoctorId, perName)
                            }));
                        break;

                    case CalculationType.ByDoctor:
                        res.Add(new AnalysisModule.SimpleCalculationResult()
                        {
                            Result = doc.Pacients.Any() ? doc.Pacients.Average(p => p.MeanRateGrowhPerTimePart) : 0,
                            AnalysisName = string.Format("{0} {2} for doctor (id:{1})", CalcTaskName, doc.DoctorId, perName)
                        });
                        break;
                }
            }
            return res;
        }
示例#33
0
 partial void BtnMinus_Activated()
 {
     Calculate();
     calculation = CalculationType.Subtract;
 }
示例#34
0
 public OreCalculator(CalculationType type, float oreConversionRate)
 {
     this.type = type;
     this.oreConversionRate = oreConversionRate;
     stripper = new MarketDataStripper();
 }
示例#35
0
 partial void BtnAdd_Activated()
 {
     Calculate();
     calculation = CalculationType.Add;
 }
示例#36
0
        public void Create(DataCreationService dataCreationService, IWorkspace workspace)
        {
            this._workspace = workspace;
            var saleAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Sales)
            };
            var receivableAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Receiveable)
            };
            var paymentAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Payment)
            };
            var discountAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Discount)
            };
            var customerAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Customer)
            };

            _workspace.Add(receivableAccountType);
            _workspace.Add(saleAccountType);
            _workspace.Add(paymentAccountType);
            _workspace.Add(discountAccountType);
            _workspace.Add(customerAccountType);
            _workspace.CommitChanges();

            var customerEntityType = new EntityType {
                Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name
            };

            customerEntityType.EntityCustomFields.Add(new EntityCustomField {
                EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone
            });
            customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]";
            //var tableEntityType = new EntityType { Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name };

            _workspace.Add(customerEntityType);
            //_workspace.Add(tableEntityType);

            _workspace.CommitChanges();

            var accountScreen = new AccountScreen {
                Name = Resources.General
            };

            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40
            });
            _workspace.Add(accountScreen);

            var defaultSaleAccount = new Account {
                AccountTypeId = saleAccountType.Id, Name = Resources.Sales
            };
            var defaultReceivableAccount = new Account {
                AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables
            };
            var cashAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Cash
            };
            var creditCardAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard
            };
            var voucherAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher
            };
            var defaultDiscountAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Discount
            };
            var defaultRoundingAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Rounding
            };

            _workspace.Add(defaultSaleAccount);
            _workspace.Add(defaultReceivableAccount);
            _workspace.Add(defaultDiscountAccount);
            _workspace.Add(defaultRoundingAccount);
            _workspace.Add(cashAccount);
            _workspace.Add(creditCardAccount);
            _workspace.Add(voucherAccount);

            _workspace.CommitChanges();

            var discountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Discount),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultDiscountAccount.Id
            };

            var roundingTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Rounding),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultRoundingAccount.Id
            };

            var saleTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Sale),
                SourceAccountTypeId    = saleAccountType.Id,
                TargetAccountTypeId    = receivableAccountType.Id,
                DefaultSourceAccountId = defaultSaleAccount.Id,
                DefaultTargetAccountId = defaultReceivableAccount.Id
            };

            var paymentTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Payment),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerAccountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.AccountTransaction),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = customerAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id
            };

            var customerCashPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CashPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerCreditCardPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = creditCardAccount.Id
            };

            _workspace.Add(saleTransactionType);
            _workspace.Add(paymentTransactionType);
            _workspace.Add(discountTransactionType);
            _workspace.Add(roundingTransactionType);
            _workspace.Add(customerAccountTransactionType);
            _workspace.Add(customerCashPaymentType);
            _workspace.Add(customerCreditCardPaymentType);

            var discountService = new CalculationType
            {
                AccountTransactionType = discountTransactionType,
                CalculationMethod      = 0,
                DecreaseAmount         = true,
                Name = Resources.Discount
            };

            var roundingService = new CalculationType
            {
                AccountTransactionType = roundingTransactionType,
                CalculationMethod      = 2,
                DecreaseAmount         = true,
                IncludeTax             = true,
                Name = Resources.Round
            };

            var discountSelector = new CalculationSelector {
                Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign
            };

            discountSelector.CalculationTypes.Add(discountService);
            discountSelector.AddCalculationSelectorMap();

            var roundingSelector = new CalculationSelector {
                Name = Resources.Round, ButtonHeader = Resources.Round
            };

            roundingSelector.CalculationTypes.Add(roundingService);
            roundingSelector.AddCalculationSelectorMap();


            _workspace.Add(discountService);
            _workspace.Add(roundingService);
            _workspace.Add(discountSelector);
            _workspace.Add(roundingSelector);

            var screen = new ScreenMenu();

            _workspace.Add(screen);

            var ticketNumerator = new Numerator {
                Name = Resources.TicketNumerator
            };

            _workspace.Add(ticketNumerator);

            var orderNumerator = new Numerator {
                Name = Resources.OrderNumerator
            };

            _workspace.Add(orderNumerator);



            _workspace.CommitChanges();

            var ticketType = new TicketType
            {
                Name                = Resources.Ticket,
                TicketNumerator     = ticketNumerator,
                OrderNumerator      = orderNumerator,
                SaleTransactionType = saleTransactionType,
                ScreenMenuId        = screen.Id,
            };

            ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment {
                EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20
            });

            var cashPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = cashAccount,
                Name    = cashAccount.Name
            };

            cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var creditCardPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = creditCardAccount,
                Name    = creditCardAccount.Name
            };

            creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var voucherPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = voucherAccount,
                Name    = voucherAccount.Name
            };

            voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var accountPayment = new PaymentType
            {
                AccountTransactionType = customerAccountTransactionType,
                Name = Resources.CustomerAccount
            };

            accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            _workspace.Add(cashPayment);
            _workspace.Add(creditCardPayment);
            _workspace.Add(voucherPayment);
            _workspace.Add(accountPayment);
            _workspace.Add(ticketType);

            var warehouseType = new WarehouseType {
                Name = Resources.Warehouses
            };

            _workspace.Add(warehouseType);
            _workspace.CommitChanges();

            var localWarehouse = new Warehouse
            {
                Name            = Resources.LocalWarehouse,
                WarehouseTypeId = warehouseType.Id
            };

            _workspace.Add(localWarehouse);
            _workspace.CommitChanges();

            var department = new Department
            {
                Name         = Resources.Retail,
                TicketTypeId = ticketType.Id,
                WarehouseId  = localWarehouse.Id
            };

            _workspace.Add(department);

            var transactionType = new InventoryTransactionType
            {
                Name = Resources.PurchaseTransactionType,
                TargetWarehouseTypeId    = warehouseType.Id,
                DefaultTargetWarehouseId = localWarehouse.Id
            };

            _workspace.Add(transactionType);

            var transactionDocumentType = new InventoryTransactionDocumentType
            {
                Name = Resources.PurchaseTransaction,
                InventoryTransactionType = transactionType
            };

            _workspace.Add(transactionDocumentType);

            AddDefaultUsers();

            PrinterTemplate customerReceiptTemplate = AddDefaultPrintersAndTerminal();

            new RuleGenerator().GenerateSystemRules(_workspace);

            dataCreationService.ImportMenus(screen);
            //dataCreationService.ImportTableResources(tableEntityType, ticketType);
            //RL - import data and associate with an entity.
            //C:\Users\Roy Lawson\source\repos\sdselite\SambaPOS-3\Samba.Presentation\bin\Debug\Imports

            var customerScreen = new EntityScreen {
                Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id
            };

            customerScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerScreen);

            var customerTicketScreen = new EntityScreen {
                Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id
            };

            customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerTicketScreen);

            var customerCashDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.Cash),
                ButtonHeader        = Resources.Cash,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCashDocument.AddAccountTransactionDocumentTypeMap();
            customerCashDocument.TransactionTypes.Add(customerCashPaymentType);

            var customerCreditCardDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.CreditCard),
                ButtonHeader        = Resources.CreditCard,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCreditCardDocument.AddAccountTransactionDocumentTypeMap();
            customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType);

            _workspace.Add(customerCashDocument);
            _workspace.Add(customerCreditCardDocument);
        }
示例#37
0
 partial void BtnEqual_Activated()
 {
     Calculate();
     calculation = CalculationType.None;
 }