예제 #1
0
        public static void DeleteRecord(int id)
        {
            SqlConnection connDB = UtilityDB.ConnectDB();
            SqlCommand    cmd    = new SqlCommand();

            cmd.Connection  = connDB;
            cmd.CommandText = "delete from [User] where UserId=@UserId";
            cmd.Parameters.AddWithValue("@UserId", id);
            cmd.ExecuteNonQuery();
            connDB.Close();
        }
예제 #2
0
        public static bool IsUniqueId(int tempId)
        {
            SqlConnection connDB = UtilityDB.ConnectDB();
            SqlCommand    cmd    = new SqlCommand();

            cmd.Connection  = connDB;
            cmd.CommandText = "SELECT * FROM [User] " +
                              " WHERE UserId =" + tempId;
            int id = Convert.ToInt32(cmd.ExecuteScalar());

            if (id != 0)
            {
                connDB.Close();
                return(false);
            }
            connDB.Close();
            return(true);
        }
예제 #3
0
        public static void UpdateRecord(User emp)
        {
            SqlConnection connDB = UtilityDB.ConnectDB();
            SqlCommand    cmd    = new SqlCommand();

            cmd.Connection  = connDB;
            cmd.CommandText = "Update [User] " +
                              "SET FirstName = @FirstName," +
                              " LastName = @LastName," +
                              " JobTitle = @JobTitle " +
                              " WHERE UserId = @UserId ";
            cmd.Parameters.AddWithValue("@UserId", emp.UserId);
            cmd.Parameters.AddWithValue("@FirstName", emp.FirstName);
            cmd.Parameters.AddWithValue("@LastName", emp.LastName);
            cmd.Parameters.AddWithValue("@JobTitle", emp.JobTitle);
            cmd.ExecuteNonQuery();
            connDB.Close();
        }
예제 #4
0
        public static void SaveRecord(User emp)
        {
            SqlConnection connDB = UtilityDB.ConnectDB();

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = connDB;
            cmd.CommandText = "INSERT INTO [User](UserId,FirstName,LastName,JobTitle)" +
                              " VALUES (@UserId,@FirstName,@LastName,@JobTitle)";

            cmd.Parameters.AddWithValue("@UserId", emp.UserId);
            cmd.Parameters.AddWithValue("@FirstName", emp.FirstName);
            cmd.Parameters.AddWithValue("@LastName", emp.LastName);
            cmd.Parameters.AddWithValue("@JobTitle", emp.JobTitle);
            cmd.ExecuteNonQuery();

            connDB.Close();
        }