Beispiel #1
0
        public MainViewModel()
        {
            CheckRoles();
            TitleText = "PinnaStock, Stock Management System (" +
                        Singleton.User.UserName + ") - " +
                        DateTime.Now.ToString("dd/MM/yyyy") + " (" +
                        ReportUtility.getEthCalendarFormated(DateTime.Now, "-") + ") - " +
                        new ProductActivationDTO().BiosSn;

            if (UserRoles.OnHandInventory == "Visible")
            {
                HeaderText = "OnHand Inventories";
                OnHandInventoryViewModel.LoadData = true;
                CurrentViewModel = OnHandInventoryViewModel;
            }
            else if (UserRoles.Sales == "Visible")
            {
                HeaderText = "Sales Management";
                TransactionsViewModel.TransactionType = TransactionTypes.Sale;
                CurrentViewModel = TransactionsViewModel;
            }
            DashBoardViewCommand         = new RelayCommand(ExecuteDashBoardViewCommand);
            PhysicalInventoryViewCommand = new RelayCommand(ExecutePhysicalInventoriesViewCommand);
            ItemsMovementViewCommand     = new RelayCommand(ItemsMovementsViewCommand);
            OnHandInventoryViewCommand   = new RelayCommand(ExecuteOnHandInventoriesViewCommand);
            SalesViewCommand             = new RelayCommand(ExecuteSalesViewCommand);
            PurchasesViewCommand         = new RelayCommand(ExecutePurchasesViewCommand);
        }
        public TransactionDataSet GetListDataSet()
        {
            var myDataSet = new TransactionDataSet();

            try
            {
                #region Fields
                var brCode            = new BarcodeProcess();
                var tranNumberbarcode = ImageToByteArray(brCode.GetBarcode(SelectedTransaction.TransactionNumber, 320, 40, true), ImageFormat.Bmp);

                var tax = Convert.ToDecimal((SelectedTransaction.TotalCost * (Singleton.Setting.TaxPercent * (decimal)0.01)).ToString("N2"));

                #endregion

                #region Header
                myDataSet.TransactionHeader.Rows.Add(
                    SelectedTransaction.FiscalNumber,
                    tranNumberbarcode,
                    SelectedTransaction.Warehouse.DisplayName,
                    SelectedTransaction.BusinessPartner.DisplayName,
                    SelectedTransaction.BusinessPartner.TinNumber,
                    SelectedTransaction.BusinessPartner.VatNumber,
                    SelectedTransaction.TransactionDateString + "(" +
                    ReportUtility.getEthCalendarFormated(SelectedTransaction.TransactionDate, "/") + ")",
                    SelectedTransaction.Status,
                    SelectedTransaction.TotalCost,
                    EnumUtil.GetEnumDesc(Singleton.Setting.TaxType) + " (" + Singleton.Setting.TaxPercent + "%)",
                    tax,
                    SelectedTransaction.TotalCost + tax,
                    "linknumber1"
                    );
                #endregion

                #region Client Address

                myDataSet.ClientDetail.Rows.Add(
                    SelectedTransaction.Warehouse.Header,
                    SelectedTransaction.Warehouse.Footer,
                    SelectedTransaction.Warehouse.Address.StreetAddress,
                    SelectedTransaction.Warehouse.Address.SubCity,
                    SelectedTransaction.Warehouse.Address.Kebele,
                    SelectedTransaction.Warehouse.Address.HouseNumber,
                    SelectedTransaction.Warehouse.Address.Telephone,
                    SelectedTransaction.Warehouse.Address.Mobile,
                    SelectedTransaction.Warehouse.Address.Fax,
                    SelectedTransaction.Warehouse.Address.PrimaryEmail,
                    SelectedTransaction.Warehouse.Address.AlternateEmail,
                    SelectedTransaction.Warehouse != null ? SelectedTransaction.Warehouse.TinNumber : "",
                    SelectedTransaction.Warehouse != null ? SelectedTransaction.Warehouse.VatNumber : "",
                    PaymentMethod, PaymentMethod, "", "linknumber1");
                #endregion

                #region BPAddress
                myDataSet.BPAddress.Rows.Add(
                    SelectedTransaction.BusinessPartner.Addresses.FirstOrDefault().Address.StreetAddress,
                    SelectedTransaction.BusinessPartner.Addresses.FirstOrDefault().Address.SubCity,
                    SelectedTransaction.BusinessPartner.Addresses.FirstOrDefault().Address.Kebele,
                    SelectedTransaction.BusinessPartner.Addresses.FirstOrDefault().Address.HouseNumber,
                    SelectedTransaction.BusinessPartner.Addresses.FirstOrDefault().Address.Telephone,
                    SelectedTransaction.BusinessPartner.Addresses.FirstOrDefault().Address.Mobile,
                    SelectedTransaction.BusinessPartner.Addresses.FirstOrDefault().Address.Fax,
                    SelectedTransaction.BusinessPartner.Addresses.FirstOrDefault().Address.PrimaryEmail,
                    SelectedTransaction.BusinessPartner.Addresses.FirstOrDefault().Address.AlternateEmail,
                    "linknumber1");
                #endregion

                #region Lines
                var serNo = 1;
                foreach (var line in TransactionLines)
                {
                    myDataSet.TransactionLine.Rows.Add(
                        serNo,
                        line.Item.ItemCode,
                        string.IsNullOrEmpty(line.Item.Description) ? line.Item.DisplayName : line.Item.Description,
                        "",
                        line.Item.Category.DisplayName,
                        line.Item.UnitOfMeasure.DisplayName,
                        line.EachPrice,
                        line.Unit,
                        line.LinePrice,
                        0,
                        "linknumber1");

                    serNo++;
                }
                #endregion
            }
            catch (Exception exception)
            {
                MessageBox.Show("Can't get data for the report"
                                + Environment.NewLine + exception.Message, "Can't get data", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }

            return(myDataSet);
        }