private static void UpdateProcedure(string connect) { int id = MyConsole.GetNumber("Enter the Id:"); string name = MyConsole.GetString("Enter the Name: "); string address = MyConsole.GetString("Enter the Address:"); SqlConnection dbConnection = new SqlConnection(connect); SqlCommand command = new SqlCommand("EmpUpdate", dbConnection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@param1", id); command.Parameters.AddWithValue("@param2", name); command.Parameters.AddWithValue("@param3", address); try { //open Connection dbConnection.Open(); command.ExecuteNonQuery(); } catch (SqlException) { Console.WriteLine("Someting went wrong"); } finally { dbConnection.Close(); } }
private static void addTravelDetails() { if (blog.CurrentUser == null) { Console.WriteLine("U have not logged in to Post a Travel Info"); Console.WriteLine("Please login to add new details"); return; } Travel details = new Travel(); details.NoOfDays = MyConsole.GetNumber("Enter the No of days of Travel"); details.ModeOfTransport = MyConsole.GetMode(); details.DateOfTravel = MyConsole.GetDate("Enter the date as dd/MM/yyyy"); details.Destination = MyConsole.GetString("Enter UR place of Visit"); details.UserDetails = blog.CurrentUser; details.Details = MyConsole.GetString("Please enter UR Experience in the Travel to be shared to all our visitors"); try { blog.AddTravelDetails(details); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private static void UpdateRecords(string connect, string updateQuery) { int id = MyConsole.GetNumber("Enter the Id:"); string name = MyConsole.GetString("Enter the Name: "); string address = MyConsole.GetString("Enter the Address:"); SqlConnection dbConnection = new SqlConnection(connect); SqlCommand command = new SqlCommand(updateQuery, dbConnection); command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@Name", name); command.Parameters.AddWithValue("@Address", address); try { //open Connection dbConnection.Open(); command.ExecuteNonQuery(); } catch (SqlException) { Console.WriteLine("Someting went wrong"); } finally { dbConnection.Close(); } }
private static void DeleteRecords(string connect, string deletequery) { int id = MyConsole.GetNumber("Enter the Id:"); SqlConnection dbConnection = new SqlConnection(connect); SqlCommand command = new SqlCommand(deletequery, dbConnection); command.Parameters.AddWithValue("@id", id); try { //open Connection dbConnection.Open(); command.ExecuteNonQuery(); } catch (SqlException) { Console.WriteLine("Someting went wrong"); } finally { dbConnection.Close(); } }
private static void registerUser() { int userId = MyConsole.GetNumber("Enter user id: "); string username = MyConsole.GetString("Enter username:"******"Enter password: "); userCredentials.RegisterNewUser(new User { UserID = userId, UserName = username, Password = password }); //throw new NotImplementedException(); }
private static void signUpFeature() { int userID = MyConsole.GetNumber("Enter the UserID"); string username = MyConsole.GetString("Enter the Username"); string password = MyConsole.GetString("Enter the password"); string retype = MyConsole.GetString("Retype the pasword"); if (password != retype) { Console.WriteLine("Password mismatch"); return; } try { IUserLog log = new UserLog(); log.RegisterNewUser(new User { UserID = userID, UserName = username, Password = password }); } catch (Exception ex) { Console.WriteLine(ex.Message); } }