Beispiel #1
0
 private void ButtonAddToCart_Click(object sender, EventArgs e)
 {
     for (int i = 0; i <= DataGridViewItemsInStock.Rows.Count - 1; i++)
     {
         bool RowExist    = false;
         bool CheckedCell = Convert.ToBoolean(DataGridViewItemsInStock.Rows[i].Cells[0].Value);
         if (CheckedCell == true)
         {
             DataGridViewRow Row = DataGridViewItemsInStock.Rows[i];
             if (DataGridViewCart.Rows.Count != 0)
             {
                 for (int j = 0; j < DataGridViewCart.Rows.Count - 1; j++)
                 {
                     if (Row.Cells[2].Value.ToString() == DataGridViewCart.Rows[j].Cells[1].Value.ToString())
                     {
                         RowExist = true;
                         break;
                     }
                 }
                 if (RowExist == false)
                 {
                     DataGridViewCart.Rows.Add(Row.Cells[1].Value.ToString(),           //RessourceCategory
                                               Row.Cells[2].Value.ToString(),           //RessourceNumber
                                               Row.Cells[3].Value.ToString(),           //Name
                                               Row.Cells[4].Value = TextboxAmount.Text, //Amount
                                               Row.Cells[5].Value.ToString());          //Price
                     DataGridViewItemsInStock.Rows[i].Cells[0].Value = false;
                 }
             }
             else
             {
                 DataGridViewCart.Rows.Add(Row.Cells[1].Value.ToString(),
                                           Row.Cells[2].Value.ToString(),
                                           Row.Cells[3].Value.ToString(),
                                           Row.Cells[4].Value = TextboxAmount.Text,
                                           Row.Cells[5].Value.ToString());
                 DataGridViewItemsInStock.Rows[i].Cells[0].Value = false;
             }
             textboxTotalPrisWithOutTax.Text = Controller.ControllerChangeOfPriceWithOutMoms(Convert.ToInt32(Row.Cells[5].Value), Convert.ToInt32(TextboxAmount.Text), Convert.ToInt32(textboxTotalPrisWithOutTax.Text)).ToString();
             textboxTotalPrisWithTax.Text    = Controller.ControllerChangeOfPriceWithMoms(Convert.ToInt32(Row.Cells[5].Value), Convert.ToInt32(TextboxAmount.Text), Convert.ToInt32(textboxTotalPrisWithTax.Text)).ToString();
         }
     }
     TextboxAmount.Text = "";
 }