GithubHelp home page GithubHelp logo

consoleapplication's Introduction

using System; using System.Collections.Generic; using System.Text; using System.Data.SqlClient;

namespace EmployeeManagementSystem { class UpdateEmployeeDetails { public SqlConnection connection = null; public UpdateEmployeeDetails() { EmployeeProject employeeProject = new EmployeeProject();

        Console.WriteLine(" 1.Update EmployeeName\n " +
                        "2.Update Email\n " +
                        "3.Update EmployeeId\n " +
                         "4.Update PhoneNumber\n " +
                        "5.Update DateOfBirth\n " +
                        "6.Update DateOfJoining\n ");

        int choose = Convert.ToInt32(Console.ReadLine());

        switch(choose)
        {
            case 1:
               
                try
                {
                   
                    string ID = employeeProject.AddEmployeeID();
                    connection = new SqlConnection(@"Data Source = RANJITH\MSSQLSERVERR; Initial Catalog = Employeee; Integrated Security = True");
                    
                    SqlCommand command = new SqlCommand("UPDATE Employee SET   EmployeeName ='" + employeeProject.AddEmployeeName() + "'WHERE EmployeeId ='" + ID + "';", connection);
                    
                   
                    connection.Open();
                     
                    command.ExecuteNonQuery();
                    Console.WriteLine("Record Deleted Successfully \n");
                }
                catch (Exception e)
                {
                    Console.WriteLine("OOPs, something went wrong.\n" + e);
                }
         
                finally
                {
                    connection.Close();
                }

                break;
            case 2:
                
                try
                {
                 
                    string ID = employeeProject.AddEmployeeID();
                    connection = new SqlConnection(@"Data Source = RANJITH\MSSQLSERVERR; Initial Catalog = Employeee; Integrated Security = True");

                    SqlCommand cm = new SqlCommand("UPDATE Employee SET   Email ='" + employeeProject.AddEmail() + "'WHERE EmployeeId ='" + ID + "';", connection);

                    connection.Open();

                    cm.ExecuteNonQuery();
                    Console.WriteLine("Record Deleted Successfully \n");
                }
                catch (Exception e)
                {
                    Console.WriteLine("OOPs, something went wrong.\n" + e);
                }

                finally
                {
                    connection.Close();
                }

                break;
            case 3:
                try
                {
                    
                    string Email = employeeProject.AddEmail();
                    connection = new SqlConnection(@"Data Source = RANJITH\MSSQLSERVERR; Initial Catalog = Employeee; Integrated Security = True"); 
                    SqlCommand cm = new SqlCommand("UPDATE Employee SET   EmployeeId ='" + employeeProject.AddEmployeeID() + "'WHERE Email ='" + Email + "';", connection);
                    connection.Open();
                    cm.ExecuteNonQuery();
                    Console.WriteLine("Record Deleted Successfully \n");
                }
                catch (Exception e)
                {
                    Console.WriteLine("OOPs, something went wrong.\n" + e);
                }

                finally
                {
                    connection.Close();
                }

                break;
            case 4:
                try
                {
                
                    string ID = employeeProject.AddEmployeeID(); ;
                    connection = new SqlConnection(@"Data Source = RANJITH\MSSQLSERVERR; Initial Catalog = Employeee; Integrated Security = True");
                    SqlCommand cm = new SqlCommand("UPDATE Employee SET  PhoneNumber ='" +employeeProject.AddEmployeePhoneNumber()+ "'WHERE EmployeeId ='" + ID + "';", connection);
                    connection.Open();

                    cm.ExecuteNonQuery();
                    Console.WriteLine("Record Deleted Successfully \n");
                }
                catch (Exception e)
                {
                    Console.WriteLine("OOPs, something went wrong.\n" + e);
                }

                finally
                {
                    connection.Close();
                }


                break;
            case 5:
                try
                {
                  
                    string ID = employeeProject.AddEmployeeID(); ;
                    connection = new SqlConnection(@"Data Source = RANJITH\MSSQLSERVERR; Initial Catalog = Employeee; Integrated Security = True");

                    SqlCommand cm = new SqlCommand("UPDATE Employee SET   DateOfBirth ='" + employeeProject.AddDateOfBirth() + "'WHERE EmployeeId ='" + ID + "';", connection);
                    connection.Open();

                    cm.ExecuteNonQuery();
                    Console.WriteLine("Record Deleted Successfully \n");
                }
                catch (Exception e)
                {
                    Console.WriteLine("OOPs, something went wrong.\n" + e);
                }

                finally
                {
                    connection.Close();
                }
                break;
            case 6:
                try
                {
                  
                    string ID = employeeProject.AddEmployeeID(); ;
                    connection = new SqlConnection(@"Data Source = RANJITH\MSSQLSERVERR; Initial Catalog = Employeee; Integrated Security = True");
                    SqlCommand cm = new SqlCommand("UPDATE Employee SET   DateOfjoin ='" + employeeProject.AddDateOfJoining() + "'WHERE EmployeeId ='" + ID + "';", connection);

                    connection.Open();

                    cm.ExecuteNonQuery();
                    Console.WriteLine("Record Deleted Successfully \n");
                }
                catch (Exception e)
                {
                    Console.WriteLine("OOPs, something went wrong.\n" + e);
                }

                finally
                {
                    connection.Close();
                }
                break;
               
            default:
                Console.WriteLine("Enter Valid InPut \n");
               
                break;
        }
    }
}

}

consoleapplication's People

Contributors

vidhyapriyav avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.