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...");
            }
        }
Beispiel #2
0
        public static void PrintRecord(string studentIdToPrint)
        {
            try
            {
                SearchWebService.SearhWebServiceSoapClient client = new SearchWebService.SearhWebServiceSoapClient();
                SearchWebService.Student studentToPrint           = new SearchWebService.Student();
                studentToPrint = client.GetStudent(studentIdToPrint);


                int isThereRecord = client.FindRecord(studentToPrint.StudentId);
                if (isThereRecord != -1)
                {
                    Console.Write("Record is not found..");
                    return;
                }
                else
                {
                    Console.Write("Name: ");
                    Console.WriteLine(studentToPrint.Name);
                    Console.Write("Surname: ");
                    Console.WriteLine(studentToPrint.Surname);
                    Console.Write("Birthday: ");
                    Console.WriteLine(studentToPrint.Birthday.ToString().Substring(0, 10));
                    Console.Write("Student Id: ");
                    Console.WriteLine(studentToPrint.StudentId);
                    Console.Write("Gsm: ");
                    Console.WriteLine(studentToPrint.Gsm);
                    Console.WriteLine("\nAdresses\n");
                }

                for (int i = 1; i <= client.HowManyAdress(studentIdToPrint); i++)
                {
                    SearchWebService.Adress adressToPrint = new SearchWebService.Adress();
                    adressToPrint = client.GetAdress(studentIdToPrint, i);
                    Console.WriteLine("\n\tAdresses" + i.ToString());

                    Console.Write("\t\tStreet: ");
                    Console.WriteLine(adressToPrint.Street);
                    Console.Write("\t\tNeighbourhood: ");
                    Console.WriteLine(adressToPrint.Neighborhood);
                    Console.Write("\t\tDistrict: ");
                    Console.WriteLine(adressToPrint.District);
                    Console.Write("\t\tState: ");
                    Console.WriteLine(adressToPrint.State);
                }
            }

            catch (Exception exception)
            {
                LogOperation.LogProgram.Error(exception.Message);
                Console.WriteLine(exception.Message);
            }
        }
Beispiel #3
0
 public static bool AddAlternativeAddresses(string Id)
 {
     SearchWebService.SearhWebServiceSoapClient client = new SearchWebService.SearhWebServiceSoapClient();
     if (client.HowManyAdress(Id) == Constants.MAX_NUMBER_OF_ADRESS)
     {
         Console.WriteLine("You Have Already Add Three Adress. You Cannot Add More Adress Information");
         return(false);
     }
     else
     {
         ProgramSqlOperations.InsertAdress(GetAdress(), Id);
         return(true);
     }
 }
Beispiel #4
0
        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: ");
                    }
                }
            }
        }
Beispiel #6
0
        public static void SearchRecord()
        {
            Console.Write("\n>>>Search Record");

            Console.Write("\n\nStudentId to search: ");
            string studentIdToSearch = Utils.GetNumericValueWithValidation(Console.ReadLine(), "StudentId: ", "\nPlease Enter Valid StudentId with these format (#########)\n\n", true, 9);

            SearchWebService.SearhWebServiceSoapClient client = new SearchWebService.SearhWebServiceSoapClient();
            LogOperation.LogProgram.Info(" Student with id " + studentIdToSearch + " id searched by " + LoginProcess.loginedUser.UserName);
            if (client.FindRecord(studentIdToSearch) != -1)
            {
                Console.WriteLine("Record cannot found...");
            }
            else
            {
                PrintRecord(studentIdToSearch);
            }
        }
Beispiel #7
0
 public static void InsertAdress(Adress adressToInsert, string StudentIdToInsertAdress)
 {
     SearchWebService.SearhWebServiceSoapClient client = new SearchWebService.SearhWebServiceSoapClient();
     try
     {
         SqlCommand    sqlCommand;
         SqlConnection sqlConnection       = GeneralSqlConnection.CreateSqlConnection();
         string        queryToInsertAdress = "INSERT INTO [dbo].[Adresses] \n([StudentId],\n[AdressNo],\n[Street],\n[Neighbourhood],\n[District],\n[State_],\n[CreatedBy],\n[LastUpdatedBy])\n VALUES";
         queryToInsertAdress = queryToInsertAdress + "(" + "\n'" + StudentIdToInsertAdress + "'" + "\n,'" + (client.HowManyAdress(StudentIdToInsertAdress) + 1).ToString() + "'" + "\n,'" + adressToInsert.Street + "'" + "\n,'" + adressToInsert.Neighborhood + "'" + "\n,'" + adressToInsert.District + "'" + "\n,'" + adressToInsert.State + "'\n,'" + Program.LoginProcess.loginedUser.UserName + "'\n,'" + Program.LoginProcess.loginedUser.UserName + "')";
         sqlCommand          = new SqlCommand(queryToInsertAdress, sqlConnection);
         sqlCommand.ExecuteNonQuery();
         LogOperation.LogProgram.Info(" Adress added to student with " + StudentIdToInsertAdress + " id by " + LoginProcess.loginedUser.UserName);
         sqlConnection.Close();
         return;
     }
     catch (Exception exception)
     {
         LogOperation.LogProgram.Info(exception.Message);
         Console.WriteLine(exception.Message);
         return;
     }
 }