Esempio n. 1
0
 private void loadCliente()
 {
     try
     {
         if (myCliente != null && myCliente.ID > 0)
         {
             myCliente = serviciosCLIENTE.buscarPrimeroCLIENTE(myCliente);
             if (myCliente != null && myCliente.ID > 0)
             {
                 setComboTipoDocumento(myCliente.ID_TIPO_DOCUMENTO);
                 txtNumDocumento.Text = myCliente.IDENTIFICACION;
                 txtNombres.Text      = myCliente.NOMBRES;
                 txtApellidos.Text    = myCliente.APELLIDOS;
                 txtDireccion.Text    = myCliente.DIRECCION;
                 myCiudad             = new VIEW_CIUDAD();
                 myCiudad.ID          = myCliente.ID_CIUDAD;
                 myCiudad             = serviciosVIEW_CIUDAD.buscarPrimeroVIEW_CIUDAD(myCiudad);
                 if (myCiudad != null && myCiudad.ID > 0)
                 {
                     txtCiudad.Text       = myCiudad.CIUDAD;
                     txtDepartamento.Text = myCiudad.DEPARTAMENTO;
                 }
                 txtCelular.Text          = myCliente.CELULAR;
                 txtTelefono.Text         = myCliente.TELEFONO;
                 txtCorreo.Text           = myCliente.CORREO;
                 datFechaNacimiento.Value = myCliente.FECHA_NACIMIENTO;
                 setComboGenero(myCliente.ID_GENERO);
             }
         }
     }
     catch (Exception exp)
     {
     }
 }
        /**
         * Busca los registros que coincidan con los datos enviados
         * @param VIEW_CIUDAD obj
         * @return Retorna la lista de los registros que coinciden
         */
        public VIEW_CIUDAD[] buscarVIEW_CIUDAD(VIEW_CIUDAD obj)
        {
            VIEW_CIUDAD[]      result = null;
            List <VIEW_CIUDAD> lista  = null;

            try
            {
                VIEW_CIUDADDao dao = new VIEW_CIUDADDao();
                conn  = conexion.conection();
                lista = dao.search(conn, obj);
                if (lista != null && lista.Count > 0)
                {
                    result = lista.ToArray();
                }
            }
            catch (Exception e)
            {
                result = null;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(result);
        }
        /**
         * Inserta nuevo registro en la tabla
         * @param VIEW_CIUDAD obj
         * @return Retorna el mismo objeto pero con la llave primaria configurada
         */
        public VIEW_CIUDAD crearVIEW_CIUDAD(VIEW_CIUDAD obj)
        {
            List <VIEW_CIUDAD> lista = null;

            try
            {
                VIEW_CIUDADDao dao = new VIEW_CIUDADDao();
                conn = conexion.conection();
                dao.create(conn, obj);
                //verificar existencia
                lista = dao.search(conn, obj);
                if (lista != null && lista.Count > 0)
                {
                    obj = (VIEW_CIUDAD)lista[0];
                }
                else
                {
                    obj.ID = -1;
                }
            }
            catch (Exception e)
            {
                obj.ID = -1;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(obj);
        }
Esempio n. 4
0
        private List <VIEW_CIUDAD> listQuery(SqlCommand stmt)
        {
            List <VIEW_CIUDAD> searchResults = new List <VIEW_CIUDAD>();
            SqlDataReader      reader        = null;

            try
            {
                int intt = 0; long longg = 0; double doublee = 0; float floatt = 0; DateTime datee; byte[] bytee;
                reader = stmt.ExecuteReader();
                while (reader.Read())
                {
                    VIEW_CIUDAD temp = createValueObject();

                    temp.ID           = reader["ID"] != null && int.TryParse(reader["ID"].ToString(), out intt) ? intt : 0;
                    temp.DEPARTAMENTO = reader["DEPARTAMENTO"] != null ? reader["DEPARTAMENTO"].ToString() : null;
                    temp.CIUDAD       = reader["CIUDAD"] != null ? reader["CIUDAD"].ToString() : null;
                    searchResults.Add(temp);
                }
            }
            finally {
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
                if (stmt != null)
                {
                    stmt.Dispose();
                }
            }
            return(searchResults);
        }
Esempio n. 5
0
        public void delete(SqlConnection conn, VIEW_CIUDAD valueObject)
        {
            SqlCommand stmt = null;
            String     sql  = "";

            try
            {
                sql  = "DELETE FROM VIEW_CIUDAD WHERE ( id = @id )";
                stmt = new SqlCommand(sql, conn);
                stmt.Parameters.AddWithValue("@id", valueObject.ID);
                int rowcount = databaseUpdate(stmt);
                if (rowcount == 0)
                {
                    throw new Exception("Object could not be deleted! (PrimaryKey not found)");
                }
                if (rowcount > 1)
                {
                    throw new Exception("PrimaryKey Error when updating DB! (Many objects were deleted!)");
                }
            } finally {
                if (stmt != null)
                {
                    stmt.Dispose();
                }
            }
        }
Esempio n. 6
0
        private void getMunicipio()
        {
            frmMunicipios frm = new frmMunicipios();

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                myCiudad             = frm.MyCiudad;
                txtCiudad.Text       = myCiudad.CIUDAD;
                txtDepartamento.Text = myCiudad.DEPARTAMENTO;
            }
        }
Esempio n. 7
0
        public void save(SqlConnection conn, VIEW_CIUDAD valueObject)
        {
            SqlCommand stmt = null;
            String     sql  = "";

            try
            {
                sql = "UPDATE VIEW_CIUDAD SET ID = @ID ," +
                      " DEPARTAMENTO = @DEPARTAMENTO , CIUDAD = @CIUDAD  WHERE (id = @id)";
                stmt = new SqlCommand(sql, conn);


                if (!String.IsNullOrEmpty(valueObject.DEPARTAMENTO) && valueObject.DEPARTAMENTO.Length <= 30)
                {
                    stmt.Parameters.AddWithValue("@DEPARTAMENTO", valueObject.DEPARTAMENTO);
                }
                else
                {
                    stmt.Parameters.AddWithValue("@DEPARTAMENTO", DBNull.Value);
                }

                if (!String.IsNullOrEmpty(valueObject.CIUDAD) && valueObject.CIUDAD.Length <= 30)
                {
                    stmt.Parameters.AddWithValue("@CIUDAD", valueObject.CIUDAD);
                }
                else
                {
                    stmt.Parameters.AddWithValue("@CIUDAD", DBNull.Value);
                }

                stmt.Parameters.AddWithValue("@id", valueObject.ID);

                int rowcount = databaseUpdate(stmt);
                if (rowcount == 0)
                {
                    throw new Exception("Object could not be saved! (PrimaryKey not found)");
                }
            }
            finally
            {
                if (stmt != null)
                {
                    stmt.Dispose();
                }
            }
        }
Esempio n. 8
0
        public List <VIEW_CIUDAD> search(SqlConnection conn, VIEW_CIUDAD valueObject)
        {
            List <VIEW_CIUDAD> searchResults = new List <VIEW_CIUDAD>();
            bool   first = true;
            String sql   = "SELECT * FROM VIEW_CIUDAD WHERE 1=1 ";

            if (!String.IsNullOrEmpty(valueObject.ID.ToString()))
            {
                if (first)
                {
                    first = false;
                }
                sql += "AND ID= '" + valueObject.ID + "' ";
            }

            if (!String.IsNullOrEmpty(valueObject.DEPARTAMENTO))
            {
                if (first)
                {
                    first = false;
                }
                sql += "AND DEPARTAMENTO= '" + valueObject.DEPARTAMENTO + "' ";
            }

            if (!String.IsNullOrEmpty(valueObject.CIUDAD))
            {
                if (first)
                {
                    first = false;
                }
                sql += "AND CIUDAD= '" + valueObject.CIUDAD + "' ";
            }

            sql += "ORDER BY id ASC ";

            if (first)
            {
                searchResults = new List <VIEW_CIUDAD>();
            }
            else
            {
                searchResults = listQuery(new SqlCommand(sql, conn));
            }

            return(searchResults);
        }
Esempio n. 9
0
 private void txtCiudad_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (operacion != operation.VER)
     {
         if ((int)e.KeyChar == (int)Keys.Enter)
         {
             frmMunicipios frm = new frmMunicipios();
             if (frm.ShowDialog(this) == DialogResult.OK)
             {
                 myCiudad             = frm.MyCiudad;
                 txtCiudad.Text       = myCiudad.CIUDAD;
                 txtDepartamento.Text = myCiudad.DEPARTAMENTO;
                 Funciones.setFocus(txtCelular, e);
             }
         }
     }
 }
