Example #1
0
 private decimal ItemCost(SInventory I)
 {
     if (I.Quantity > 1 && I.CostPerUnit)
     {
         return(I.Cost * I.Quantity);
     }
     else
     {
         return(I.Cost);
     }
 }
Example #2
0
        private void BTNWrite_Click(object sender, EventArgs e)
        {
            CBCompany.Text = Main.CheckCompanies(CBCompany.Text);

            SInventory I = new SInventory(TBName.Text, NUCost.Value,
                                          int.Parse(NUQuantity.Value.ToString()), ChBCostPerUnit.Checked,
                                          DTPPurchasedOn.Value, CBCategory.Text,
                                          CBCompany.Text, ChBToInsure.Checked,
                                          GetWarrantyDuration());

            TheInventory.Add(I);
            if (BTNWrite.Text == "Data\\Update")
            {
                TheInventory.RemoveAt(LBInventory.SelectedIndex);
            }
            SaveInventory();
            LoadInventory();
            LoadList();
        }
Example #3
0
        private void LoadItem(object sender, EventArgs e)
        {
            SInventory I = TheInventory[LBInventory.SelectedIndex];

            TBName.Text            = I.Name;
            NUCost.Value           = I.Cost;
            NUQuantity.Value       = I.Quantity;
            ChBCostPerUnit.Checked = I.CostPerUnit;
            DTPPurchasedOn.Value   = I.PurchasedOn;
            CBCompany.Text         = I.Company;
            CBCategory.Text        = I.Category;
            ChBToInsure.Checked    = I.ToInsure;

            if (I.Warranty.HasValue)
            {
                ChBWarranty.Checked    = true;
                DTPWarrantyStart.Value = I.Warranty.Value.Start;
                DTPWarrantyEnd.Value   = I.Warranty.Value.End;
            }
            BTNWrite.Text = "Update";
        }