コード例 #1
0
        internal async Task SetInvoice(int data)
        {
            if (data > 0)
            {
                var invoice = await MainVM.InvoiceCollections.GetItemById(data);

                if (invoice != null)
                {
                    this.CreateDate           = invoice.CreateDate;
                    this.Customer             = invoice.Customer;
                    this.CustomerId           = invoice.CustomerId;
                    this.CustomerSelectedItem = invoice.Customer;
                    this.DeadLine             = invoice.DeadLine;
                    this.DeliveryDate         = invoice.DeliveryDate;
                    this.Id             = invoice.Id;
                    this.InvoicePayType = invoice.InvoicePayType;
                    this.InvoiceStatus  = invoice.InvoiceStatus;
                    this.IsDelivery     = invoice.IsDelivery;
                    this.Number         = invoice.Number;
                    this.PaidDate       = invoice.PaidDate;
                    this.ReciveDate     = invoice.ReciveDate;
                    this.ReciverBy      = invoice.ReciverBy;
                    this.Tax            = invoice.Tax;
                    await Task.Delay(3000);

                    foreach (var item in invoice.Invoicedetail)
                    {
                        item.IsSelected = true;
                        this.Invoicedetail.Add(item);
                    }

                    this.SourceView.Refresh();
                }
            }
            else
            {
                this.Invoicedetail.Clear();
                this.CreateDate           = DateTime.Now;
                this.Customer             = null;
                this.CustomerId           = 0;
                this.CustomerSelectedItem = null;
                this.DeadLine             = CreateDate.AddMonths(1);
                this.DeliveryDate         = null;
                this.Id             = 0;
                this.InvoicePayType = InvoicePayType.None;
                this.InvoiceStatus  = InvoiceStatus.None;
                this.IsDelivery     = false;
                this.Number         = 0;
                this.PaidDate       = null;
                this.ReciveDate     = null;
                this.ReciverBy      = string.Empty;
                this.Tax            = 0;
                await Task.Delay(3000);

                this.SourceView.Refresh();
            }
        }
コード例 #2
0
ファイル: Invoice.cs プロジェクト: RegardtV/csharp-practical
        /// <summary>
        /// Adds item to invoice items list if within valid range of dates
        /// </summary>
        /// <param name="item">Item to add to items list</param>
        public void AddItem(InvoiceItem item)
        {
            var minDate             = CreateDate.AddMonths(-1);
            var daysInPreviousMonth = DateTime.DaysInMonth(minDate.Year, minDate.Month);

            minDate = new DateTime(minDate.Year, minDate.Month, daysInPreviousMonth - 5);
            if (item.ServiceDate < minDate || item.ServiceDate >= CreateDate)
            {
                ValidationMessage = "Item falls outside the range of valid dates for this invoice";
            }
            else
            {
                Items.Add(item);
            }
        }