public static void Edit() { string vname, vlast; Console.Write("Ingrese su nombre: "); vname = Editor.Input(false); Console.WriteLine(vname); Console.Write("Ingrese su apellido: "); vlast = Editor.Input(false); Console.WriteLine(vlast); if (!Editor.Srch(ref vname, ref vlast)) { Console.WriteLine("Error, la persona no existe, no se puede editar"); } else { int vopc, vloc; vloc = Editor.Find(vname + vlast); Console.WriteLine("\t\tQue desea editar?"); Console.WriteLine("1)Edad"); Console.WriteLine("2)Balance"); Console.WriteLine("3)Sexo"); Console.WriteLine("4)Licencia"); Console.WriteLine("5)Auto"); Console.WriteLine("6)Estado"); Console.WriteLine("7)Contraseña"); Console.Write("Escoja un numero: "); vopc = Editor.Number(); switch (vopc) { case 1: Console.Write("Ingrese su edad: "); int v5 = Editor.Number(); Console.WriteLine(v5); Editor.ReAge(vloc, v5); break; case 2: Console.Write("Ingrese su balance: "); decimal vbalance = Editor.PNumber(); Console.WriteLine(vbalance); Editor.Change(vloc, 2, vbalance.ToString()); break; case 3: int v1; Console.Write("Masculino/Femenino[m/f]: "); string vsex = Editor.Input(false); if (vsex == "m") { v1 = 1 | Editor.Extract(vloc); } else { v1 = ~1 & Editor.Extract(vloc); } Editor.Insert(vloc, v1); break; case 4: int v2; Console.Write("Tiene licencia de conducir?[s/n]: "); string vlic = Editor.Input(false); if (vlic == "s") { v2 = (2 | Editor.Extract(vloc)); } else { v2 = ~2 & Editor.Extract(vloc); } Editor.Insert(vloc, v2); break; case 5: int v3; Console.Write("Tiene auto?[s/n]: "); string vcar = Editor.Input(false); if (vcar == "s") { v3 = 4 | Editor.Extract(vloc); } else { v3 = ~4 & Editor.Extract(vloc); } Editor.Insert(vloc, v3); break; case 6: int v4; Console.Write("Esta activo?[s/n]: "); string vact = Editor.Input(false); if (vact == "s") { v4 = 8 | Editor.Extract(vloc); } else { v4 = ~8 & Editor.Extract(vloc); } Editor.Insert(vloc, v4); break; case 7: Console.Write("Ingrese su contraseña: "); string vpass = Editor.Input(true); Console.Write("Confirme su contraseña: "); string vconf = Editor.Input(true); if (vpass != vconf) { do { Console.Write("Las contraseñas no son iguales, desear insertar de nuevo [s/n]: "); string vsel = Editor.Input(false); if (vsel == "s") { Console.Write("Confirme de nuevo: "); vconf = Editor.Input(true); } else { break; } } while (vpass != vconf); } if (vpass == vconf) { Editor.Change(vloc, 3, vpass); } break; default: break; } } }
public static void Add() { string vloop; do { string vname, vlast; do { Console.Write("Ingrese su nombre: "); vname = Editor.Input(false); Console.WriteLine(vname); Console.Write("Ingrese su apellido: "); vlast = Editor.Input(false); Console.WriteLine(vlast); if (Editor.Srch(ref vname, ref vlast)) { Console.WriteLine("Error, la persona ya existe"); } else { break; } } while (true); Console.Write("Ingrese su edad: "); int v5 = Editor.Number(); Console.WriteLine(v5); Console.Write("Ingrese su balance: "); decimal vbalance = Editor.PNumber(); Console.WriteLine(vbalance); #region Codificacion int v1 = 0, v2 = 0, v3 = 0, v4 = 0; Console.Write("Masculino/Femenino[m/f]: "); string vsex = Editor.Input(false); if (vsex == "m") { v1 = 1; } else { } Console.Write("Tiene licencia de conducir?[s/n]: "); string vlic = Editor.Input(false); if (vlic == "s") { v2 = 2; } else { } Console.Write("Tiene auto?[s/n]: "); string vcar = Editor.Input(false); if (vcar == "s") { v3 = 4; } else { } Console.Write("Esta activo?[s/n]: "); string vact = Editor.Input(false); if (vact == "s") { v4 = 8; } else { } int vdatos = (v1 | v2 | v3 | v3 | v4) | (v5 << 4); #endregion Console.Write("Ingrese su contraseña: "); string vpass = Editor.Input(true); Console.Write("Confirme su contraseña: "); string vconf = Editor.Input(true); if (vpass != vconf) { do { Console.Write("Las contraseñas no son iguales, desear insertar de nuevo [s/n]: "); string vopc = Editor.Input(false); if (vopc == "s") { Console.Write("Confirme de nuevo: "); vconf = Editor.Input(true); } else { break; } } while (vpass != vconf); } if (vpass == vconf) { File.AppendAllText(vpath, $"{vname},{vlast},{vbalance.ToString()},{vpass},{vdatos.ToString()}" + Environment.NewLine); } Console.Write("Desea registrar algun otro dato[s/n]? "); vloop = Editor.Input(false); Console.Clear(); } while (vloop == "s"); }
static void Main(string[] args) { if (!File.Exists(vpath)) { File.AppendAllText(vpath, "Nombre,Apellido,Balance,Contraseña,Datos" + Environment.NewLine); } if (args.Length > 0 && args[0] == "--r") { string[] Lines = File.ReadAllLines(vpath); for (int i = 1; i < Lines.Length; i++) { string[] vline = Lines[i].Split(','); int.TryParse(vline[4], out int vprocess); string psex, plic, pcar, pact; if ((vprocess & 1) == 1) { psex = "masculino"; } else { psex = "femenino"; } if ((vprocess & 2) == 2) { plic = "tiene licencia"; } else { plic = "no tiene licencia"; } if ((vprocess & 4) == 4) { pcar = "tiene auto"; } else { pcar = "no tiene auto"; } if ((vprocess & 8) == 8) { pact = "esta activo"; } else { pact = "no esta activo"; } Console.WriteLine($"{vline[0]}, {psex}, {plic}, {pcar}, {pact}, {vprocess >> 4 ^ 0}"); } } else { int vopc; Console.WriteLine("\t\tMenu"); Console.WriteLine("1)Editar"); Console.WriteLine("2)Agregar"); Console.Write("Escoja una opcion [1/2]: "); vopc = Editor.Number(); Console.Clear(); switch (vopc) { case 1: Menu.Edit(); break; case 2: Menu.Add(); break; default: break; } } }