Exemplo n.º 1
0
 private void buttonAddEdit_Click(object sender, EventArgs e)
 {
     if (Mode == 0)
     {
         try
         {
             Books.Add(new Book(NameTB.Text, AutorTB.Text, GenteCB.Text, TypeCB.Text, PublishingHouseTB.Text, int.Parse(YearTB.Text), float.Parse(PriceTB.Text), int.Parse(NumberTB.Text)));
         }
         catch (Exception)
         {
             MessageBox.Show("Некорректные данные!");
             return;
         }
         this.Close();
         Main.RedrawList();
         Main.SendListUpdateToServer();
     }
     if (Mode == 1)
     {
         Books[EditIndex] = new Book(NameTB.Text, AutorTB.Text, GenteCB.Text, TypeCB.Text, PublishingHouseTB.Text, int.Parse(YearTB.Text), float.Parse(PriceTB.Text), int.Parse(NumberTB.Text));
         this.Close();
         Main.RedrawList();
         Main.SendListUpdateToServer();
     }
 }
Exemplo n.º 2
0
        private void buttonSale_Click(object sender, EventArgs e)
        {
            using (StreamWriter check = new StreamWriter("check.txt", true, System.Text.Encoding.Default))
            {
                check.WriteLine("------------------------------------------------------");
                foreach (Book book in Main.BooksInCart)
                {
                    check.WriteLine(book.Name + ", " + book.NumberForSale.ToString() + "экземпляров, " + book.PriceAll.ToString());
                }
                check.WriteLine("Итого: " + PriceSum().ToString());
            }

            foreach (Book book in Main.BooksInCart)
            {
                book.Number           = book.Number - book.NumberForSale;
                book.NumberForSale    = 0;
                book.PriceAll         = 0;
                book.SubItems[7].Text = book.Number.ToString();
            }

            Main.BooksInCart.Clear();
            RedrawCartList();
            Main.RedrawList();
            Main.SendListUpdateToServer();
        }