Beispiel #1
0
 private void metroButton1_Click(object sender, EventArgs e)
 {
     using (Plati plati = new Plati())
     {
         plati.ShowDialog();
     }
 }
 private void platiFurnizoriToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (Plati plati = new Plati())
     {
         plati.ShowDialog();
     }
 }
Beispiel #3
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 (Plati plati = new Plati())
                        {
                            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();
                }
            }
        }
        private void btnPlatesteRestul_Click(object sender, EventArgs e)
        {
            string       plateste_restul = @"insert into plati (factura_id, valoare, dataplata, metodaplata_id, nrordinplata, ibanplatitor, ibanbeneficiar) 
                                        VALUES (@idfact, @val, @dataplata, @metodaid, @nrordin, @ibanplatitor, @ibanbeneficiar)";
            double       rest_de_plata   = Convert.ToDouble(rest_plata);
            DateTime     current_date    = DateTime.Now;
            DialogResult dialog          = new DialogResult();

            dialog = MetroFramework.MetroMessageBox.Show(this, "Sunteti pe cale sa platiti restul de " + rest_de_plata + " RON.\nMetoda de plata aleasa este: " + cboMetodaPlata.SelectedItem.ToString() + "." + "\nData platii: " + dtDataPlata.Value.ToString() + "." + "\nContinuati spre inregistrarea platii?", "Confirmare plata", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (dialog == DialogResult.Yes)
            {
                checkBeforeInsert();
            }
            if (valid == true)
            {
                try
                {
                    using (conn = new NpgsqlConnection(conexiune))
                    {
                        conn.Open();
                        using (NpgsqlCommand comanda = new NpgsqlCommand(plateste_restul, conn))
                        {
                            comanda.Parameters.AddWithValue("@idfact", int.Parse(cboNrFactura.SelectedItem.ToString()));
                            comanda.Parameters.AddWithValue("@val", rest_de_plata);
                            comanda.Parameters.AddWithValue("@dataplata", current_date);
                            comanda.Parameters.AddWithValue("@metodaid", genereazaIDMetodaPlata(cboMetodaPlata.SelectedItem.ToString()));
                            if (cboMetodaPlata.SelectedItem.ToString() == "ordin plata")
                            {
                                comanda.Parameters.AddWithValue("@nrordin", int.Parse(txtNrOP.Text));
                                comanda.Parameters.AddWithValue("@ibanplatitor", txtIBANPlatitor.Text);
                                comanda.Parameters.AddWithValue("@ibanbeneficiar", txtIBANBeneficiar.Text);
                            }
                            else
                            {
                                comanda.Parameters.AddWithValue("@nrordin", DBNull.Value);
                                comanda.Parameters.AddWithValue("@ibanplatitor", DBNull.Value);
                                comanda.Parameters.AddWithValue("@ibanbeneficiar", DBNull.Value);
                            }
                            comanda.CommandType = CommandType.Text;
                            comanda.ExecuteNonQuery();
                        }
                    }
                    dialog = MetroFramework.MetroMessageBox.Show(this, "Plata a fost inregistrata.", "Succes!", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    if (dialog == DialogResult.OK)
                    {
                        using (Plati plati = new Plati())
                        {
                            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();
                }
            }
        }