Пример #1
0
 private void changeButton_Click(object sender, EventArgs e)
 {
     try
     {
         DataGridViewRow row = dataGridViewStorage.SelectedRows[0];
         if (Convert.ToString(dataGridViewStorage.CurrentRow.Cells[2].Value) == "склад")
         {
             StoreStoragePlace store = new StoreStoragePlace(Convert.ToString(dataGridViewStorage.CurrentRow.Cells[0].Value),
                                                             Convert.ToString(dataGridViewStorage.CurrentRow.Cells[1].Value), Convert.ToString(dataGridViewStorage.CurrentRow.Cells[3].Value),
                                                             Convert.ToString(dataGridViewStorage.CurrentRow.Cells[4].Value));
             controller.changeButtonClick(store, Convert.ToString(dataGridViewRaw.CurrentRow.Cells[2].Value),
                                          Convert.ToString(dataGridViewRaw.CurrentRow.Cells[3].Value),
                                          Convert.ToString(dataGridViewRaw.CurrentRow.Cells[4].Value),
                                          Convert.ToString(dataGridViewRaw.CurrentRow.Cells[5].Value),
                                          Convert.ToDouble(dataGridViewRaw.CurrentRow.Cells[7].Value));
         }
         else
         {
             SilageStoragePlace silage = new SilageStoragePlace(Convert.ToString(dataGridViewStorage.CurrentRow.Cells[0].Value),
                                                                Convert.ToString(dataGridViewStorage.CurrentRow.Cells[1].Value), Convert.ToString(dataGridViewStorage.CurrentRow.Cells[3].Value),
                                                                Convert.ToString(dataGridViewStorage.CurrentRow.Cells[4].Value));
             controller.changeButtonClick(silage, Convert.ToString(dataGridViewRaw.CurrentRow.Cells[2].Value),
                                          Convert.ToString(dataGridViewRaw.CurrentRow.Cells[3].Value),
                                          Convert.ToString(dataGridViewRaw.CurrentRow.Cells[4].Value),
                                          Convert.ToString(dataGridViewRaw.CurrentRow.Cells[5].Value),
                                          Convert.ToDouble(dataGridViewRaw.CurrentRow.Cells[7].Value));
         }
         selectStorage();
     }
     catch (System.ArgumentOutOfRangeException) { MessageBox.Show("Выберите запись!", "Изменение", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }
Пример #2
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            double weight       = Convert.ToDouble(weightTextBox.Text);
            double weightBefore = Convert.ToDouble(dataGridViewRaw.CurrentRow.Cells[5].Value);

            if (weightBefore < weight)
            {
                MessageBox.Show(String.Format("Вес не должен превышать {0} тонн!", weightBefore), "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string weightStr = weight.ToString().Replace(",", ".");

                shipment = new Shipment(Convert.ToInt32(dataGridViewRaw.CurrentRow.Cells[0].Value), contractorComboBox.Text, subdivisionComboBox.Text, dateTimePicker.Text,
                                        transportTextBox.Text, weightStr, Convert.ToString(dataGridViewRaw.CurrentRow.Cells[6].Value),
                                        Convert.ToString(dataGridViewRaw.CurrentRow.Cells[7].Value),
                                        Convert.ToString(dataGridViewRaw.CurrentRow.Cells[8].Value));
                weightStr = (weightBefore - weight).ToString().Replace(",", ".");

                if (Convert.ToString(dataGridViewRaw.CurrentRow.Cells[6].Value) == "склад")
                {
                    StoreStoragePlace store = new StoreStoragePlace(Convert.ToString(dataGridViewRaw.CurrentRow.Cells[0].Value),
                                                                    Convert.ToString(dataGridViewRaw.CurrentRow.Cells[8].Value),
                                                                    Convert.ToString(dataGridViewRaw.CurrentRow.Cells[7].Value), weightStr);
                    if (controller.onSaveClick(shipment, store, Convert.ToString(dataGridViewRaw.CurrentRow.Cells[8].Value)))
                    {
                        this.Close();
                    }
                    else
                    {
                        shipment = null;
                    }
                }
                else
                {
                    SilageStoragePlace silage = new SilageStoragePlace(Convert.ToString(dataGridViewRaw.CurrentRow.Cells[0].Value),
                                                                       Convert.ToString(dataGridViewRaw.CurrentRow.Cells[8].Value),
                                                                       Convert.ToString(dataGridViewRaw.CurrentRow.Cells[7].Value), weightStr);
                    if (controller.onSaveClick(shipment, silage, Convert.ToString(dataGridViewRaw.CurrentRow.Cells[8].Value)))
                    {
                        this.Close();
                    }
                    else
                    {
                        shipment = null;
                    }
                }
            }
        }
Пример #3
0
        public bool onAddClick(StoragePlace storagePlace, SilageStoragePlace silageStoragePlace)
        {
            string weight = silageStoragePlace.Weight.Replace(",", ".");

            if (!DAO.getInstance().addStoragePlace(storagePlace.IdRaw, silageStoragePlace.Number,
                                                   weight, SilageStoragePlace.NameTable, SilageStoragePlace.NumberAttr, SilageStoragePlace.WeightAttr))
            {
                MessageBox.Show("Данное сырье уже присутствует в данном хранилище!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #4
0
 public AddStorageForm(SilageStoragePlace newSilage, string newRaw, string newType, string newSubtype, string newClassRaw, double newWeight)
 {
     InitializeComponent();
     controller           = new AddStorageController();
     comboBoxStorage.Text = comboBoxStorage.Items[1].ToString();
     silage = newSilage;
     comboBoxNumber.Text = silage.Number;
     number                  = silage.Number;
     textBoxWeight.Text      = silage.Weight;
     comboBoxStorage.Enabled = false;
     raw      = newRaw;
     type     = newType;
     subtype  = newSubtype;
     classRaw = newClassRaw;
     weight   = newWeight;
 }
Пример #5
0
 public bool onSaveClick(Shipment shipment, SilageStoragePlace silage, string id)
 {
     if (!DAO.getInstance().addShipment(shipment.Contractor, shipment.Subdivision,
                                        shipment.Transport, shipment.Weight, shipment.Date, "numb_silage",
                                        "Silage_raw", "weight_silage", shipment.Number))
     {
         MessageBox.Show("Данная запись об отгрузке уже существует!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
     else
     {
         /*  DAO.getInstance().updateStoragePlace(silage.IdRaw, silage.Number, silage.Weight,
          * SilageStoragePlace.NameTable, SilageStoragePlace.NumberAttr, SilageStoragePlace.WeightAttr,
          * silage.IdPlaceStorage, silage.Number);*/
         return(true);
     }
 }
Пример #6
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            double d = Convert.ToDouble(textBoxWeight.Text);

            if (Convert.ToDouble(textBoxWeight.Text) > weight)
            {
                MessageBox.Show(String.Format("Вес не должен превышать {0} тонн!", weight), "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (comboBoxStorage.Text == "Склад")
                {
                    string[] res = DAO.getInstance().correctAddStorage(comboBoxNumber.Text, StoreStoragePlace.NameTable, StoreStoragePlace.NumberAttr);
                    if ((raw == res[0] && type == res[1] && subtype == res[2] && classRaw == res[3]) ||
                        (res[0] == null))
                    {
                        double capacity = DAO.getInstance().calcCapacity(StoreStoragePlace.NameTable, StoreStoragePlace.WeightAttr,
                                                                         StoreStoragePlace.NumberAttr, comboBoxNumber.Text);
                        double count = capacity + Convert.ToDouble(textBoxWeight.Text);
                        if (count > Store.Capacity)
                        {
                            MessageBox.Show(String.Format("Склад переполнен на {0} тонн(ы)! Вместимость 3500 тонн!", count - Store.Capacity), "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            if (store == null)
                            {
                                storagePlace = new StoragePlace(idRaw);
                                store        = new StoreStoragePlace(idRaw, comboBoxNumber.Text, textBoxWeight.Text);
                                if (controller.onAddClick(storagePlace, store))
                                {
                                    this.Close();
                                }
                                else
                                {
                                    store = null;
                                }
                            }
                            else
                            {
                                store.Number = comboBoxNumber.Text;
                                store.Weight = textBoxWeight.Text;
                                if (controller.onUpdateClick(store, number))
                                {
                                    this.Close();
                                }
                                else
                                {
                                    store = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Сырье не может находится в данном хранилище, произойдет смешивание!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    string[] res = DAO.getInstance().correctAddStorage(comboBoxNumber.Text, SilageStoragePlace.NameTable, SilageStoragePlace.NumberAttr);
                    if ((raw == res[0] && type == res[1] && subtype == res[2] && classRaw == res[3]) ||
                        (res[0] == null))
                    {
                        double capacity = DAO.getInstance().calcCapacity(SilageStoragePlace.NameTable, SilageStoragePlace.WeightAttr,
                                                                         SilageStoragePlace.NumberAttr, comboBoxNumber.Text);
                        double count = capacity + Convert.ToDouble(textBoxWeight.Text);
                        if (count > Silage.Capacity)
                        {
                            MessageBox.Show(String.Format("Силос переполнен на {0} тонн(ы)! Вместимость 150 тонн!", count - Silage.Capacity), "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            if (silage == null)
                            {
                                storagePlace = new StoragePlace(idRaw);
                                silage       = new SilageStoragePlace(idRaw, comboBoxNumber.Text, textBoxWeight.Text);
                                if (controller.onAddClick(storagePlace, silage))
                                {
                                    this.Close();
                                }
                                else
                                {
                                    silage = null;
                                }
                            }
                            else
                            {
                                silage.Number = comboBoxNumber.Text;
                                silage.Weight = textBoxWeight.Text;
                                if (controller.onUpdateClick(silage, number))
                                {
                                    this.Close();
                                }
                                else
                                {
                                    silage = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Сырье не может находится в данном хранилище, произойдет смешивание!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Пример #7
0
 public void changeButtonClick(SilageStoragePlace silage, string raw, string type, string subtype, string classRaw, double weight)
 {
     new AddStorageForm(silage, raw, type, subtype, classRaw, weight).ShowDialog();
 }