Пример #1
0
 protected void Update_Click(Object sender, EventArgs e)
 {
     Sku_Label.BackColor    = Form.DefaultBackColor;
     change_Label.BackColor = Form.DefaultBackColor;
     SendAmazon.BackColor   = Form.DefaultBackColor;
     Total.BackColor        = Form.DefaultBackColor;
     View.BackColor         = Form.DefaultBackColor;
     if (View.Checked && SKU_Entry.Text != "")
     {
         TreeNode data = inventory.search(SKU_Entry.Text);
         output.Text = "SKU: " + data.SKU + "\nDescription: " + data.Description + "\nPrice: " + string.Format("{0:C}", data.Price) + "\nTotal Quantity: " + data.Total + "\nTotal at Amazon: " + data.Amazon.ToString();
         double totalprice = data.Total * data.Price;
         output.Text += "\nIn Garage: " + data.garage.ToString() + "\nTotal Sold: " + data.sold + "\nTotal Invested: " + string.Format("{0:C}", totalprice);
     }
     else
     {
         int  result  = 0;
         bool checker = int.TryParse(Change_Total.Text, out result);
         if (SKU_Entry.Text != "" && Change_Total.Text != "" && (SendAmazon.Checked || Total.Checked || View.Checked || total_Sold.Checked) && checker)
         {
             if (Total.Checked)
             {
                 if (remove.Checked)
                 {
                     inventory.AddTotal(SKU_Entry.Text, int.Parse(Change_Total.Text) * -1);
                     inventory.AddGarage(SKU_Entry.Text, int.Parse(Change_Total.Text) * -1);
                 }
                 else
                 {
                     inventory.AddTotal(SKU_Entry.Text, int.Parse(Change_Total.Text));
                     inventory.AddGarage(SKU_Entry.Text, int.Parse(Change_Total.Text));
                 }
                 TreeNode data = inventory.search(SKU_Entry.Text);
                 output.Text = "SKU: " + data.SKU + "\nDescription: " + data.Description + "\nPrice: " + string.Format("{0:C}", data.Price) + "\nTotal Quantity: " + data.Total.ToString() + "\nTotal at Amazon: " + data.Amazon.ToString();
                 double totalprice = data.Total * data.Price;
                 output.Text += "\nIn Garage: " + data.garage + "\nTotal Sold: " + data.sold + "\nTotal Invested: " + string.Format("{0:C}", totalprice);
             }
             else if (SendAmazon.Checked)
             {
                 if (remove.Checked)
                 {
                     inventory.AddAmazon(SKU_Entry.Text, int.Parse(Change_Total.Text) * -1);
                     inventory.AddGarage(SKU_Entry.Text, int.Parse(Change_Total.Text));
                 }
                 else
                 {
                     inventory.AddAmazon(SKU_Entry.Text, int.Parse(Change_Total.Text));
                     inventory.AddGarage(SKU_Entry.Text, int.Parse(Change_Total.Text) * -1);
                 }
                 TreeNode data = inventory.search(SKU_Entry.Text);
                 output.Text = "SKU: " + data.SKU + "\nDescription: " + data.Description + "\nPrice: " + string.Format("{0:C}", data.Price) + "\nTotal Quantity: " + data.Total.ToString() + "\nTotal at Amazon: " + data.Amazon.ToString();
                 double totalprice = data.Total * data.Price;
                 output.Text += "\nIn Garage: " + data.garage.ToString() + "\nTotal Sold: " + data.sold.ToString() + "\nTotal Invested: " + string.Format("{0:C}", totalprice);
             }
             else if (total_Sold.Checked)
             {
                 if (remove.Checked)
                 {
                     inventory.AddSold(SKU_Entry.Text, int.Parse(Change_Total.Text) * -1, true);
                     inventory.AddGarage(SKU_Entry.Text, int.Parse(Change_Total.Text));
                 }
                 else
                 {
                     inventory.AddSold(SKU_Entry.Text, int.Parse(Change_Total.Text), false);
                     inventory.AddAmazon(SKU_Entry.Text, int.Parse(Change_Total.Text) * -1);
                 }
                 TreeNode data = inventory.search(SKU_Entry.Text);
                 output.Text = "SKU: " + data.SKU + "\nDescription: " + data.Description + "\nPrice: " + string.Format("{0:C}", data.Price) + "\nTotal Quantity: " + data.Total.ToString() + "\nTotal at Amazon: " + data.Amazon.ToString();
                 double totalprice = data.Total * data.Price;
                 output.Text += "\nIn Garage: " + data.garage.ToString() + "\nTotal Sold: " + data.sold.ToString() + "\nTotal Invested: " + string.Format("{0:C}", totalprice);
             }
         }
         else
         {
             if (SKU_Entry.Text == "" && View.Checked)
             {
                 Sku_Label.BackColor = Color.Red;
             }
             if (Change_Total.Text == "" || checker)
             {
                 change_Label.BackColor = Color.Red;
             }
         }
     }
     Change_Total.Text = "";
     remove.Checked    = false;
     View.Checked      = true;
     SKU_Entry.Focus();
 }