Ejemplo n.º 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); }
 }
Ejemplo n.º 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;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public bool onAddClick(StoragePlace storagePlace, StoreStoragePlace storeStoragePlace)
        {
            string weight = storeStoragePlace.Weight.Replace(",", ".");

            if (!DAO.getInstance().addStoragePlace(storagePlace.IdRaw, storeStoragePlace.Number,
                                                   weight, StoreStoragePlace.NameTable, StoreStoragePlace.NumberAttr, StoreStoragePlace.WeightAttr))
            {
                MessageBox.Show("Данное сырье уже присутствует в данном хранилище!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 4
0
 public AddStorageForm(StoreStoragePlace newStore, string newRaw, string newType, string newSubtype, string newClassRaw, double newWeight)
 {
     InitializeComponent();
     controller           = new AddStorageController();
     comboBoxStorage.Text = comboBoxStorage.Items[0].ToString();
     store = newStore;
     comboBoxNumber.Text = store.Number;
     number                  = store.Number;
     textBoxWeight.Text      = store.Weight;
     comboBoxStorage.Enabled = false;
     raw      = newRaw;
     type     = newType;
     subtype  = newSubtype;
     classRaw = newClassRaw;
     weight   = newWeight;
 }
Ejemplo n.º 5
0
 public bool onSaveClick(Shipment shipment, StoreStoragePlace store, string id)
 {
     if (!DAO.getInstance().addShipment(shipment.Contractor, shipment.Subdivision, shipment.Transport,
                                        shipment.Weight, shipment.Date, "numb_store", "Store_raw", "weight_store", shipment.Number))
     {
         MessageBox.Show("Данная запись об отгрузке уже существует!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
     else
     {
         /*      DAO.getInstance().updateStoragePlace(store.IdRaw, store.Number, store.Weight,
          * StoreStoragePlace.NameTable, StoreStoragePlace.NumberAttr, StoreStoragePlace.WeightAttr,
          * store.IdPlaceStorage, store.Number);*/
         return(true);
     }
 }
Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 7
0
 public void changeButtonClick(StoreStoragePlace store, string raw, string type, string subtype, string classRaw, double weight)
 {
     new AddStorageForm(store, raw, type, subtype, classRaw, weight).ShowDialog();
 }