public static void UpdateRecord() { Console.Write("\n>>>Update Record"); SearchWebService.SearhWebServiceSoapClient client = new SearchWebService.SearhWebServiceSoapClient(); Console.Write("\n\nEnter Student Id to Update: "); string studentIdToUpdate = Utils.GetNumericValueWithValidation(Console.ReadLine(), "StudentId: ", "\nPlease Enter Valid StudentId with these format (#########)\n\n", true, 9); int isRecord = client.FindRecord(studentIdToUpdate); if (isRecord != -1) { Console.WriteLine("\n...Record cannot be found...\n"); return; } else { SearchFindPrintOperations.PrintRecord(studentIdToUpdate); Student studentToUpdate = new Student(); studentToUpdate = StudentOperations.GetStudentInformations(false, studentIdToUpdate); ProgramSqlOperations.UpdateStudent(studentToUpdate, studentIdToUpdate); string choice = "-1"; while (choice != "9") { Console.WriteLine("\nEnter Adress Number To Update || 9-EXIT"); choice = Console.ReadLine(); if (choice == "1") { AdressOperations.UpdateAddresses(studentIdToUpdate, 1); } else if (client.HowManyAdress(studentIdToUpdate) < Convert.ToInt32(choice) && Convert.ToInt32(choice) <= Constants.MAX_NUMBER_OF_ADRESS) { Console.Write("\nThere is no adress" + choice + ". Please enter valid address number or press 0 to add new adress"); choice = Console.ReadLine(); if (choice == "0") { AdressOperations.AddAlternativeAddresses(studentIdToUpdate); } } else if (client.HowManyAdress(studentIdToUpdate) > Convert.ToInt32(choice) - 1 && Convert.ToInt32(choice) <= Constants.MAX_NUMBER_OF_ADRESS) { AdressOperations.UpdateAddresses(studentIdToUpdate, Convert.ToInt32(choice)); } else if (choice == "9") { break; } else { Console.WriteLine("\nPlease enter valid number..."); } } Console.WriteLine("...Record Updated..."); } }
public static string AddingId() { string toReturnStudentId = Utils.GetNumericValueWithValidation(Console.ReadLine(), "StudentId: ", "\nPlease Enter Valid StudentId with these format (#########)\n\n", true, 9); bool isUniqueId = true; while (isUniqueId) { SearchWebService.SearhWebServiceSoapClient client = new SearchWebService.SearhWebServiceSoapClient(); if (client.FindRecord(toReturnStudentId) == -1) { Console.WriteLine("...This Student Id Has Already Recorded...\n\n"); SearchFindPrintOperations.PrintRecord(toReturnStudentId); Console.WriteLine("\n...Do You Want To Enter Another Id (Y/N)..."); bool condition = true; while (condition) { string yes_no = Console.ReadLine(); if (yes_no == "Y" || yes_no == "y") { Console.Write("Student Id: "); toReturnStudentId = Utils.GetNumericValueWithValidation(Console.ReadLine(), "StudentId: ", "\nPlease Enter Valid StudentId with these format (#########)\n\n", true, 9); condition = false; } else if (yes_no == "N" || yes_no == "n") { toReturnStudentId = "false"; condition = false; return(toReturnStudentId); } else { Console.WriteLine("Please Enter Y or N: "); } } } else { isUniqueId = false; } } return(toReturnStudentId); }
public static void RemoveRecord() { Console.Write("\n>>>Remove Record"); Console.Write("\n\nStudentId to remove: "); string studentIdToRemove = Utils.GetNumericValueWithValidation(Console.ReadLine(), "StudentId: ", "\nPlease Enter Valid StudentId with these format (#########)\n\n", true, 9); SearchWebService.SearhWebServiceSoapClient client = new SearchWebService.SearhWebServiceSoapClient(); int isRecord = client.FindRecord(studentIdToRemove); if (isRecord != -1) { Console.WriteLine("\n...Record cannot be found...\n"); return; } else { SearchFindPrintOperations.PrintRecord(studentIdToRemove); Console.WriteLine("Are you sure Y/N: "); bool condition = true; while (condition) { string yes_no = Console.ReadLine(); if (yes_no == "Y" || yes_no == "y") { ProgramSqlOperations.DeleteRecords(studentIdToRemove); Console.WriteLine("\n...Record Removed...\n"); condition = false; } else if (yes_no == "N" || yes_no == "n") { Console.WriteLine("\n...Record Remove Canceled...\n"); condition = false; return; } else { Console.WriteLine("\nPlease Enter Y or N: "); } } } }
public static void RecordSystemMenu() { Console.WriteLine("Welcome " + LoginProcess.loginedUser.Name + " " + LoginProcess.loginedUser.Surname); string choice = "-1"; while (choice != "9") { Console.WriteLine("\n<<<<< Please Choose One The Operation (1-ADD | 2-UPDATE | 3-REMOVE | 4-SEARCH | 9-EXIT) >>>>>"); Console.Write("\nOperation>> "); choice = Console.ReadLine(); switch (choice) { case "1": AddOperations.AddRecord(); break; case "2": UpdateOperations.UpdateRecord(); break; case "3": RemoveOperations.RemoveRecord(); break; case "4": SearchFindPrintOperations.SearchRecord(); break; case "9": LoginProcess.logOutDate = DateTime.Now; LogOperation.LogProgram.Info(LoginProcess.loginedUser.UserName + " logout."); Console.WriteLine("...Exit..."); break; default: Console.WriteLine("Please Enter Valid Operation Number\n"); break; } } }