Esempio n. 1
0
 public FrmAuctionReceipt(PersonPickup purchaser, List <ArtShowItem> items, string source, string reference)
 {
     InitializeComponent();
     Purchaser = purchaser;
     Items     = items;
     Source    = source;
     Reference = reference;
 }
        public FrmSellAuctionItemsToPerson(PersonPickup person)
        {
            InitializeComponent();
            Person         = person;
            StripeFirstTry = true;
            Text           = "Items Won by " + Person.Name;
            LblTaxes.Text  = "Taxes @ " + decimal.Round(Program.TaxRate * 100, 1) + "%";

            var payload = "action=GetItemsForPickup&id=" + Person.BadgeID + "&year=" + Program.Year.ToString();
            var data    = Encoding.ASCII.GetBytes(payload);

            var request = WebRequest.Create(Program.URL + "/functions/artQuery.php");

            request.ContentLength = data.Length;
            request.ContentType   = "application/x-www-form-urlencoded";
            request.Method        = "POST";
            using (var stream = request.GetRequestStream())
                stream.Write(data, 0, data.Length);

            var response = (HttpWebResponse)request.GetResponse();
            var results  = new StreamReader(response.GetResponseStream()).ReadToEnd();

            Items = JsonConvert.DeserializeObject <List <ArtShowItem> >(results);

            TotalPrice = 0;
            TotalDue   = 0;
            decimal taxibleAmount = 0;

            TotalTax = 0;
            foreach (var showItem in Items)
            {
                var item = new ListViewItem {
                    Text = showItem.LocationCode
                };
                item.SubItems.Add(showItem.ShowNumber.ToString());
                item.SubItems.Add(showItem.Title);
                item.SubItems.Add(showItem.ArtistDisplayName);
                item.SubItems.Add(((decimal)showItem.FinalSalePrice).ToString("C"));
                item.Tag = showItem;
                LstItems.Items.Add(item);
                TotalPrice += (decimal)showItem.FinalSalePrice;
                if (showItem.IsCharity)
                {
                    item.BackColor = Color.LightGreen;
                }
                else
                {
                    taxibleAmount += (decimal)showItem.FinalSalePrice;
                }
            }
            TotalTax            = taxibleAmount * Program.TaxRate;
            TotalTax            = decimal.Round(TotalTax, 2);
            TotalDue            = TotalPrice + TotalTax;
            LblAmountDue.Text   = TotalPrice.ToString("C");
            LblAmountTax.Text   = TotalTax.ToString("C");
            LblAmountTotal.Text = TotalDue.ToString("C");
        }