Exemplo n.º 1
0
 private void clientiToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     using (ComenziC c = new ComenziC())
     {
         c.ShowDialog();
     }
 }
Exemplo n.º 2
0
 private void btnSprePlati_Click(object sender, EventArgs e)
 {
     using (ComenziC cc = new ComenziC())
     {
         cc.ShowDialog();
     }
 }
Exemplo n.º 3
0
        private void btnSaveComanda_Click(object sender, EventArgs e)
        {
            string           query           = @"insert into comenzi_clienti (comandac_id, client_id, angajat_id, metodalivrare_id, datacomanda, datalimita, datalivrare) 
                                values (@comandaid, @clientid, @angajatid, @metodaid, @datac, @datalim, @dataliv)";
            string           query_detalii   = @"insert into detalii_comanda (comandac_id, produs_id, pretperkg, cantitate, tva, total) 
                                          values (@comandaid, @produsid, @pret, @q, @tva, @total)";
            NpgsqlConnection conn            = new NpgsqlConnection(conexiune);
            NpgsqlCommand    comanda_detalii = new NpgsqlCommand(query_detalii, conn);
            NpgsqlCommand    comanda         = new NpgsqlCommand(query, conn);

            if (gridComanda.Rows.Count - 1 == 0)
            {
                valid = false;
            }
            checkBeforeInsert();
            MessageBox.Show("Valid?" + valid);
            if (valid == true)
            {
                try
                {
                    conn.Open();
                    comanda.Parameters.Clear();
                    comanda.Parameters.AddWithValue("@comandaid", int.Parse(txtNrComanda.Text));
                    comanda.Parameters.AddWithValue("@clientid", genereazaIDClient(cboAlegeClient.SelectedItem.ToString()));
                    comanda.Parameters.AddWithValue("@angajatid", genereazaIDAngajat(cboAlegeAngajat.SelectedItem.ToString()));
                    comanda.Parameters.AddWithValue("@metodaid", genereazaIDMetodaLivrare(cboMetodaLivrare.SelectedItem.ToString()));
                    comanda.Parameters.AddWithValue("@datac", dtDataComanda.Value);
                    comanda.Parameters.AddWithValue("@datalim", dtDataLimita.Value);
                    if (chkLivrata.Checked == false)
                    {
                        comanda.Parameters.AddWithValue("@dataliv", dtDataLivrare.Value);
                    }
                    else
                    {
                        comanda.Parameters.AddWithValue("@dataliv", DBNull.Value);
                    }
                    comanda.CommandType = CommandType.Text;
                    comanda.ExecuteNonQuery();
                    // Detaliile comenzii
                    for (int i = 0; i < gridComanda.Rows.Count - 1; ++i)
                    {
                        comanda_detalii.Parameters.Clear();
                        comanda_detalii.Parameters.AddWithValue("@comandaid", int.Parse(txtNrComanda.Text));
                        comanda_detalii.Parameters.AddWithValue("@produsid", genereazaIDProdus(gridComanda[0, i].Value.ToString()));
                        comanda_detalii.Parameters.AddWithValue("@q", double.Parse(gridComanda[1, i].Value.ToString()));
                        comanda_detalii.Parameters.AddWithValue("@pret", double.Parse(gridComanda[2, i].Value.ToString()));
                        comanda_detalii.Parameters.AddWithValue("@tva", double.Parse(gridComanda[3, i].Value.ToString()));
                        comanda_detalii.Parameters.AddWithValue("@total", double.Parse(gridComanda[4, i].Value.ToString()));
                        comanda_detalii.CommandType = CommandType.Text;
                        comanda_detalii.ExecuteNonQuery();
                    }
                    conn.Close();
                    DialogResult dialog = MetroFramework.MetroMessageBox.Show(this, @"Comanda cu nr. " + txtNrComanda.Text +
                                                                              " a fost inregistrata cu succes!\nDoriti sa inregistrati alta comanda?",
                                                                              "Comanda inregistrata", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialog == DialogResult.Yes)
                    {
                        using (ComenziC comenzic = new ComenziC())
                        {
                            Hide();
                            comenzic.ShowDialog();
                        }
                    }
                    else
                    {
                        Close();
                    }
                }
                catch (NpgsqlException ex)
                {
                    MessageBox.Show("O mica eroare a intervenit:\n" + ex);
                }
            }
        }