public int Registrar(CEmpleado empleado, ref bool ResultadoOK, ref string MensajeError) { CRegistro objRegistro = new CRegistro(); objRegistro.Registro(empleado, ref ResultadoOK, ref MensajeError); return(Empleado_ID); }
public HttpResponseMessage Registrar(CRegistro pModelo) { HttpResponseMessage respuesta = null; CCoinPaymentMessage resultado = new CCoinPaymentMessage(); try { CripMonEntities db = new CripMonEntities(); db.PA_Usuario(pModelo.vNombreUsuario, pModelo.vNombres, pModelo.vApellidos, pModelo.vCorreoElectronico, pModelo.vContrasena, pModelo.vPatrocinador, pModelo.vCarteraCryptoMoneda); respuesta = Request.CreateResponse(HttpStatusCode.OK, true); } catch (Exception ex) { respuesta = Request.CreateErrorResponse(HttpStatusCode.Conflict, (ex.InnerException == null) ? ex.Message : ex.InnerException.Message); } return(respuesta); }
protected void Page_Load(object sender, EventArgs e) { if (Global.empleado != null) { if (Global.empleado.IdCargo == 1) { cEmpleado = new CEmpleado(); cCliente = new CCliente(); cMercaderia = new CMercaderia(); cRegistro = new CRegistro(); obj = new ClassAdo(); objConexion = new ObjConexion(Constantes.BASE_DE_DATOS, Constantes.USER_ADM, Constantes.USER_ADM_PASS, Constantes.SERVIDOR); if (!this.IsPostBack) { this.BindGrid(); } numEmpleados = cEmpleado.obtenerNumEmpleados(objConexion); numClientes = cCliente.obtenerNumClientes(objConexion); numMercaderias = cMercaderia.obtenerNumMercaderias(objConexion); numRegistros = cRegistro.obtenerNumGuias(objConexion); } else { Response.Redirect("~/default.aspx"); } } else { Response.Redirect("~/default.aspx"); } }
} // número de registros public bool ponerValorEn(int i, CRegistro objeto) { if (i >= 0 && i <= nregs) { // Los 1 o 2 primeros bytes que escribe Write indican la // longitud de la cadena que escribe a continuación, // información utilizada por ReadString para recuperarla. if (objeto.tamaño() + 2 > tamañoReg) { Console.WriteLine("tamaño del registro excedido"); } else { // Situar el puntero de L/E en el registro i. bw.BaseStream.Seek(i * tamañoReg, SeekOrigin.Begin); // Sobreescribir el registro con la nueva información bw.Write(objeto.obtenerReferencia()); bw.Write(objeto.obtenerPrecio()); return(true); } } else { Console.WriteLine("número de registro fuera de límites"); } return(false); }
public static void visualizarRegs() { int nreg = -1, nregs = artículos.longitud(); if (nregs == 0) { Console.WriteLine("lista vacía"); } Console.Write("conjunto de caracteres a buscar: "); string str = Console.ReadLine(); CRegistro obj = null; do { nreg = artículos.buscar(str, nreg + 1); if (nreg > -1) { obj = artículos.valorEn(nreg); Console.WriteLine("Registro: " + nreg); Console.WriteLine(obj.obtenerReferencia()); Console.WriteLine(obj.obtenerPrecio()); Console.WriteLine(); } }while (nreg != -1); if (obj == null) { Console.WriteLine("no se encontró ningún registro"); } }
public void copiar(string fichero1, string fichero2) { // Copiar fichero2 en fichero1 // Verificar si el fichero existe if (File.Exists(fichero2)) { // Si existe, abrir un flujo desde el mismo para leer br2 = new BinaryReader(new FileStream( fichero2, FileMode.Open, FileAccess.Read)); } else { Console.WriteLine("El fichero " + fichero2 + " no existe"); return; } // Abrir un flujo hacia el fichero1 bw = new BinaryWriter(new FileStream( fichero1, FileMode.Create, FileAccess.Write)); // Variable para leer desde el fichero2 CRegistro regF2 = new CRegistro(); try { while (true) { // Leer del fichero2 regF2.nombre = br2.ReadString(); regF2.nota = br2.ReadSingle(); // Escribir en el fichero1 if (regF2.nota != -1) { bw.Write(regF2.nombre); bw.Write(regF2.nota); } } } catch (EndOfStreamException) { Console.WriteLine("Fin de la copia"); } finally { // Cerrar flujos if (br2 != null) { br2.Close(); } if (bw != null) { bw.Close(); } // Borrar el fichero temporal File.Delete(fichero2); } }
public JsonResult Registrar(CRegistro modelo) { try { if (modelo != null) { IRestResponse WSR = Task.Run(() => api.Put("Seguridad/Registrar", modelo)).Result; if (WSR.StatusCode == HttpStatusCode.OK) { bool result = false; bool.TryParse(WSR.Content, out result); Autenticar(new CInicioSesion() { vNombreUsuario = modelo.vNombreUsuario, vContrasena = modelo.vContrasena }); return(new JsonResult() { Data = result, ContentType = "json", MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return(new JsonResult() { Data = WSR.Content, ContentType = "json", MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } else { return(new JsonResult() { Data = "El modelo viene nulo", ContentType = "json", MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { return(new JsonResult() { Data = ex.Message, ContentType = "json", MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public static void modificarReg() { string referencia; double precio; int op, nreg; // Solicitar el número de registro a modificar Console.Write("Número de registro entre 0 y " + (artículos.longitud() - 1) + ": "); nreg = Leer.datoInt(); // Leer el registro CRegistro obj = artículos.valorEn(nreg); if (obj == null) { return; } // Visualizarlo Console.WriteLine(obj.obtenerReferencia()); Console.WriteLine(obj.obtenerPrecio()); // Modificar el registro do { Console.Write("\n\n"); Console.WriteLine("Modificar el dato:"); Console.WriteLine("1. Referencia"); Console.WriteLine("2. Precio"); Console.WriteLine("3. Salir y salvar los cambios"); Console.WriteLine("4. Salir sin salvar los cambios"); Console.WriteLine(); Console.Write(" Opción: "); op = Leer.datoInt(); switch (op) { case 1: // modificar referencia Console.Write("Referencia: "); referencia = Console.ReadLine(); obj.asignarReferencia(referencia); break; case 2: // modificar precio Console.Write("Precio: "); precio = Leer.datoDouble(); obj.asignarPrecio(precio); break; case 3: // guardar los cambios artículos.ponerValorEn(nreg, obj); return; case 4: // salir sin guardar los cambios break; } }while(op != 4); }
public void añadir(CRegistro obj) { // Añadir un registro al final del fichero e incrementar // el número de registros if (ponerValorEn(nregs, obj)) { nregs++; } }
protected void Page_Load(object sender, EventArgs e) { if (Global.empleado != null) { idEmpleado = Global.empleado.IdEmpleado; cRegistro = new CRegistro(); cTipoRegistro = new CTipoRegistro(); cMercaderia = new CMercaderia(); cCliente = new CCliente(); obj = new ClassAdo(); objConexion = new ObjConexion(Constantes.BASE_DE_DATOS, Constantes.USER_ADM, Constantes.USER_ADM_PASS, Constantes.SERVIDOR); clientes = cCliente.obtenerListaClientes(objConexion); if (!this.IsPostBack) { this.BindGrid(); txtFecha.Text = DateTime.Now.ToShortDateString(); txtFecha.Enabled = false; dataSet = cTipoRegistro.obtenerTiposRegistro(objConexion); //Itera sobre la lista para llenar la dropdownlist foreach (DataTable table in dataSet.Tables) { foreach (DataRow dr in table.Rows) { string idTipo = dr["idTipoRegistro"].ToString(); string descripcion = dr["descripcionTipo"].ToString(); listaTipo.Items.Add(new ListItem(descripcion, idTipo)); } } dataSet.Clear(); cTipoRegistro.closeConexion(); //Itera sobre la lista de clientes para llenar la dropdownlist foreach (Cliente clien in clientes) { listaCliente.Items.Add(new ListItem(clien.NombreEmpresa, clien.IdCliente + "")); foreach (CAPA_DATOS.Mercaderia merca in clien.Mercaderias) { //listaMercaderia.Items.Add(new ListItem(merca.Descripcion, merca.IdMercaderia + "")); } } cCliente.closeConexion(); } } else { Response.Redirect("~/default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { cRegistro = new CRegistro(); ado = new ClassAdo(); objConexion = new ObjConexion(Constantes.BASE_DE_DATOS, Constantes.USER_ADM, Constantes.USER_ADM_PASS, Constantes.SERVIDOR); if (!this.IsPostBack) { this.BindGrid(); } }
public void fusionar() { // Variable para leer desde el fichero1 CRegistro regF1 = new CRegistro(); bool finFichero1 = false; // Variable para leer desde el fichero2 CRegistro regF2 = new CRegistro(); bool finFichero2 = false; int i; // resultado de una comparación try { // Leer un un nombre y una nota desde el fichero1. // Cuando se alcance el final del fichero C# // lanzará una excepción del tipo EndOfStreamException. regF1.nombre = br1.ReadString(); regF1.nota = br1.ReadSingle(); // Leer un un nombre y una nota desde el fichero2. // Cuando se alcance el final del fichero C# // lanzará una excepción del tipo EndOfStreamException. regF2.nombre = br2.ReadString(); regF2.nota = br2.ReadSingle(); while (true) { if (finFichero1 && finFichero2) { break; } i = regF1.nombre.CompareTo(regF2.nombre); // Forzar el resultado de la comparación a un valor // determinado si alguno de los dos ficheros finalizó, // para que lea y grabe del que aún no finalizó. if (finFichero1) { i = 1; } else if (finFichero2) { i = -1; } if (i == 0) // regF1.nombre == regF2.nombre { // El mismo alumno. Grabar regF2 bw.Write(regF2.nombre); bw.Write(regF2.nota); // Leer de nuevo de ambos ficheros try { regF1.nombre = br1.ReadString(); regF1.nota = br1.ReadSingle(); } catch (EndOfStreamException) { Console.WriteLine("Fin del fichero1"); finFichero1 = true; } try { regF2.nombre = br2.ReadString(); regF2.nota = br2.ReadSingle(); } catch (EndOfStreamException) { Console.WriteLine("Fin del fichero2"); finFichero2 = true; } continue; } else if (i > 0) // regF1.nombre > regF2.nombre { // Grabar regF2 bw.Write(regF2.nombre); bw.Write(regF2.nota); // Leer de nuevo de fichero2 try { regF2.nombre = br2.ReadString(); regF2.nota = br2.ReadSingle(); } catch (EndOfStreamException) { Console.WriteLine("Fin del fichero2"); finFichero2 = true; } continue; } else // regF2.nombre > regF1.nombre { // Grabar regF1 bw.Write(regF1.nombre); bw.Write(regF1.nota); // Leer de nuevo de fichero1 try { regF1.nombre = br1.ReadString(); regF1.nota = br1.ReadSingle(); } catch (EndOfStreamException) { Console.WriteLine("Fin del fichero1"); finFichero1 = true; } } } } catch (EndOfStreamException) { Console.WriteLine("Fin del fichero1 y fichero2"); } finally { // Cerrar flujos if (br1 != null) { br1.Close(); } if (br2 != null) { br2.Close(); } if (bw != null) { bw.Close(); } // Copiar en el fichero alumnos todos los registros del temporal // excepto los que en el campo nota tengan -1. copiar("alumnos", "temporal"); } }
public static void estadística(string fichero) { BinaryReader br = null; // flujo entrada de datos //desde el fichero // Declarar contadores int ss = 0, ap = 0, nt = 0, sb = 0, total = 0; try { if (File.Exists(fichero)) { // Si existe, abrir un flujo desde el mismo para leer br = new BinaryReader(new FileStream( fichero, FileMode.Open, FileAccess.Read)); // Declarar variables CRegistro reg = new CRegistro(); string calificación; do { // Leer un nº de matrícula, un nombre y una calificación desde // el fichero. Cuando se alcance el final del fichero C# // lanzará una excepción del tipo EndOfStreamException. reg.asignarNumMat(br.ReadInt32()); reg.asignarNombre(br.ReadString()); reg.asignarCalificación(br.ReadString()); // Contar SS, AP, NT y SB calificación = reg.obtenerCalificación(); if (calificación.CompareTo("SS") == 0) { ss++; } else if (calificación.CompareTo("AP") == 0) { ap++; } else if (calificación.CompareTo("NT") == 0) { nt++; } else if (calificación.CompareTo("SB") == 0) { sb++; } }while (true); } else { Console.WriteLine("El fichero no existe"); } } catch (EndOfStreamException) { Console.WriteLine("Fin del fichero"); total = ss + ap + nt + sb; Console.WriteLine("Suspensos: " + (100F * ss / total) + "%"); Console.WriteLine("Aprobados: " + (100F * ap / total) + "%"); Console.WriteLine("Notables: " + (100F * nt / total) + "%"); Console.WriteLine("Sobresalientes: " + (100F * sb / total) + "%"); } finally { // Cerrar el flujo if (br != null) { br.Close(); } } }