Esempio n. 10
0
        public void create(SqlConnection conn, VIEW_CIUDAD valueObject)
        {
            String     sql  = "";
            SqlCommand stmt = null;

            try
            {
                sql = "INSERT INTO VIEW_CIUDAD ( ID," +
                      " DEPARTAMENTO, CIUDAD)" +
                      "VALUES (@ID,@DEPARTAMENTO,@CIUDAD)";

                stmt = new SqlCommand(sql, conn);


                if (!String.IsNullOrEmpty(valueObject.DEPARTAMENTO) && valueObject.DEPARTAMENTO.Length <= 30)
                {
                    stmt.Parameters.AddWithValue("@DEPARTAMENTO", valueObject.DEPARTAMENTO);
                }
                else
                {
                    stmt.Parameters.AddWithValue("@DEPARTAMENTO", DBNull.Value);
                }

                if (!String.IsNullOrEmpty(valueObject.CIUDAD) && valueObject.CIUDAD.Length <= 30)
                {
                    stmt.Parameters.AddWithValue("@CIUDAD", valueObject.CIUDAD);
                }
                else
                {
                    stmt.Parameters.AddWithValue("@CIUDAD", DBNull.Value);
                }

                databaseUpdate(stmt);
            } finally {
                if (stmt != null)
                {
                    stmt.Dispose();
                }
            }
        }
        /**
         * Edita un registro en la tabla
         * @param VIEW_CIUDAD obj
         * @return boolean indicando si se realizo o no la actualizacion
         */
        public bool editarVIEW_CIUDAD(VIEW_CIUDAD obj)
        {
            bool resultado;

            resultado = false;
            try
            {
                VIEW_CIUDADDao dao = new VIEW_CIUDADDao();
                conn = conexion.conection();
                dao.save(conn, obj);
                resultado = true;
            }
            catch (Exception e)
            {
                resultado = false;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(resultado);
        }
Esempio n. 12
0
 private void seleccionarObjeto()
 {
     try
     {
         if (grdDatos.DataSource != null && grdDatos.Rows.Count > 0 && grdDatos.SelectedRows.Count > 0)
         {
             MyCiudad              = new VIEW_CIUDAD();
             MyCiudad.ID           = int.Parse(grdDatos.SelectedRows[0].Cells["ID"].Value.ToString());
             MyCiudad.DEPARTAMENTO = grdDatos.SelectedRows[0].Cells["DEPARTAMENTO"].Value.ToString();
             MyCiudad.CIUDAD       = grdDatos.SelectedRows[0].Cells["CIUDAD"].Value.ToString();
             this.DialogResult     = DialogResult.OK;
         }
         else
         {
             MyCiudad          = null;
             this.DialogResult = DialogResult.Cancel;
         }
     }
     catch (Exception exp)
     {
         MyCiudad          = null;
         this.DialogResult = DialogResult.Cancel;
     }
 }
 public bool eliminarVIEW_CIUDAD(VIEW_CIUDAD obj)
 {
     return(gestionVIEW_CIUDAD.eliminarVIEW_CIUDAD(obj));
 }
 public VIEW_CIUDAD[] buscarVIEW_CIUDAD(VIEW_CIUDAD obj)
 {
     return(gestionVIEW_CIUDAD.buscarVIEW_CIUDAD(obj));
 }
 public VIEW_CIUDAD buscarPrimeroVIEW_CIUDAD(VIEW_CIUDAD obj)
 {
     return(gestionVIEW_CIUDAD.buscarPrimeroVIEW_CIUDAD(obj));
 }
 public bool editarVIEW_CIUDAD(VIEW_CIUDAD obj)
 {
     return(gestionVIEW_CIUDAD.editarVIEW_CIUDAD(obj));
 }
 public VIEW_CIUDAD crearVIEW_CIUDAD(VIEW_CIUDAD obj)
 {
     return(gestionVIEW_CIUDAD.crearVIEW_CIUDAD(obj));
 }