Beispiel #1
0
 internal async void OnCurrentAsycudaSalesAllocationsExIDChanged(object sender, NotificationEventArgs <string> e)
 {
     using (AsycudaSalesAllocationsExRepository ctx = new AsycudaSalesAllocationsExRepository())
     {
         CurrentAsycudaSalesAllocationsEx = await ctx.GetAsycudaSalesAllocationsEx(e.Data).ConfigureAwait(continueOnCapturedContext: false);
     }
     NotifyPropertyChanged(m => CurrentAsycudaSalesAllocationsEx);
 }
        public static async Task <IEnumerable <SaleReportLine> > GetDocumentSalesReport(int ASYCUDA_Id)
        {
            try
            {
                using (var ctx = new AsycudaSalesAllocationsExRepository())
                {
                    var alst =
                        (await ctx.GetAsycudaSalesAllocationsExsByExpression(string.Format("xASYCUDA_Id == {0} " +
                                                                                           "&& EntryDataDetailsId != null " +
                                                                                           "&& PreviousItem_Id != null" +
                                                                                           "&& pRegistrationDate != null",
                                                                                           ASYCUDA_Id))
                         .ConfigureAwait(false)).ToList();
                    if (alst.Count <= 0)
                    {
                        return(null);
                    }
                    var d =
                        alst.Where(x => x.xLineNumber != null)
                        .OrderBy(s => s.xLineNumber)
                        .ThenBy(s => s.InvoiceNo)
                        .Select(s => new SaleReportLine
                    {
                        Line            = Convert.ToInt32(s.xLineNumber),
                        Date            = Convert.ToDateTime(s.InvoiceDate),
                        InvoiceNo       = s.InvoiceNo,
                        CustomerName    = s.CustomerName,
                        ItemNumber      = s.ItemNumber,
                        ItemDescription = s.ItemDescription,
                        TariffCode      = s.TariffCode,
                        SalesFactor     = Convert.ToDouble(s.SalesFactor),
                        SalesQuantity   = Convert.ToDouble(s.QtyAllocated),

                        xQuantity          = Convert.ToDouble(s.xQuantity),// Convert.ToDouble(s.QtyAllocated),
                        Price              = Convert.ToDouble(s.Cost),
                        SalesType          = s.DutyFreePaid,
                        GrossSales         = Convert.ToDouble(s.TotalValue),
                        PreviousCNumber    = s.pCNumber,
                        PreviousLineNumber = s.pLineNumber.ToString(),
                        PreviousRegDate    = Convert.ToDateTime(s.pRegistrationDate).ToShortDateString(),
                        CIFValue           =
                            (Convert.ToDouble(s.Total_CIF_itm) / Convert.ToDouble(s.pQuantity)) *
                            Convert.ToDouble(s.QtyAllocated),
                        DutyLiablity =
                            (Convert.ToDouble(s.DutyLiability) / Convert.ToDouble(s.pQuantity)) *
                            Convert.ToDouble(s.QtyAllocated)
                    }).Distinct();



                    return(new ObservableCollection <SaleReportLine>(d));
                }
            }
            catch (Exception Ex)
            {
            }
            return(null);
        }
        private async void OnAsycudaSalesAllocationsExsFilterExpressionChangetals(object sender, SimpleMvvmToolkit.NotificationEventArgs <string> e)
        {
            using (var ctx = new AsycudaSalesAllocationsExRepository())
            {
                TotalTotalValue = await ctx.SumNav(e.Data, vloader.NavigationExpression, "TotalValue").ConfigureAwait(false);

                TotalAllocatedValue = await ctx.SumNav(e.Data, vloader.NavigationExpression, "AllocatedValue").ConfigureAwait(false);
            }
        }
        public async Task SelectAll()
        {
            IEnumerable <AsycudaSalesAllocationsEx> lst = null;

            using (var ctx = new AsycudaSalesAllocationsExRepository())
            {
                lst = await ctx.GetAsycudaSalesAllocationsExsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            SelectedAsycudaSalesAllocationsExs = new ObservableCollection <AsycudaSalesAllocationsEx>(lst);
        }
Beispiel #5
0
        public IList <AsycudaSalesAllocationsEx> LoadRange(int startIndex, int count, SortDescriptionCollection sortDescriptions, out int overallCount)
        {
            try
            {
                if (FilterExpression == null)
                {
                    FilterExpression = "All";
                }
                using (var ctx = new AsycudaSalesAllocationsExRepository())
                {
                    var r = ctx.LoadRange(startIndex, count, FilterExpression, navExp, IncludesLst);
                    overallCount = r.Result.Item2;

                    return(r.Result.Item1.ToList());
                }
            }
            catch (Exception ex)
            {
                StatusModel.Message(ex.Message);
                overallCount = 0;
                return(new List <AsycudaSalesAllocationsEx>());
            }
        }
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <AsycudaSalesAllocationsEx> lst = null;

            using (var ctx = new AsycudaSalesAllocationsExRepository())
            {
                lst = await ctx.GetAsycudaSalesAllocationsExsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <AsycudaSalesAllocationsExExcelLine, List <AsycudaSalesAllocationsExExcelLine> >
            {
                dataToPrint = lst.Select(x => new AsycudaSalesAllocationsExExcelLine
                {
                    InvoiceDate       = x.InvoiceDate,
                    InvoiceNo         = x.InvoiceNo,
                    SANumber          = Convert.ToInt32(x.SANumber),
                    ItemNumber        = x.ItemNumber,
                    ItemDescription   = x.ItemDescription,
                    DutyFreePaid      = x.DutyFreePaid,
                    TaxAmount         = x.TaxAmount,
                    Status            = x.Status,
                    SalesQuantity     = x.SalesQuantity,
                    SalesCost         = x.Cost,
                    SalesQtyAllocated = x.SalesQtyAllocated,
                    TotalSalesValue   = x.TotalValue,
                    QtyAllocated      = x.QtyAllocated,
                    AllocatedValue    = x.AllocatedValue,

                    pReferenceNumber  = x.pReferenceNumber,
                    pCNumber          = x.pCNumber,
                    pLineNumber       = x.pLineNumber,
                    pRegistrationDate = x.pRegistrationDate,
                    pExpiryDate       = x.pExpiryDate,
                    pIsAssessed       = x.pIsAssessed,
                    pQuantity         = x.pQuantity,
                    pQtyAllocated     = x.pQtyAllocated,
                    PiQuantity        = x.PiQuantity,
                    Total_CIF_itm     = x.Total_CIF_itm,
                    DutyLiability     = x.DutyLiability,



                    xReferenceNumber  = x.xReferenceNumber,
                    xCNumber          = x.xCNumber,
                    xLineNumber       = x.xLineNumber,
                    xRegistrationDate = x.xRegistrationDate,


                    DoNotAllocateSales         = x.DoNotAllocateSales,
                    DoNotAllocatePreviousEntry = x.DoNotAllocatePreviousEntry,

                    TariffCode = x.TariffCode,
                    Invalid    = x.Invalid,
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }