Advertisement
Guest User

Untitled

a guest
May 9th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. using System.IO;
  2. using LibreriaDos.Classes.Libro;
  3. using LibreriaDos.Classes.lecturaEscritura;
  4.  
  5. namespace LibreriaDos.Classes.Usuarios
  6. {
  7. public class CVenderLibroDos
  8. {
  9. List<Usuario> UsuarioOne;
  10. List<CLibro> Book;
  11. PaginaPrincipal main;
  12. public static string pasarLibro;
  13.  
  14.  
  15. public CVenderLibroDos(PaginaPrincipal main)
  16. {
  17. this.main = main;
  18. string[] usuarios = Lectura.ReadFile(@"C:\Temporal\UsuariosLibreria.txt");
  19. UsuarioOne = Conversion.convertUser(usuarios);
  20.  
  21. //string[] libros = Lectura.ReadFile(@"C:\Temporal\Libros.txt");
  22. //Book = ConversionLibro.convertBook(libros);
  23.  
  24. }
  25.  
  26.  
  27.  
  28.  
  29. public void sellBook()
  30. {
  31. if ((main.txtUserSell.Text.ToString() != "") && (main.txtPassSell.Text.ToString() != ""))
  32. {
  33. if ((main.txtUserSell.Text == UsuarioOne[0].User) && (main.txtPassSell.Text == UsuarioOne[0].Contrasena))
  34. {
  35.  
  36. int venta = 10;
  37. UsuarioOne[0].Credito = UsuarioOne[0].Credito + venta; //Suma por la compra
  38. string CreditoUser = UsuarioOne[0].Credito.ToString(); //Convertirlo para ponerlo en el archivo de texto
  39.  
  40. pasarLibro = main.txtTitulo.Text;
  41.  
  42. System.IO.File.WriteAllText(@"C:\Temporal\Libros.txt", string.Empty);
  43. string locacion = @"C:\Temporal\Libros.txt";
  44. StreamWriter libro = new StreamWriter(locacion, true);
  45. List<string> listaLibro = new List<string>() {pasarLibro};
  46.  
  47. foreach (string l in listaLibro)
  48. {
  49. libro.WriteLine(pasarLibro);
  50. }
  51.  
  52. libro.Close();
  53.  
  54. string[] libros = Lectura.ReadFile(@"C:\Temporal\Libros.txt");
  55. Book = ConversionLibro.convertBook(libros);
  56.  
  57.  
  58. foreach(CLibro b in Book)
  59. {
  60. main.listLibros.Items.Add(b);
  61. }
  62. }
  63.  
  64. if ((main.txtUserSell.Text == UsuarioOne[1].User) && (main.txtPassSell.Text == UsuarioOne[1].Contrasena))
  65. {
  66.  
  67. int venta = 10;
  68. UsuarioOne[1].Credito = UsuarioOne[1].Credito + venta; //Suma por la compra
  69. string CreditoUser = UsuarioOne[1].Credito.ToString(); //Convertirlo para ponerlo en el archivo de texto
  70.  
  71. pasarLibro = main.txtTitulo.Text;
  72.  
  73. System.IO.File.WriteAllText(@"C:\Temporal\Libros.txt", string.Empty);
  74. string locacion = @"C:\Temporal\Libros.txt";
  75. StreamWriter libro = new StreamWriter(locacion, true);
  76. List<string> listaLibro = new List<string>() { pasarLibro };
  77.  
  78. foreach (string l in listaLibro)
  79. {
  80. libro.WriteLine(pasarLibro);
  81. }
  82.  
  83. libro.Close();
  84.  
  85. string[] libros = Lectura.ReadFile(@"C:\Temporal\Libros.txt");
  86. Book = ConversionLibro.convertBook(libros);
  87.  
  88.  
  89. foreach (CLibro b in Book)
  90. {
  91. main.listLibros.Items.Add(b);
  92. }
  93.  
  94. }
  95.  
  96. if ((main.txtUserSell.Text == UsuarioOne[2].User) && (main.txtPassSell.Text == UsuarioOne[2].Contrasena))
  97. {
  98.  
  99. int venta = 10;
  100. UsuarioOne[0].Credito = UsuarioOne[2].Credito + venta; //Suma por la compra
  101. string CreditoUser = UsuarioOne[2].Credito.ToString(); //Convertirlo para ponerlo en el archivo de texto
  102.  
  103. pasarLibro = main.txtTitulo.Text;
  104.  
  105. System.IO.File.WriteAllText(@"C:\Temporal\Libros.txt", string.Empty);
  106. string locacion = @"C:\Temporal\Libros.txt";
  107. StreamWriter libro = new StreamWriter(locacion, true);
  108. List<string> listaLibro = new List<string>() { pasarLibro };
  109.  
  110. foreach (string l in listaLibro)
  111. {
  112. libro.WriteLine(pasarLibro);
  113. }
  114.  
  115. libro.Close();
  116.  
  117. string[] libros = Lectura.ReadFile(@"C:\Temporal\Libros.txt");
  118. Book = ConversionLibro.convertBook(libros);
  119.  
  120.  
  121. foreach (CLibro b in Book)
  122. {
  123. main.listLibros.Items.Add(b);
  124. }
  125.  
  126. }
  127. }
  128. }
  129. }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement