示例#1
0
        private void changeButton_Click(object sender, EventArgs e)
        {
            try
            {
                DataGridViewRow row = dataGridViewDelivery.SelectedRows[0];
                if (this.Text == "Поставка")
                {
                    Storage storage = new Storage(Convert.ToInt32(dataGridViewDelivery.CurrentRow.Cells[0].Value),
                                                  Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[3].Value),
                                                  Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[4].Value),
                                                  Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[5].Value),
                                                  Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[7].Value));
                    Delivery delivery = new Delivery(Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[1].Value),
                                                     Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[2].Value),
                                                     Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[6].Value),
                                                     Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[8].Value),
                                                     Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[9].Value));
                    controller.changeButtonClick(storage, delivery);
                }
                else
                {
                    /* Storage storage = new Storage(Convert.ToInt32(dataGridViewDelivery.CurrentRow.Cells[0].Value),
                     * Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[3].Value),
                     * Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[4].Value),
                     * Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[5].Value),
                     * Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[7].Value));
                     * Shipment shipment = new Shipment(Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[1].Value),
                     *   Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[2].Value),
                     *   Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[6].Value),
                     *   Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[8].Value),
                     *   Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[9].Value),
                     *   Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[10].Value),
                     *   Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[11].Value),
                     *   Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[12].Value));*/

                    try
                    {
                        DialogResult dr = MessageBox.Show("Вы действительно хотите отменить запись?",
                                                          "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                        if (dr == DialogResult.OK)
                        {
                            Shipment shipment = new Shipment(Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[1].Value),
                                                             Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[2].Value),
                                                             Convert.ToInt32(dataGridViewDelivery.CurrentRow.Cells[0].Value),
                                                             Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[6].Value),
                                                             Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[10].Value),
                                                             Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[9].Value));
                            controller.cancelShipmentClick(shipment);
                        }
                    }
                    catch (System.ArgumentOutOfRangeException) { MessageBox.Show("Выберите запись!", "Изменение", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                    select();

                    // controller.changeButtonClick(storage, shipment);


                    /* DialogResult dr = MessageBox.Show("Вы действительно хотите удалить запись?",
                     * "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                     * if (dr == DialogResult.OK)
                     * {
                     *   Shipment shipment = new Shipment(Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[1].Value),
                     *   Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[2].Value),
                     *   Convert.ToString(dataGridViewDelivery.CurrentRow.Cells[6].Value),
                     *   Convert.ToInt32(dataGridViewDelivery.CurrentRow.Cells[0].Value));
                     *   controller.deleteButtonClick(shipment);
                     * }*/
                }
                select();
            }
            catch (System.ArgumentOutOfRangeException) { MessageBox.Show("Выберите запись!", "Изменение", MessageBoxButtons.OK, MessageBoxIcon.Error); }

            select();
        }