Example #1
0
        public static ResultadoTransaccion CreaAgente(Agente agente)
        {
            var res = new ResultadoTransaccion();
               //Abrir Conexion
               var conn = BaseDatos.Conexion();
               try
               {
               var command = new SqlCommand("SP_N_AGENTES", conn);
               command.CommandType = CommandType.StoredProcedure;
               command.Parameters.AddWithValue("@descripcion", agente.Descripcion);
               command.Parameters.AddWithValue("@contacto", agente.Contacto);
               command.Parameters.AddWithValue("@email", agente.Email);
               command.Parameters.AddWithValue("@alias", agente.Alias);

               var foo = command.ExecuteNonQuery();

               res.ObjetoTransaccion = agente;
               res.Descripcion = "El Agente se creo Exitosamente";

               }
               catch (Exception ex)
               {
               Log.EscribirLog(ex.Message);

               res.Descripcion = ex.Message;
               //res.ArchivoError = NombreClase;
               res.MetodoError = MethodBase.GetCurrentMethod().Name;
               }
               finally
               {
               conn.Close();
               }
               return res;
        }
Example #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (validar())
                return;
            var agente = BindViewToDomain();
            ResultadoTransaccion resultado = null;
            try
            {
                if (_agente == null)
                    resultado = ClsAgente.CreaAgente(agente);
                else
                    resultado = ClsAgente.ActualizaAgente(agente);
                MessageBox.Show(resultado.Descripcion, "Mantenedor de Agentes", MessageBoxButtons.OK, MessageBoxIcon.Information);

                ListarAgentes();
                LimpiarDatos();

                _agente = null;

            }
            catch (Exception ex)
            {
                Console.Write(ex.InnerException);
            }
        }
Example #3
0
 //pasar valores del form al objeto
 private Agente BindViewToDomain()
 {
     var item = new Agente();
     if (!string.IsNullOrEmpty(txtClave.Text))
         item.Clave = Convert.ToInt64(txtClave.Text);
     item.Contacto = txtContacto.Text;
     item.Descripcion = txtDescripcion.Text;
     item.Email = txtEmail.Text;
     item.Alias = txtAlias.Text;
     return item;
 }
Example #4
0
 public static ResultadoTransaccion EliminaAgente(Agente agente)
 {
     return ClsAgenteDao.EliminaAgente(agente);
 }
Example #5
0
 public static ResultadoTransaccion CreaAgente(Agente agente)
 {
     return ClsAgenteDao.CreaAgente(agente);
 }
Example #6
0
 public static ResultadoTransaccion ActualizaAgente(Agente agente)
 {
     return ClsAgenteDao.ActualizaAgente(agente);
 }
Example #7
0
 private static Agente GetFromDataReader(SqlDataReader reader)
 {
     var p = new Agente();
        p.Clave = Convert.ToInt64(reader["Id"]);
        p.Descripcion = reader["descripcion"].ToString();
        p.Contacto = reader["contacto"].ToString();
        p.Email = reader["email"].ToString();
        p.Alias = reader["alias"].ToString();
        return p;
 }
Example #8
0
 private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     var agente = GetSelectedRow(sender as GridView);
     if (agente == null)
     {
         LimpiarDatos();
         MenuEliminar.Enabled = false;
     }
     else
     {
         _agente = agente;
         txtClave.Text = agente.Clave.ToString();
         txtDescripcion.Text = agente.Descripcion;
         txtContacto.Text = agente.Contacto;
         txtEmail.Text = agente.Email;
         txtAlias.Text = agente.Alias;
         groupControl1.Text = "Editar";
         MenuEliminar.Enabled = true;
         //txtDescripcion.Enabled = false;
     }
 }
Example #9
0
 //Botón Nuevo_Click
 private void toolStripButton2_Click_1(object sender, EventArgs e)
 {
     _agente = null;
     ActiveControl = txtDescripcion;
     txtDescripcion.Focus();
     LimpiarDatos();
     gridView1.ClearSelection();
     var seleccionados = gridView1.GetSelectedRows();
     foreach (var i in seleccionados)
         gridView1.UnselectRow(i);
 }