Example #1
0
 private void platiClientiToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (PlatiClienti platiclienti = new PlatiClienti())
     {
         platiclienti.ShowDialog();
     }
 }
Example #2
0
        private void btnPlata_Click(object sender, EventArgs e)
        {
            string       insert = @"INSERT INTO Plati (factura_id, valoare, dataplata, metodaplata_id, nrordinplata, ibanplatitor, ibanbeneficiar) 
                                    VALUES (@id, @val, @data, @idmetoda, @nrordin, @ibanp, @ibanb)";
            DialogResult dialog = new DialogResult();

            checkBeforeInsert();
            if (valid == true)
            {
                try
                {
                    using (conn = new NpgsqlConnection(conexiune))
                    {
                        conn.Open();
                        using (NpgsqlCommand comanda = new NpgsqlCommand(insert, conn))
                        {
                            comanda.Parameters.AddWithValue("@id", int.Parse(cboNrFactura.SelectedItem.ToString()));
                            comanda.Parameters.AddWithValue("@val", double.Parse(txtTotalPlatit.Text));
                            comanda.Parameters.AddWithValue("@data", dtDataPlata.Value);
                            comanda.Parameters.AddWithValue("@idmetoda", genereazaIDMetodaPlata(cboMetodaPlata.SelectedItem.ToString()));
                            if (cboMetodaPlata.SelectedItem.ToString() == "ordin plata")
                            {
                                comanda.Parameters.AddWithValue("@nrordin", int.Parse(txtNrOP.Text));
                                comanda.Parameters.AddWithValue("@ibanp", txtIBANPlatitor.Text);
                                comanda.Parameters.AddWithValue("@ibanb", txtIBANBeneficiar.Text);
                            }
                            else
                            {
                                comanda.Parameters.AddWithValue("@nrordin", DBNull.Value);
                                comanda.Parameters.AddWithValue("@ibanp", DBNull.Value);
                                comanda.Parameters.AddWithValue("@ibanb", DBNull.Value);
                            }
                            comanda.CommandType = CommandType.Text;
                            comanda.ExecuteNonQuery();
                            dialog = MetroFramework.MetroMessageBox.Show(this, "Plata inregistrata cu succes!\nInregistrati alta plata?", "Succes!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        }
                    }
                    if (dialog == DialogResult.Yes)
                    {
                        using (PlatiClienti plati = new PlatiClienti())
                        {
                            Hide();
                            plati.ShowDialog();
                        }
                    }
                    else
                    {
                        Close();
                    }
                }
                catch (Exception ex)
                {
                    MetroFramework.MetroMessageBox.Show(this, "A aparut o problema.\n" + ex, "Atentie!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    conn.Close();
                }
            }
        }