public static bool gravaMovEntrega(CL_SincrEntrega objSincrEntrega, string con) { DB_Funcoes.DesmontaConexao(con); CONEXAO = montaDAO(CONEXAO); Conn = new NpgsqlConnection(CONEXAO); try { string sql = "INSERT INTO mov_entregas (m_identreg, m_idapp, m_data, m_status, m_motivo, m_nreceb, m_tipodoc, m_docum, m_tiporec, m_obs, m_foto, m_nrtent) " + "VALUES (@m_identreg, @m_idapp, @m_data, @m_status, @m_motivo, @m_nreceb, @m_tipodoc, @m_docum, @m_tiporec, @m_obs, @m_foto, @m_nrtent)"; NpgsqlCommand comand = new NpgsqlCommand(sql, Conn); comand.Parameters.AddWithValue("m_identreg", objSincrEntrega.e_identreg); comand.Parameters.AddWithValue("m_idapp", objSincrEntrega.e_idapp); comand.Parameters.AddWithValue("m_data", objSincrEntrega.e_data); comand.Parameters.AddWithValue("m_status", objSincrEntrega.e_status); comand.Parameters.AddWithValue("m_motivo", objSincrEntrega.e_motivo); comand.Parameters.AddWithValue("m_nreceb", objSincrEntrega.e_recebedor); comand.Parameters.AddWithValue("m_tipodoc", objSincrEntrega.e_tpdoc); comand.Parameters.AddWithValue("m_docum", objSincrEntrega.e_doc); comand.Parameters.AddWithValue("m_tiporec", objSincrEntrega.e_tpreceb); comand.Parameters.AddWithValue("m_obs", objSincrEntrega.e_obs); comand.Parameters.AddWithValue("m_foto", objSincrEntrega.e_foto); comand.Parameters.AddWithValue("m_nrtent", objSincrEntrega.e_tentat); Conn.Open(); comand.ExecuteScalar(); return(true); } catch (Exception ex) { ex.ToString(); return(false); } finally { if (Conn.State == ConnectionState.Open) { Conn.Close(); } } }
public static bool gravaMovEntrega(CL_SincrEntrega objSincrEntrega, string con) { return(DB_Entrega.gravaMovEntrega(objSincrEntrega, con)); }
public static CL_SincrEntrega buscaMovEntrega(int idUmov, string con) { DB_Funcoes.DesmontaConexao(con); CONEXAO = montaDAO(CONEXAO); Conn = new NpgsqlConnection(CONEXAO); CL_SincrEntrega objSincrEntrega = new CL_SincrEntrega(); string sql = "SELECT * FROM mov_entregas WHERE m_idapp=@m_idapp"; NpgsqlCommand comand = new NpgsqlCommand(sql, Conn); comand.Parameters.AddWithValue("m_idapp", idUmov.ToString()); NpgsqlDataReader dr; try { Conn.Open(); dr = comand.ExecuteReader(); if (dr.HasRows) { if (dr.Read()) { objSincrEntrega.e_idapp = idUmov; objSincrEntrega.e_id = dr["m_id"] is DBNull ? 0 : Convert.ToInt64(dr["m_id"]); objSincrEntrega.e_data = Convert.ToDateTime(dr["m_data"]); objSincrEntrega.e_identreg = Convert.ToInt64(dr["m_identreg"]); objSincrEntrega.e_motivo = dr["m_motivo"].ToString().Trim(); objSincrEntrega.e_status = dr["m_status"].ToString().Trim(); objSincrEntrega.e_recebedor = dr["m_nreceb"].ToString().Trim(); objSincrEntrega.e_tpdoc = dr["m_tipodoc"].ToString().Trim(); objSincrEntrega.e_doc = dr["m_docum"].ToString().Trim(); objSincrEntrega.e_tpreceb = dr["m_tiporec"].ToString().Trim(); objSincrEntrega.e_obs = dr["m_obs"].ToString().Trim(); objSincrEntrega.e_foto = dr["m_foto"].ToString().Trim(); objSincrEntrega.e_tentat = dr["m_nrtent"] is DBNull ? 0 : Convert.ToInt32(dr["m_nrtent"]); return(objSincrEntrega); } else { objSincrEntrega = null; return(objSincrEntrega); } } else { objSincrEntrega = null; return(objSincrEntrega); } } catch (Exception ex) { ex.ToString(); objSincrEntrega = null; return(objSincrEntrega); } finally { if (Conn.State == ConnectionState.Open) { Conn.Close(); } } }