예제 #1
0
        }     //End insertar

        public static void ActualizarCliente(VOCliente cliente)
        {
            Conexion      conexion = new Conexion();
            SqlConnection cnn      = new SqlConnection(conexion.CadenaConexion);
            int           r        = 0;

            try
            {
                cnn.Open();
                SqlCommand cmd = new SqlCommand("SP_ActualizarCliente", cnn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@IdCliente", SqlDbType.Int).Value            = cliente.IdCliente;
                cmd.Parameters.Add("@NombreCliente", SqlDbType.VarChar).Value    = cliente.NombreCliente;
                cmd.Parameters.Add("@Apellido_paterno", SqlDbType.VarChar).Value = cliente.Apellido_paterno;
                cmd.Parameters.Add("@Apellido_materno", SqlDbType.VarChar).Value = cliente.Apellido_materno;
                cmd.Parameters.Add("@Correo", SqlDbType.VarChar).Value           = cliente.Correo;
                cmd.Parameters.Add("@Telefono", SqlDbType.VarChar).Value         = cliente.Telefono;
                cmd.Parameters.Add("@Direccion", SqlDbType.VarChar).Value        = cliente.Direccion;
                cmd.Parameters.Add("@UrlFoto", SqlDbType.VarChar).Value          = cliente.Urlfoto;
                r = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new ArgumentException("No se pudo insertar el dato en la base de datos " + ex.Message);
            }
            finally
            {
                cnn.Close();
            } //End ty/catch
        }     //End Actualizar
예제 #2
0
        }//End btnGuardar

        public void CagarFormulario(VOCliente cliente)
        {
            lblIdCliente.Text        = cliente.IdCliente.ToString();
            txtNombre.Text           = cliente.NombreCliente.ToString();
            txtApellido_paterno.Text = cliente.Apellido_paterno.ToString();
            txtApellido_materno.Text = cliente.Apellido_materno.ToString();
            txtCorreo.Text           = cliente.Correo.ToString();
            txtTelefono.Text         = cliente.Telefono.ToString();
            txtDireccion.Text        = cliente.Direccion.ToString();
            lblUrlFoto.InnerText     = cliente.Urlfoto.ToString();
        }//End cargarformulario
예제 #3
0
        }//End eliminar

        public static void Actualizar(VOCliente cliente)
        {
            try
            {
                DALCliente.ActualizarCliente(cliente);
            }
            catch
            {
                throw new ArgumentException("No se pudo actualizar el dato");
            }
        }//End actualizar
예제 #4
0
 public static void Insertar(VOCliente cliente)
 {
     try
     {
         DALCliente.InsertarCliente(cliente);
     }
     catch
     {
         throw new ArgumentException("No se pudo insertar el dato");
     }
 }//End insertar
예제 #5
0
        }     //End page_load

        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                VOCliente cliente = new VOCliente(int.Parse(lblIdCliente.Text), txtNombre.Text, txtApellido_paterno.Text, txtApellido_materno.Text, txtCorreo.Text, txtTelefono.Text, txtDireccion.Text, lblUrlFoto.InnerText);
                BLLCliente.Actualizar(cliente);
                LimpiarFormulario();
                Response.Redirect("ListaCliente.aspx");
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "Mensaje de error", "alert('Se registro un error a realizar la operacion." + ex.Message + "');", true);
            }
        }//End btnGuardar
예제 #6
0
        }//End actualizar

        public static VOCliente ConsultarClientePorId(string idCliente)
        {
            VOCliente cliente = null;

            try
            {
                cliente = DALCliente.ConsultarClientePorId(int.Parse(idCliente));
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Error al consultar el registro de persona" + ex.Message);
            }
            return(cliente);
        }
예제 #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["id"] == null)
         {
             Response.Redirect("ListaCliente.aspx");
         }
         else
         {
             string    idCliente = Request.QueryString["id"].ToString();
             VOCliente cliente   = BLLCliente.ConsultarClientePorId(idCliente);
             CagarFormulario(cliente);
         }
     } //End if postback
 }     //End page_load
예제 #8
0
        }     //End EliminarCliente

        public static VOCliente ConsultarClientePorId(int idCliente)
        {
            VOCliente     cliente  = null;
            Conexion      conexion = new Conexion();
            SqlConnection cnn      = new SqlConnection(conexion.CadenaConexion);
            SqlDataReader datos;

            try
            {
                cnn.Open();
                SqlCommand cmd = new SqlCommand("SP_ConsultarClientePorId", cnn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@IdCliente", SqlDbType.Int).Value = idCliente;
                datos = cmd.ExecuteReader();
                while (datos.Read())
                {
                    cliente = new VOCliente(Convert.ToInt32(datos.GetValue(0).ToString()),
                                            datos.GetValue(1).ToString(),
                                            datos.GetValue(2).ToString(),
                                            datos.GetValue(3).ToString(),
                                            datos.GetValue(4).ToString(),
                                            datos.GetValue(5).ToString(),
                                            datos.GetValue(6).ToString(),
                                            datos.GetValue(7).ToString());
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("No se pudo completar la busqueda");
            }
            finally
            {
                cnn.Close();
            }
            return(cliente);
        }//End ConsultarClientePorId