private void buttonAddNewOrder_Click(object sender, EventArgs e)
        {
            int             index       = dataGridViewAddOrderSelectCar.CurrentCell.RowIndex;
            DataGridViewRow selectedRow = dataGridViewAddOrderSelectCar.Rows[index];
            string          autoIdText  = selectedRow.Cells[0].Value.ToString();
            int             autoId      = Convert.ToInt32(autoIdText);

            string startDate   = dateTimePickerStartDate.Text;
            string endDate     = dateTimePickerEndDate.Text;
            string description = textBoxAddOrderDescription.Text;
            object state       = comboBoxAddOrderState.SelectedItem;

            if (string.IsNullOrEmpty(description) || state == null)
            {
                labelAddOrder.Text = @"Must complete all mandatory fields.";
            }
            else
            {
                buttonAddNewOrder.Enabled = true;
                Comanda order = new Comanda()
                {
                    AutoId         = autoId,
                    DataFinalizare = Convert.ToDateTime(endDate),
                    DataProgramare = Convert.ToDateTime(startDate),
                    DataSystem     = DateTime.Now,
                    Descriere      = description,
                    KmBord         = Convert.ToInt32(textBoxAddOrderKm.Text),
                    StareComanda   = getOrderState(Convert.ToString(state)),
                    ValoarePiese   = TotalCost
                };

                _carService.AddOrder(order);

                labelAddOrder.Text    = @"Order added.";
                labelAddOrder.Visible = true;

                string getOrdersQuery = $"SELECT Id, Descriere, StareComanda FROM Comenzi WHERE AutoId = {autoId}";
                ExecuteQuery(getOrdersQuery, dataGridViewAddDetailByOrder);
            }
        }
Exemplo n.º 2
0
 public void AddOrder(Comanda comanda)
 {
     _api.AddOrder(comanda);
 }