Пример #1
0
        public static bool cadEntrega(CL_Entrega objEntrega, string token, string post, string situac, string con)
        {
            DB_Funcoes.DesmontaConexao(con);
            CONEXAO = montaDAO(CONEXAO);
            Conn    = new NpgsqlConnection(CONEXAO);
            Conn.Open();
            NpgsqlTransaction transaction = Conn.BeginTransaction();

            try
            {
                string sql = "INSERT INTO entregas (e_awb, e_dataenco, e_datastat, e_status, e_diasprev, e_clicod, e_situac, e_id, e_identreg, e_modelo) " +
                             "VALUES " +
                             "(@e_awb, @e_dataenco, @e_datastat, @e_status, @e_diasprev, @e_clicod, @e_situac, @e_id, @e_identreg, @e_modelo)";
                NpgsqlCommand cmd = new NpgsqlCommand(sql, Conn, transaction);
                cmd.Parameters.AddWithValue("e_awb", objEntrega.e_awb);
                cmd.Parameters.AddWithValue("e_dataenco", objEntrega.e_dataenco);
                cmd.Parameters.AddWithValue("e_datastat", objEntrega.e_datastat);
                cmd.Parameters.AddWithValue("e_status", objEntrega.e_status);
                cmd.Parameters.AddWithValue("e_diasprev", objEntrega.e_diasprev);
                cmd.Parameters.AddWithValue("e_clicod", objEntrega.e_clicod);
                cmd.Parameters.AddWithValue("e_situac", objEntrega.e_situac);
                cmd.Parameters.AddWithValue("e_id", objEntrega.e_id);
                cmd.Parameters.AddWithValue("e_identreg", objEntrega.e_idEntregador);
                cmd.Parameters.AddWithValue("e_modelo", objEntrega.e_modelo);

                cmd.ExecuteScalar();
                if (DB_Umov.sincronizaApp(token, "schedule", post))
                {
                    if (DB_Umov.attSituac(situac, con))
                    {
                        transaction.Commit();
                        return(true);
                    }
                    else
                    {
                        transaction.Rollback();
                        return(false);
                    }
                }
                else
                {
                    transaction.Rollback();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                transaction.Rollback();
                return(false);
            }
            finally
            {
                if (Conn.State == ConnectionState.Open)
                {
                    Conn.Close();
                }
            }
        }
Пример #2
0
 public static bool cadEntrega(CL_Entrega objEntrega, string token, string post, string sql, string con)
 {
     return(DB_Entrega.cadEntrega(objEntrega, token, post, sql, con));
 }