Exemplo n.º 1
0
        public static ResultadoTransaccion EditarAgente(PaperlessAgente agente)
        {
            ResultadoTransaccion res = new ResultadoTransaccion();

            conn = BaseDatos.Conexion();
            //Crear Transaccion
            var transaction = conn.BeginTransaction();

            long Id;
            try {
                objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_A_PAPERLESS_AGENTE");
                objParams[0].Value = agente.Id;
                objParams[1].Value = agente.Nombre;
                objParams[2].Value = agente.Contacto;
                objParams[3].Value = agente.Email;
                objParams[4].Value = agente.Activo;
                objParams[5].Value = agente.Alias;

                SqlCommand command = new SqlCommand("SP_A_PAPERLESS_AGENTE", conn);
                command.Transaction = transaction;
                command.Parameters.AddRange(objParams);
                command.CommandType = CommandType.StoredProcedure;
                command.ExecuteNonQuery();

                //Ejecutar transaccion
                transaction.Commit();
                res.Estado = Enums.EstadoTransaccion.Aceptada;
                res.Descripcion = "Se actualizo la información del agente correctamente";
            } catch (Exception ex) {
                transaction.Rollback();
                Log.EscribirLog(ex.Message);

                res.Descripcion = ex.Message;
                res.ArchivoError = "clsPaperlessADO.cs";
                res.MetodoError = "CrearAgente";
                res.Estado = Enums.EstadoTransaccion.Rechazada;
            } finally {
                conn.Close();
            }
            return res;
        }
Exemplo n.º 2
0
 public static ResultadoTransaccion EliminarAgente(PaperlessAgente agente)
 {
     agente.Activo = false;
     var foo = EditarAgente(agente);
     if (foo.Estado.Equals(Enums.EstadoTransaccion.Aceptada))
         foo.Descripcion = "Se Elimino el agente correctamente";
     return foo;
 }
Exemplo n.º 3
0
        public static IList<PaperlessAgente> ObtenerAgentes(Enums.Estado estado)
        {
            PaperlessAgente agente = null;
            IList<PaperlessAgente> listagentes = new List<PaperlessAgente>();
            try {
                //Abrir Conexion
                conn = BaseDatos.NuevaConexion();
                objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_L_PAPERLESS_AGENTE");
                objParams[0].Value = estado;
                SqlCommand command = new SqlCommand("SP_L_PAPERLESS_AGENTE", conn);
                command.Parameters.AddRange(objParams);
                command.CommandType = CommandType.StoredProcedure;
                dreader = command.ExecuteReader();

                while (dreader.Read()) {
                    agente = new PaperlessAgente();
                    agente.Id = Convert.ToInt64(dreader["Id"]);
                    agente.Nombre = dreader["Descripcion"].ToString();
                    agente.Contacto = dreader["Contacto"].ToString();
                    agente.Email = dreader["Email"].ToString();
                    agente.Alias = dreader["Alias"].ToString();
                    agente.Activo = true;
                    //agente.FechaCreacion = Convert.ToDateTime(dreader["FechaCreacion"]);
                    listagentes.Add(agente);
                }
            } catch (Exception ex) {
                Base.Log.Log.EscribirLog(ex.Message);
            } finally {
                conn.Close();
            }

            return listagentes;
        }
Exemplo n.º 4
0
        private static ResultadoTransaccion GuardaNuevoAgente(PaperlessAgente agente, SqlConnection connparam, SqlTransaction tranparam)
        {
            Int64 idagente = 0;
            resTransaccion = new ResultadoTransaccion();
            try {

                objParams = SqlHelperParameterCache.GetSpParameterSet(connparam, "SP_N_PAPERLESS_AGENTEV2");
                objParams[0].Value = agente.Nombre;
                objParams[1].Value = agente.Activo;

                SqlCommand command = new SqlCommand("SP_N_PAPERLESS_AGENTEV2", connparam);
                command.Transaction = tranparam;
                command.Parameters.AddRange(objParams);
                command.CommandType = CommandType.StoredProcedure;
                idagente = Convert.ToInt64(command.ExecuteScalar());

                resTransaccion.Estado = Enums.EstadoTransaccion.Aceptada;
                resTransaccion.ObjetoTransaccion = idagente;

            } catch (Exception ex) {
                resTransaccion.Estado = Enums.EstadoTransaccion.Rechazada;
                resTransaccion.Descripcion = ex.Message;
                Log.EscribirLog(ex.Message);
            }
            return resTransaccion;
        }
Exemplo n.º 5
0
        private void cboagente_SelectedIndexChanged(object sender, EventArgs e)
        {
            PaperlessAgente ObjAgente = new PaperlessAgente();

            if (cboagente.SelectedIndex>0)
            {
                ObjAgente = (PaperlessAgente)cboagente.SelectedItem;
                this.txtContacto.Text = ObjAgente.Contacto.ToString();
            }
        }
Exemplo n.º 6
0
 public static ResultadoTransaccion EliminarAgente(PaperlessAgente agente)
 {
     return AccesoDatos.Paperless.clsPaperlessADO.EliminarAgente(agente);
 }
Exemplo n.º 7
0
        private void CargarEditAgente(PaperlessAgente agente)
        {
            txtNombre.Text = agente.Nombre;
            txtContacto.Text = agente.Contacto;
            txtEmail.Text = agente.Email;
            txtAlias.Text = agente.Alias;
            txtId.Text = agente.Id.ToString();

            btnGuardar.Text = "Actualizar";
            btnEliminar.Enabled = true;
        }
Exemplo n.º 8
0
 private PaperlessAgente cargarAgentedesdeTextBox()
 {
     var agente = new PaperlessAgente();
     if (!String.IsNullOrEmpty(txtId.Text))
         agente.Id = Convert.ToInt64(txtId.Text);
     agente.Nombre = txtNombre.Text;
     agente.Contacto = txtContacto.Text;
     agente.Email = txtEmail.Text;
     agente.Alias = txtAlias.Text;
        return agente;
 }
Exemplo n.º 9
0
 private void ActualizarAgente(PaperlessAgente agente)
 {
     agente.Activo = true;
     var res = LogicaNegocios.Paperless.Paperless.EditarAgente(agente);
     ShowResultadoTransaccion(res);
 }
Exemplo n.º 10
0
 private void EliminarAgente(PaperlessAgente agente)
 {
     var res = LogicaNegocios.Paperless.Paperless.EliminarAgente(agente);
     ShowResultadoTransaccion(res);
 }
Exemplo n.º 11
0
 private void CrearNuevoAgente(PaperlessAgente agente)
 {
     var res = LogicaNegocios.Paperless.Paperless.CrearAgente(agente);
     ShowResultadoTransaccion(res);
 }